Skip to content

Validate lookup qubit labels and cache swap absorption labels - #1

Closed
masterFoad wants to merge 1 commit into
absorb-into-swaps-lean-commutation-checkerfrom
commutation-checker-followup
Closed

masterFoad wants to merge 1 commit into
absorb-into-swaps-lean-commutation-checkerfrom
commutation-checker-followup

Conversation

@masterFoad

Copy link
Copy Markdown
Owner

Follow-up to c81cf60.

  • check_commutation_entries: accept a Qubit or an int-like label
    (operator.index), so NumPy ints work; reject bool or anything else
    with QiskitError instead of returning None.
  • Cache the standard wire labels per (name, width) so a second pass
    call does not query the table again.
  • Note in the docstring why the parameter-free lookup holds for
    crz, crx, rzz, rxx, ryy and rzx at every angle.

Checked: 149 tests pass; same output as your branch on 1690 small
inputs and on Benchpress (6246 cases, identical counts/depth/ESP).

check_commutation_entries now takes each qubit label as a Qubit or as an
integer converted with operator.index, so NumPy integers name the same
qubit as equal Python ints. A bool or any other label raises QiskitError
instead of silently giving None. The shared get_bits_from_py helper,
commute() and commute_nodes() are unchanged.

_AbsorbIntoSwaps keeps the labels it derives from the session
commutation table in a module-level cache keyed by (name, width), so a
second pass call does not query the table again. Tests that replace the
lookup clear the cache for their duration.

Document why the crz, crx, rzz, rxx, ryy and rzx labels found by the
parameter-free lookup hold at every angle.
@masterFoad

Copy link
Copy Markdown
Owner Author

Included in #2, which now targets your branch directly.

@masterFoad masterFoad closed this Oct 25, 2026
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