Plotly circuit
Executed-circuit reconstruction and Plotly traces for the move debugger.
The move dialect program that :func:~bloqade.lanes.visualize.plotly_debug.plotly_debugger
interprets already describes the executed circuit: every gate statement carries
the physical locations (or zone) it acts on, and the interpreted atom state maps
those locations back to qubit ids. This module turns the debugger steps into
circuit columns (one per gate step) and renders them as a compact circuit
diagram on a secondary Plotly axis pair, so the diagram stays in lockstep with
the atom animation.
CircuitColumn
dataclass
CircuitColumn(
step_index: int,
kind: GateKind,
label: str,
description: str,
qubit_ids: tuple[int, ...],
pairs: tuple[tuple[int, int], ...] = (),
)
One executed gate layer of the circuit, tied to a debugger step.
circuit_columns
circuit_columns(
steps: Sequence[DebugStep], arch_spec: ArchSpec
) -> list[CircuitColumn]
Reconstruct the executed circuit, one column per gate step.
The qubit ids are resolved from the interpreted atom state exactly the way
move2squin resolves them when it emits the final squin program, so the
result is the executed circuit by construction (after ASAP/ALAP reordering
and gate fusion).
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/visualize/plotly_circuit.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
circuit_cursor
circuit_cursor(
columns: Sequence[CircuitColumn], step_index: int
) -> float
Position of step_index along the circuit's column axis.
Gate steps sit on their own column. Steps without a gate (moves, fills, loads) sit halfway between the previously executed column and the next one, which is where the atoms are physically travelling to.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/visualize/plotly_circuit.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
circuit_highlight_trace
circuit_highlight_trace(
columns: Sequence[CircuitColumn],
step_index: int,
qubit_count: int,
colors: dict[str, str],
) -> Any
Translucent band over the active column, or a cursor between columns.
Plotly animation merges frame trace attributes into the live trace instead of replacing them, so both variants set the same attribute keys.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/visualize/plotly_circuit.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
circuit_qubit_ids
circuit_qubit_ids(steps: Sequence[DebugStep]) -> list[int]
Every qubit id that occupies a site at any step, in ascending order.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/visualize/plotly_circuit.py
161 162 163 164 165 166 | |
circuit_static_traces
circuit_static_traces(
columns: Sequence[CircuitColumn],
qubit_ids: Sequence[int],
colors: dict[str, str],
) -> list[Any]
Wires, CZ connectors, and gate markers for the executed circuit.
CZ layers draw one connector per pair, staggered into sub-columns when pairs overlap on the wire axis, so each two-qubit gate is legible. Gate markers carry their CZ partner in hover text.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/visualize/plotly_circuit.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
circuit_window_range
circuit_window_range(
cursor: float, column_count: int, window: int
) -> tuple[float, float]
Visible column range keeping cursor centered inside a window.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/visualize/plotly_circuit.py
187 188 189 190 191 192 193 194 195 196 197 | |
cz_pair_offsets
cz_pair_offsets(
pairs: Sequence[tuple[int, int]], rows: dict[int, int]
) -> list[float]
Horizontal offset within a column for each CZ pair.
Pairs whose wire spans overlap would draw collinear connectors and become indistinguishable, so they are assigned to separate sub-columns (a greedy interval colouring). Pairs with disjoint spans share a sub-column. The sub-columns are spread symmetrically around the column centre.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/visualize/plotly_circuit.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
gate_description
gate_description(step: DebugStep) -> str
Format an interpreted gate with named, evaluated parameters.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/visualize/plotly_circuit.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |