Skip to content

Add ascii draw regression test for mid-trace measurements - #5277

Open
VaggelisGian wants to merge 2 commits into
NVIDIA:mainfrom
VaggelisGian:test-draw-ascii-measurement
Open

Add ascii draw regression test for mid-trace measurements#5277
VaggelisGian wants to merge 2 commits into
NVIDIA:mainfrom
VaggelisGian:test-draw-ascii-measurement

Conversation

@VaggelisGian

Copy link
Copy Markdown

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, then mz on q2, then x on q2, and asserts the exact ascii output:

     ╭───╮╭───╮
q2 : ┤ h ├┤ x ├
     ╰───╯╰───╯

On 0.15.1 behavior this crashes instead of misrendering: layers_from_trace stored absolute instruction indices while boxes_from_trace pushed only gates, so a skipped measurement desynced the two and indexed out of bounds. Mirrors the existing LatexDrawTester.skipsNonGateInstructions case.

DCO: all commits signed off as required.

Test output (ctest -R DrawTester -LE gpu_required and friends, devcontainer cu12.6-gcc12, Release, no GPU in this environment):

 3/15 Test #299: qpp_DrawTester.skipsNonGateInstructions .........   Passed    0.02 sec
 5/15 Test #301: qpp_LatexDrawTester.skipsNonGateInstructions ....   Passed    0.02 sec
 8/15 Test #498: dm_DrawTester.skipsNonGateInstructions ..........   Passed    0.02 sec
10/15 Test #500: dm_LatexDrawTester.skipsNonGateInstructions .....   Passed    0.02 sec
13/15 Test #624: stim_DrawTester.skipsNonGateInstructions ........   Passed    0.02 sec
15/15 Test #626: stim_LatexDrawTester.skipsNonGateInstructions ...   Passed    0.02 sec
100% tests passed, 0 tests failed out of 15

pre-commit run --all-files --hook-stage pre-push passes on every hook except markdown-link-check, whose single failure is a pre-existing stale badge URL in the top-level README.md (untouched by this branch); all other checked files report OK.

@copy-pr-bot

copy-pr-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

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
VaggelisGian force-pushed the test-draw-ascii-measurement branch from 886fbeb to bda1830 Compare August 26, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant