Add new Quantikz rendering modules and enhance existing functions for visualization
Feature(vis): Enhance circuit_to_latex_render and GIF creation
This PR introduces cirq.vis.render_circuit and create_gif_from_ipython_images.
The functionality is showcased and described here: in this Jupyter notebook https://drive.google.com/file/d/1KXQjBmQ9rNUjZHJ6QuGolthLN19_K9yK/view?usp=drivesdk (colab: https://colab.sandbox.google.com/drive/1KXQjBmQ9rNUjZHJ6QuGolthLN19_K9yK)
Notes on render_circuit:
* Performs upfront checks for pdflatex and pdftoppm executables. Issues informative warnings and disables relevant functionality if they are not found, preventing unexpected failures.
* If pdflatex fails and an output_tex_path is specified, the problematic .tex file is copied to the specified path for easier user inspection.
Example outputs:
Ideally, we should have some tests, at least for 'circuit_to_latex_quantikz.py'
I think i resolved all comments as you suggested and added a test file.
- All the tests run and pass on my end.
- ps. I don't think i fixed all the lint issues
Anyone to help clean up and merge in?
Pushed some changes here that fix all the CI errors and also fixes (1) and (2) from Eliott's comments.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 99.37%. Comparing base (63cfe53) to head (53a9a75).
:warning: Report is 10 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #7354 +/- ##
========================================
Coverage 99.37% 99.37%
========================================
Files 1082 1087 +5
Lines 96691 97205 +514
========================================
+ Hits 96086 96598 +512
- Misses 605 607 +2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@eliottrosenberg I don't think you can do the over/under brace in quantikz as far as I can tell.
I added classical control. The control dots look a little goofy, but it works now. There's better support for classical controls in the 2023 version of quantikz but it looks like colab currently has the 2020 version which is a bit more limited.
Yes, that’s a good point. It’s probably better to update to the latest version. It’s just what was internally deployed I think was the older one. The new version has one or two small syntax updates to the default behavior of meter for instance, and having its content already been in math mode or not. So that might be something to be a bit careful with when switching.Sent from my iPhoneOn Aug 4, 2025, at 6:09 AM, Doug Strain @.***> wrote:dstrain115 left a comment (quantumlib/Cirq#7354) @eliottrosenberg I don't think you can do the over/under brace in quantikz as far as I can tell. I added classical control. The control dots look a little goofy, but it works now. There's better support for classical controls in the 2023 version of quantikz but it looks like colab currently has the 2020 version which is a bit more limited.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>
Yes, that’s a good point. It’s probably better to update to the latest version. It’s just what was internally deployed I think was the older one. The new version has one or two small syntax updates to the default behavior of meter for instance, and having its content already been in math mode or not. So that might be something to be a bit careful with when switching.
@zlatko-minev Thank you for your work. It's not clear from your last comments whether you are planning to do something more with this PR. Could you let us know if we should wait further?
@dstrain115 I can't tell for certain from your last comment above whether anything needs to be done with respect to Colab compatibility. I sounds like the answer is "no", but it seemed better to double-check with you.
@mhucka No, the PR as it stands is compatible with colab. It's just that for controlled gates the dot looks a little funny due to the old specification. However, controlled gates weren't even supported in the original PR so I think this is fine.
@mhucka No, the PR as it stands is compatible with colab. It's just that for controlled gates the dot looks a little funny due to the old specification. However, controlled gates weren't even supported in the original PR so I think this is fine.
Got it. Thanks.
@zlatko-minev It's not clear from your last comments whether you are planning to do something more with this PR. Could you let us know if we should wait further?
Happy to merge it!
Message ID: @.***>
@mhucka @pavoljuhas Could we get a review/approval for this? It has been sitting here for a long time.
+1, thank you
From: Doug Strain @.> Date: Saturday, August 23, 2025 at 7:24 AM To: quantumlib/Cirq @.> Cc: Zlatko Minev @.>, Mention @.> Subject: Re: [quantumlib/Cirq] Add new Quantikz rendering modules and enhance existing functions for visualization (PR #7354)
[https://avatars.githubusercontent.com/u/22484728?s=20&v=4]dstrain115 left a comment (quantumlib/Cirq#7354)https://github.com/quantumlib/Cirq/pull/7354#issuecomment-3217044494
@mhuckahttps://github.com/mhucka @pavoljuhashttps://github.com/pavoljuhas Could we get a review/approval for this? It has been sitting here for a long time.
— Reply to this email directly, view it on GitHubhttps://github.com/quantumlib/Cirq/pull/7354#issuecomment-3217044494, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZS5ZWA45WVB6S2PZ37DBL3PB2SVAVCNFSM6AAAAAB5KHMRPWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMJXGA2DINBZGQ. You are receiving this because you were mentioned.
@zlatko-minev I was holding off approving it because there are comments by @dstrain115 in the review that have not been addressed:
- https://github.com/quantumlib/Cirq/pull/7354/files#r2094138349
- https://github.com/quantumlib/Cirq/pull/7354/files#r2094139042
Thanks, Mike. For some reason, the links don't point me to the comments you're pointing to. But I don't think there are any essential comments left. There were some possible enhancements that could be left for the future about more specific cases. For now we can I think he better as is with the current version of quantikz
Hi Mike, thanks for finding these. It would be great if someone from the cirq team has the time at the moment to push these small edits over.
@zlatko-minev Just to follow up on the status (although you may have inferred it from the activity on this PR): Pavol is actively working on getting the code into shape for incorporation into Cirq.
Glad to hear, thank you, @mhucka and @pavoljuhas
@zlatko-minev - can you please give this a quick look if this is OK to merge from your side?