Add ascii draw regression test for mid-trace measurements - #5277
Open
VaggelisGian wants to merge 2 commits into
Open
Add ascii draw regression test for mid-trace measurements#5277VaggelisGian wants to merge 2 commits into
VaggelisGian wants to merge 2 commits into
Conversation
The ascii renderer crashed with an IndexError whenever a measurement appeared before a later gate in the trace: the layers stored absolute instruction indices while boxes were indexed by gate order, and string_diagram_from_trace mixed the two conventions. The indexing was unified on main in NVIDIA#4945; this adds the missing DrawTester counterpart of LatexDrawTester.skipsNonGateInstructions to lock the behavior in. Related to NVIDIA#5258 Signed-off-by: Vaggelis <baggelis100@gmail.com>
clang-format 22 repacks adjacent string literals, so the escaped multi-line expectation fails the formatting check. Express it as a raw string like the sibling tests do; content is unchanged. Signed-off-by: Vaggelis <baggelis100@gmail.com>
VaggelisGian
force-pushed
the
test-draw-ascii-measurement
branch
from
August 26, 2026 13:22
886fbeb to
bda1830
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #5258
Test-only regression coverage for the mid-circuit-measurement draw bug reported in #5258. The renderer defect itself is already fixed on main by the trace rework in #4945 (included in
v0.15.2_base); this adds an ascii-draw test so a gate that follows a measurement in the middle of a trace keeps its correct layer position.The test builds a three-qubit trace with
h, thenmzon q2, thenxon q2, and asserts the exact ascii output:On 0.15.1 behavior this crashes instead of misrendering:
layers_from_tracestored absolute instruction indices whileboxes_from_tracepushed only gates, so a skipped measurement desynced the two and indexed out of bounds. Mirrors the existingLatexDrawTester.skipsNonGateInstructionscase.DCO: all commits signed off as required.
Test output (
ctest -R DrawTester -LE gpu_requiredand friends, devcontainer cu12.6-gcc12, Release, no GPU in this environment):pre-commit run --all-files --hook-stage pre-pushpasses on every hook exceptmarkdown-link-check, whose single failure is a pre-existing stale badge URL in the top-levelREADME.md(untouched by this branch); all other checked files report OK.