Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fix in the syntax of jax.vmap #6668

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ added `binary_mapping()` function to map `BoseWord` and `BoseSentence` to qubit
* `jax.vmap` can be captured with `qml.capture.make_plxpr` and is compatible with quantum circuits.
[(#6349)](https://github.com/PennyLaneAI/pennylane/pull/6349)
[(#6422)](https://github.com/PennyLaneAI/pennylane/pull/6422)
[(#6668)](https://github.com/PennyLaneAI/pennylane/pull/6668)

* `qml.capture.PlxprInterpreter` base class has been added for easy transformation and execution of
pennylane variant jaxpr.
Expand Down
2 changes: 1 addition & 1 deletion pennylane/workflow/_capture_qnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def qfunc(*inner_args):

# pylint: disable=protected-access
return jax.vmap(partial(qnode._impl_call, shots=shots), batch_dims[n_consts:])(
*jax.tree_util.tree_leaves(non_const_args)
*non_const_args
)

# pylint: disable=protected-access
Expand Down
2 changes: 1 addition & 1 deletion tests/capture/test_capture_qnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ def workflow4(y, x, z):
assert len(eqn.outvars) == 1
assert eqn.outvars[0].aval.shape == (3,)

result = jax.core.eval_jaxpr(jaxpr.jaxpr, jaxpr.consts, x, y, 1)
result = jax.core.eval_jaxpr(jaxpr.jaxpr, jaxpr.consts, x["arr"], y, 1)
expected = jax.numpy.array([0.93005586, 0.00498127, -0.88789978]) * y
assert jax.numpy.allclose(result[0], expected)
assert jax.numpy.allclose(result[1], expected)
Expand Down
Loading