PennyLaneAI / PennyLaneAI/catalyst
`qp.allocate(1)`: using the qubit without index works but not formally supported
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 234
- Forks
- 84
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 66
Description
When using qp.allocate(1) to allocate a single qubit, calling qp.H(w) (without indexing w[0]) silently succeeds. This behavior is not guaranteed and relies on implementation details. PL / Catalyst should either formally support this pattern or emit a warning/error directing users to always index their qubit registers.
Example:
import pennylane as qp
@qp.qjit(capture=True)
@qp.qnode(qp.device("null.qubit", wires=2))
def circuit():
with qp.allocate(1) as w:
# This works but is not guaranteed:
qp.H(w)
# This is the correct, explicit form:
# qp.H(w[0])
return qp.state()
print(circuit())
Versions:
Name: pennylane
Version: 0.45.0.dev52
JAX version: 0.7.1
Catalyst version: 0.15.0.dev47
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 by reproducing the provided qp.allocate(1) and qp.H(w) example with the listed PennyLane and Catalyst versions. Trace how qp.allocate and the unindexed register reach capture and operator handling; done means the behavior is formally supported or a clear warning/error directs users to qp.H(w[0]), with coverage for the chosen outcome.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100