Skip to content

Accept rotation gate names in CommutationChecker filters#16409

Open
peter941221 wants to merge 6 commits into
Qiskit:mainfrom
peter941221:peter/fix-16407-commutationchecker
Open

Accept rotation gate names in CommutationChecker filters#16409
peter941221 wants to merge 6 commits into
Qiskit:mainfrom
peter941221:peter/fix-16407-commutationchecker

Conversation

@peter941221

@peter941221 peter941221 commented Jun 11, 2026

Copy link
Copy Markdown

CommutationChecker used to map parameterized rotation gates to their generators before it applied the optional gates filter. With a filter like {"rx"}, an RXGate pair was normalized to "x" first, so the filter rejected it before the commutation lookup.

This PR keeps the filter keyed to the public gate names and still keeps generator normalization for the commutation logic itself. A filter like {"rx"} now accepts RXGate pairs from #16407, while unrelated filters such as {"rz"} still return False.

The regression coverage checks:

  • the exact RXGate reproducer from the issue with gates={"rx"}
  • the rejected generator-name filter with gates={"x"}
  • the accepted mixed filter with gates={"rx", "x"}
  • the still-rejected unrelated filter with gates={"rz"}

Tests run:

  • python -m unittest test.python.circuit.test_commutation_checker.TestCommutationChecker.test_parameterized_gates_when_gates_specified test.python.circuit.test_commutation_checker.TestCommutationChecker.test_parameterized_gates
  • python -m unittest test.python.circuit.test_commutation_checker
  • cargo fmt --all --check
  • python -m ruff check test/python/circuit/test_commutation_checker.py

Fix #16407

AI/LLM disclosure

  • I didn't use LLM tooling, or only used it privately.
  • I used the following tool to help write this PR description:
    OpenAI GPT-5 Codex
  • I used the following tool to generate or modify code:
    OpenAI GPT-5 Codex

Comment thread crates/transpiler/src/commutation_checker.rs Outdated
@ShellyGarion ShellyGarion added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jun 11, 2026
@ShellyGarion ShellyGarion added the mod: transpiler Issues and PRs related to Transpiler label Jun 11, 2026
Comment thread crates/transpiler/src/commutation_checker.rs
Comment thread releasenotes/notes/commutation-checker-rotation-gate-filter-9652352b76b6f6ae.yaml Outdated
Comment thread test/python/circuit/test_commutation_checker.py Outdated
@peter941221 peter941221 force-pushed the peter/fix-16407-commutationchecker branch from 892d160 to 762bfd2 Compare June 14, 2026 13:15
Comment thread test/python/circuit/test_commutation_checker.py Outdated
Comment thread test/python/circuit/test_commutation_checker.py Outdated
Comment thread crates/transpiler/src/commutation_checker.rs Outdated
@peter941221 peter941221 force-pushed the peter/fix-16407-commutationchecker branch from 762bfd2 to 095318c Compare June 16, 2026 07:17
@peter941221

Copy link
Copy Markdown
Author

Pushed 095318c.

I moved the gates early return to the start of commute(), renamed the regression to test_parameterized_gates_when_gates_specified, and trimmed it to the rx cases the review asked for, plus the mixed and empty filters.

I rebuilt the Rust extension and reran:
python -m unittest test.python.circuit.test_commutation_checker.TestCommutationChecker.test_parameterized_gates_when_gates_specified test.python.circuit.test_commutation_checker.TestCommutationChecker.test_parameterized_gates
python -m unittest test.python.circuit.test_commutation_checker
cargo fmt --all --check
python -m ruff check test/python/circuit/test_commutation_checker.py

Comment thread test/python/circuit/test_commutation_checker.py Outdated
@alexanderivrii

Copy link
Copy Markdown
Member

This is a copy-pasted message. At the moment, you have 9 open PRs, and it seems that most of them were created using an LLM with little to no human involvement in the process. Talking to LLMs is not a good use of reviewers' time. I strongly suggest keeping only 1 or 2 PRs that you are willing to invest your own time and effort in as a human, and closing the rest.

@peter941221

Copy link
Copy Markdown
Author

I narrowed this PR to the named-filter behavior only and dropped the empty-set assertion. I closed the other open PRs, so this and #16388 are the two active ones.

@peter941221 peter941221 force-pushed the peter/fix-16407-commutationchecker branch from c2ec85e to 4588045 Compare June 16, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PR PRs from contributors that are not 'members' of the Qiskit repo mod: transpiler Issues and PRs related to Transpiler

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

CommutationChecker gate filtering ignores generator names for parameterized rotation gates

3 participants