Skip to content

[qref 3.2] Migrate gate-like ops' plxpr conversion to reference semantics#2672

Open
paul0403 wants to merge 13 commits intopaul0403/qref_frontend_alloc_and_obsfrom
paul0403/qref_frontend_gates
Open

[qref 3.2] Migrate gate-like ops' plxpr conversion to reference semantics#2672
paul0403 wants to merge 13 commits intopaul0403/qref_frontend_alloc_and_obsfrom
paul0403/qref_frontend_gates

Conversation

@paul0403
Copy link
Copy Markdown
Member

@paul0403 paul0403 commented Apr 9, 2026

Context:
Migrate gate-like ops' plxpr conversion to reference semantics.

This PR also handles dynamic allocations and deallocations from qml.allocate().

Note: adjointed gates are not handled in this PR. They will be handled in a future PR that specifically handles the adjoint region from plxpr.

  • CustomOp
  • MultiRZOp
  • PCPhaseOp
  • PauliRotOp
  • GlobalPhaseOp
  • QubitUnitaryOp
  • MeasureOp
  • SetStateOp
  • SetBasisStateOp

Related GitHub Issues:
[sc-115869]

Comment on lines +180 to +190
for w in op.wires:
if isinstance(w, DynamicJaxprTracer) and isinstance(w.val.aval, QrefQubit):
in_qubits.append(w)
else:
in_qubits.append(qref_get_p.bind(self.init_qreg, w))
for w in control_wires:
if isinstance(w, DynamicJaxprTracer) and isinstance(w.val.aval, QrefQubit):
in_control_qubits.append(w)
else:
in_control_qubits.append(qref_get_p.bind(self.init_qreg, w))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: do this treatement for everyone

@github-actions
Copy link
Copy Markdown
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md on your branch with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant