PennyLaneAI / PennyLaneAI/catalyst
mcm_method='one-shot' is not supported with a dynamic number of shots
Open
Nobody has claimed this yet.
bug
frontend
- Dominant language
- Python
- Stars
- 234
- Forks
- 84
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 66
Description
Possibly related to a similar issue with dynamic shapes in #1949, the dynamic one-shot transform does not work when the number of shots is a tracer value. The underlying issue is the vmap transform not being able to handle a dynamic batch size.
import pennylane as qml
@qml.qjit
def main(shots: int):
@qml.qnode(qml.device("lightning.qubit", wires=1), mcm_method="one-shot")
def f():
qml.H(0)
return qml.sample()
return qml.set_shots(shots)(f)()
main(10)
File "catalyst/frontend/catalyst/api_extensions/function_maps.py", line 368, in _get_batch_size
if not batch_size:
jax.errors.TracerBoolConversionError: Attempted boolean conversion of traced array with shape int64[].
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at catalyst/frontend/catalyst/api_extensions/function_maps.py, especially _get_batch_size, and reproduce the shown qjit example with main(10). Trace how the dynamic shots value reaches the vmap transform, then verify that the example runs without the reported TracerBoolConversionError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- quantum-computing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100