Skip to content

Support qreg + scalar qubit-index signatures in decompose-lowering (#2869)#2952

Open
jk20342 wants to merge 4 commits into
PennyLaneAI:mainfrom
jk20342:main
Open

Support qreg + scalar qubit-index signatures in decompose-lowering (#2869)#2952
jk20342 wants to merge 4 commits into
PennyLaneAI:mainfrom
jk20342:main

Conversation

@jk20342

@jk20342 jk20342 commented Jun 16, 2026

Copy link
Copy Markdown

Context:

decompose-lowering's prepareCallOperands assumed qreg-mode rules pack all
wire indices into a single tensor (e.g. tensor<2xi64>). Signatures of the form
(qreg, *params, first_qubit_index, second_qubit_index, ...) - produced by ops
like quantum.paulirot - hit an out-of-bounds SmallVector access and crashed.

Description of the Change:
prepareCallOperands now maps wire indices to function inputs one at a time,
letting each input type's element count decide how many indices it consumes
handles both a single packed tensor<Nxi64> arg and separate scalar tensor<i64>
args. Also removed leftover debug .dump() calls.

Benefits:
Fixes the crash; qreg-mode rules with per-qubit index arguments now lower correctly.

Possible Drawbacks:
None known.

Related GitHub Issues:
Fixes #2869

jk20342 added 3 commits June 15, 2026 23:43
Refactor handling of wire indices to support both packed tensor arguments and scalar arguments. Adjust logic to consume function inputs based on expected element counts.
Removed debug dump statements for decompFunc and callOperands.
@github-actions github-actions Bot added the external PRs where the author is not a part of PennyLane Org (or part of external contributors team) label Jun 16, 2026
Added a note about the `--decompose-lowering` pass fix.
@jk20342

jk20342 commented Jun 16, 2026

Copy link
Copy Markdown
Author

one thing I didnt change since it was already a pre existing contract is the fact that assert is loading bearing under NDEBUG but could add an emitError + failure() to the PauliRot//Custom paths since MultiRZ already does it

@dime10

dime10 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Hi @jk20342, welcome to the Catalyst project 👋 And thank you for opening a PR!

Our team will have a look the submitted code, however one caveat is that this component (compiler decompositions) is heavily in flux right now, so we may or may not be able to merge your contribution. Please allow us some time to look into it. In the future, it would be safer to comment on the issue you are intending to tackle before work starts, that way we coordinate or provide missing context that may be necessary.

Cheers :)

@jk20342

jk20342 commented Jun 17, 2026

Copy link
Copy Markdown
Author

Hi @jk20342, welcome to the Catalyst project 👋 And thank you for opening a PR!

Our team will have a look the submitted code, however one caveat is that this component (compiler decompositions) is heavily in flux right now, so we may or may not be able to merge your contribution. Please allow us some time to look into it. In the future, it would be safer to comment on the issue you are intending to tackle before work starts, that way we coordinate or provide missing context that may be necessary.

Cheers :)

thanks :) i normally contribute to pennylane rather then catalyst but this project seems quite interesting thanks for the info for future PRs :D

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

Labels

external PRs where the author is not a part of PennyLane Org (or part of external contributors team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

decompose-lowering's prepareCallOperands doesn't support qreg + multiple individual qubit indices

2 participants