Skip to main content
view_program renders a routed TopologicalProgram (produced by routing) as an interactive 3-D HTML page. The page needs no server and opens directly in any browser, but it loads its 3-D library from a CDN, so viewing it requires internet access. Here’s a small routed program (S, H, T, RZ, CX on two qubits) rendered by the viewer:
This viewer is fully interactive, so go ahead and play with it! Drag to orbit, scroll to zoom, right-drag to pan, and use the toggles at the top right to switch between the surface-code and logical views.
The show=True behaviour depends on where you run it:
  • In a Jupyter notebook, the viewer is embedded directly in the cell’s output, so you can rotate and inspect it inline without leaving the notebook.
  • Outside a notebook, it opens output_path in your web browser — so output_path is required when show=True (otherwise a ClassiqValueError is raised). To just get the HTML without displaying it, omit show (or pass show=False) and use the returned string.

Focus on a range of cycles (z-axis)

The lattice’s z-axis is time, measured in cycles. A cycle is one logical time step, one z-layer of the lattice, and the noise model assumes each cycle spans exactly d rounds of stabilizer measurement, where d is the code distance. For a tall program this can be a lot to render at once, so view_program accepts start_cycle and end_cycle to show only a slice of the circuit along the z-axis. Cubes outside [start_cycle, end_cycle) are hidden, and the window is shifted down so start_cycle becomes the scene’s base.
  • start_cycle defaults to 0. end_cycle defaults to the program’s total cycle count (program.stats.cycles), but when left unspecified it is capped to 100 cycles from start_cycle so a very tall circuit stays manageable — pass end_cycle explicitly to override.
  • The window must satisfy 0 <= start_cycle < end_cycle <= program.stats.cycles, and can span at most 2500 cycles. A window outside these limits raises a ClassiqAPIError; narrow the range with start_cycle/end_cycle.

Interacting with the viewer

  • Orbit: drag  ·  Zoom: scroll  ·  Pan: right-drag.
  • Colour modes (top-right toggle):
    • Surface-code view (default) colours each cube and pipe by its X/Z boundary type. The legend also marks Y cubes (S gates and the tips of T-gate arms), T cubes (the magic state each T gate consumes), and H strips, the bands around a pipe where a Hadamard swaps the boundary types.
    • Logical view colours each cube by the gate it belongs to; the legend lists the gate types.
  • Camera presets:
    • View all frames the entire lattice.
    • View layout grid frames the 2-D qubit footprint from above (this is the default pose when the viewer opens).
  • The info panel (top-left) reports the qubit count, layout, cycle count, node count, and a per-gate breakdown.

Embed the visualization elsewhere

Because the returned HTML is a single page, you can embed it in your own site or app with an <iframe> pointing at the saved file:
Next, estimate the total error of the routed program.