Skip to content

Commit 891e452

Browse files
zlatko-minevdstrain115mhuckapavoljuhas
authored
Add new Quantikz rendering modules and enhance existing functions for visualization (#7354)
Feature(vis): Enhance circuit_to_latex_render and GIF creation This PR introduces `cirq.contrib.quantikz` with the `render_circuit` function to produce circuit diagrams in LaTeX using the quantikz package. 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: ![image](https://github.com/user-attachments/assets/d941ab0d-30dc-4a01-aa85-aa4a4b1ef377) ![image](https://github.com/user-attachments/assets/79450bc3-25e6-46a8-9cf7-556b53a0722f) ![image](https://github.com/user-attachments/assets/d4b9013a-613b-4a6c-b2c2-50a04374ebe9) ![image](https://github.com/user-attachments/assets/e9d67a29-a6d5-4efb-abfd-cdfdce5a1422) ![image](https://github.com/user-attachments/assets/e0a36722-d066-473d-987c-b59850a88792) --------- Co-authored-by: Doug Strain <dstrain@google.com> Co-authored-by: Michael Hucka <mhucka@caltech.edu> Co-authored-by: Pavol Juhas <juhas@google.com>
1 parent d69b437 commit 891e452

File tree

5 files changed

+1422
-0
lines changed

5 files changed

+1422
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2025 The Cirq Developers
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Converts Cirq circuits to LaTeX diagrams using the Quantikz package."""
16+
17+
from cirq.contrib.quantikz.circuit_to_latex_quantikz import (
18+
CircuitToQuantikz as CircuitToQuantikz,
19+
GATE_STYLES_COLORFUL as GATE_STYLES_COLORFUL,
20+
)
21+
from cirq.contrib.quantikz.circuit_to_latex_render import render_circuit as render_circuit

0 commit comments

Comments
 (0)