Skip to content

Preserve untagged FrozenCircuit instance across with_tags calls - #8422

Open
mshearn wants to merge 2 commits into
quantumlib:mainfrom
mshearn:patch-1
Open

mshearn wants to merge 2 commits into
quantumlib:mainfrom
mshearn:patch-1

Conversation

@mshearn

@mshearn mshearn commented Oct 9, 2026

Copy link
Copy Markdown

In FrozenCircuit.with_tags, forward new_circuit.untagged = self.untagged alongside new_circuit._moments = self._moments so that calling .untagged on any tagged wrapper returns the original untagged FrozenCircuit instance (c.with_tags('a').untagged is c and c.with_tags('a').untagged is c.with_tags('b').untagged) without allocating a duplicate FrozenCircuit.

In FrozenCircuit.with_tags, forward `new_circuit.untagged = self.untagged` alongside `new_circuit._moments = self._moments` so that calling `.untagged` on any tagged wrapper returns the original untagged FrozenCircuit instance (`c.with_tags('a').untagged is c` and `c.with_tags('a').untagged is c.with_tags('b').untagged`) without allocating a duplicate FrozenCircuit.
Verify in test_tagged_circuits that calling .untagged on tagged FrozenCircuit copies returns the exact same untagged FrozenCircuit instance (`is`).
@mshearn
mshearn requested a review from a team as a code owner October 9, 2026 23:00
@github-actions github-actions Bot added the Size: XS <10 lines changed label Oct 9, 2026
@mshearn

mshearn commented Oct 9, 2026

Copy link
Copy Markdown
Author

@maffoo for review when you have a chance — thanks!

@codecov

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.59%. Comparing base (1403830) to head (f91333a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8422      +/-   ##
==========================================
- Coverage   99.59%   99.59%   -0.01%     
==========================================
  Files        1133     1133              
  Lines      103919   103923       +4     
==========================================
- Hits       103498   103497       -1     
- Misses        421      426       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

Size: XS <10 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant