Repository navigation
Conversation
Pattern.copy made shallow copies of the commands, so the s_domain, t_domain and domain sets were shared with the original pattern. shift_signals(method="mc") updates these sets in place, so shifting the signals of a copy also rewrote the original, which then no longer implemented the same map. Copy the set-valued fields of each command. Fixes TeamGraphix#653. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context (if applicable):
Pattern.copybuilt the new sequence withcopy.copy(cmd), so thes_domain/t_domain/domainsets were shared between a pattern and its copy.shift_signals(method="mc")updates those sets in place (_commute_xs,_commute_zs,_commute_ms,_commute_ss), so shifting the signals of a copy also rewrote the original, which then no longer implemented the circuit (lowest fidelity 0.078 on the H·H·H example from the issue).Description of the change:
Pattern.copynow copies each command with a small helper_copy_command, which makes a shallow copy and then replaces every set-valued attribute with a fresh set. This keepscopy.copysemantics for the other fields (measurements, parameters, customBaseN/BaseMsubclasses) and makes a copy independent of any in-place domain update, not only the four_commute_*functions.test_shift_signals_mc_on_copy_keeps_original: transpiles H·H·H, shifts the signals of a copy with"mc", checks that the original command list is unchanged and that both patterns reproduce the circuit on every measurement branch (FixedBranchSelector). It fails onmasterand passes with the change.Checks run locally (WSL,
uv sync --extra dev): fullpytest tests(6840 passed, 562 skipped, 26 xfailed),ruff check,ruff format --check,mypyandpyrighton the touched files.Related issue:
Fixes #653
AI use: the fix, test and description were written with Claude Code (Claude Opus 5.5); Claude Code also ran the failing/passing test and the local runs.
🤖 Generated with Claude Code