Skip to content

Add lightcone filter transformer#8107

Merged
eliottrosenberg merged 4 commits into
mainfrom
u/eliottrosenbrg/lightcone_filter
May 30, 2026
Merged

Add lightcone filter transformer#8107
eliottrosenberg merged 4 commits into
mainfrom
u/eliottrosenbrg/lightcone_filter

Conversation

@eliottrosenberg
Copy link
Copy Markdown
Collaborator

No description provided.

@eliottrosenberg eliottrosenberg requested a review from a team as a code owner May 29, 2026 23:33
@github-actions github-actions Bot added the size: M 50< lines changed <250 label May 29, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.60%. Comparing base (defc9a0) to head (daedcc7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8107   +/-   ##
=======================================
  Coverage   99.59%   99.60%           
=======================================
  Files        1116     1118    +2     
  Lines      100923   100951   +28     
=======================================
+ Hits       100519   100550   +31     
+ Misses        404      401    -3     

☔ View full report in Codecov by Sentry.
📢 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.

Comment thread cirq-core/cirq/transformers/lightcone_filter.py Outdated
Co-authored-by: Pavol Juhas <juhas@google.com>
@eliottrosenberg eliottrosenberg enabled auto-merge May 30, 2026 03:55
@eliottrosenberg eliottrosenberg added this pull request to the merge queue May 30, 2026
Merged via the queue into main with commit 74abd87 May 30, 2026
52 checks passed
@eliottrosenberg eliottrosenberg deleted the u/eliottrosenbrg/lightcone_filter branch May 30, 2026 04:09


@transformer_api.transformer()
def lightcone_filter(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - I think we could use transformer_primitives.map_operations here and get this handling FrozenCircuit-s for free.

Do you want me to take a stab at that?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to suggest this in #8109! Thanks!

Comment thread cirq-core/cirq/transformers/lightcone_filter_test.py
Comment thread cirq-core/cirq/transformers/lightcone_filter_test.py
circuit += circuits.Circuit(ops.M(qubits[:10]))
assert [len(moment) for moment in circuit] == [25, 10, 25, 10, 25, 10, 25, 10, 25, 10, 25, 1]
new_circuit = ct.lightcone_filter(circuit)
assert [len(moment) for moment in new_circuit] == [18, 8, 13, 5, 10, 4, 10, 4, 10, 4, 10, 1]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hard to make sense of without knowing the exact seed-dependent random circuit.

Can you perhaps add checks that dropped operations missing in new_circuit are all acting on other qubits than the measured ones and also validating that new_circuit operations are a subset of the original ones?

Also it would be nice to add a mid-circuit measurement of few extra qubits and verify its lightcone would show up only in preceding moments.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified the test to capture most of your suggestions here. Feel free to modify the test further. Thanks!

Comment thread cirq-core/cirq/transformers/lightcone_filter.py Outdated
@pavoljuhas
Copy link
Copy Markdown
Collaborator

@eliottrosenberg - can you PTAL at comments I got in after the merge?

@eliottrosenberg
Copy link
Copy Markdown
Collaborator Author

@pavoljuhas done in #8109. Thanks!

pull Bot pushed a commit to Intuitive-Flow/Cirq that referenced this pull request Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: M 50< lines changed <250

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants