Skip to content

Remove the bare-RESULT path & fix sample with named measurements on QIR output logs - #5768

Merged
khalatepradnya merged 3 commits into
NVIDIA:mainfrom
khalatepradnya:fix/drop-bare-result-records
Oct 30, 2026
Merged

khalatepradnya merged 3 commits into
NVIDIA:mainfrom
khalatepradnya:fix/drop-bare-result-records

Conversation

@khalatepradnya

@khalatepradnya khalatepradnya commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Removes the RecordLogParser path that accepted RESULT records without an enclosing ARRAY record. Such a record is now an error, and the parser no longer reads METADATA values.
  • Indexes each RESULT record by its position in its array, which fixes those kernels.

Motivation

  • [QIR] Insert array record call in sampling workflow #3553 added qir-insert-array-record, which declares an array<i1 x N> before the result records of every sampled entry point. It kept the bare-RESULT path as a temporary workaround "until all backends consistently use the new transformation pass".
  • That condition holds now:
    • Both QIR lowering pipelines schedule the pass (addConvertToQIRAPIPipeline and addWiresetToProfileQIRPipeline).
    • The pass counts every result_record_output call in the entry point, user-specified measurements included. It skips only run entry points, whose logs carry typed return-value records.
    • quantinuum is the only target that enables output_log, and QuantinuumServerHelper is the only caller of createSampleResultFromQirOutput.
  • Indices from labels:
    • The parser read a result's index from its label: r00003 gave 3 and name%2 gave 2. But a label is a register name. UpdateRegisterNames restarts the % suffix for each register, and the r counter counts only unnamed results.
    • Records arrive in the order the kernel measured them, which is the order codegen numbers results in (ConvertToQIRAPI.cpp). A result's index is its position in its array.
    • [fix] [sample] Correctly parse QIR log for results that are out of order #3530 added the label parsing for a log whose records arrived out of order. No current producer reorders them (qci was removed)
  • Sub-registers: This path returns only the global register, as before. Sub-registers in sample_result are deprecated, as the runtime warns.

khalatepradnya and others added 2 commits October 29, 2026 11:35
`RecordLogParser` collected RESULT records that arrive outside an ARRAY
into an implicit array, sized by the `required_num_results` metadata.
`qir-insert-array-record` pass, which declares an `array<i1 x N>` before
the result records of every sampled entry point. Both QIR lowering
pipelines now run the pass, and `quantinuum` is the only target that
sends output logs to the parser, so the implicit array has no producer
left.

A RESULT record outside an ARRAY now throws. The parser reads no
METADATA values anymore, so the `required_num_results` special case and
the metadata map go too. The parser tests wrap their RESULT records in
ARRAY records, as current logs do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
`sample` on a QIR output log threw "Duplicate container index" for a
kernel with two named measurement registers, or with a named
measurement next to an unnamed one. The parser read a result's index
from its label: `r00003` gave 3 and `name%2` gave 2. But a label is a
register name. `UpdateRegisterNames` restarts the `%` suffix for each
register, and the `r` counter counts only unnamed results, so two
results can claim the same index.

Results arrive in the order the kernel measured them, which is the order
codegen numbers them in, so a result's index is its position in its
array. The parser no longer reads RESULT labels.

Also from review of the previous commit: drop a stale comment on
`ContainerStorage`, correct the RESULT-branch comment, and test a shot
that carries more results than its array declares, which the old parser
turned into an extra row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
@khalatepradnya
khalatepradnya force-pushed the fix/drop-bare-result-records branch from ef3a5b4 to 0a44b7d Compare October 29, 2026 18:37
@khalatepradnya khalatepradnya changed the title [runtime] Remove the bare-RESULT path from the output log parser [runtime] Fix sample with named measurements on QIR output logs Oct 29, 2026
@NVIDIA NVIDIA deleted a comment from github-actions Bot Oct 29, 2026
@khalatepradnya
khalatepradnya marked this pull request as ready for review October 29, 2026 18:43
@github-actions github-actions Bot added runtime CUDA quantum runtime testing Relates to testing labels Oct 29, 2026
@khalatepradnya khalatepradnya changed the title [runtime] Fix sample with named measurements on QIR output logs Remove the bare-RESULT path & fix sample with named measurements on QIR output logs Oct 29, 2026
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>

@1tnguyen 1tnguyen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks @khalatepradnya!

@github-actions

Copy link
Copy Markdown

CI Summary (push) — ✅ passed

Run #40943853632 · ✅ 8 · ⏩ 10 · ❌ 0 · ⛔ 0

Top-level jobs (18)
Job Result
binaries ⏩ skipped
build_and_test ✅ success
changes ✅ success
config_devdeps ✅ success
config_source_build ⏩ skipped
config_wheeldeps ✅ success
devdeps ✅ success
docker_image ⏩ skipped
documentation ✅ success
gen_code_coverage ⏩ skipped
metadata ✅ success
python_devel_wheel ⏩ skipped
python_metapackages ⏩ skipped
python_wheels ⏩ skipped
python_wheels_cu12_validation ⏩ skipped
python_wheels_cu13 ⏩ skipped
source_build ⏩ skipped
wheeldeps ✅ success
⏩ Skipped jobs (10) — intentionally skipped on PR builds; run on merge_group / workflow_dispatch
Job
binaries
config_source_build
docker_image
gen_code_coverage
python_devel_wheel
python_metapackages
python_wheels_cu12_validation
python_wheels_cu13
python_wheels
source_build
All sub-jobs (47) — every matrix leg, with links
Job Status Link
Build and test (amd64, gcc12, openmpi) / Dev environment (Debug) ✅ success view
Build and test (amd64, gcc12, openmpi) / Dev environment (Python) ✅ success view
Build and test (amd64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (amd64, llvm, openmpi) / Dev environment (Python) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Python) ✅ success view
CI Summary ❔ in_progress view
Check for stable CUDA-Q changes ✅ success view
Configure build (devdeps) ✅ success view
Configure build (source_build) ⏩ skipped view
Configure build (wheeldeps) ✅ success view
Create CUDA 12 Python wheels ⏩ skipped view
Create CUDA 13 Python wheels ⏩ skipped view
Create CUDA Quantum installer ⏩ skipped view
Create Docker images ⏩ skipped view
Create Python metapackages ⏩ skipped view
Create shared Python development wheel ⏩ skipped view
Documentation / Build and check docs ✅ success view
Gen code coverage ⏩ skipped view
Load dependencies (amd64, gcc12) / Caching ✅ success view
Load dependencies (amd64, gcc12) / Finalize ✅ success view
Load dependencies (amd64, gcc12) / Metadata ✅ success view
Load dependencies (amd64, llvm) / Caching ✅ success view
Load dependencies (amd64, llvm) / Finalize ✅ success view
Load dependencies (amd64, llvm) / Metadata ✅ success view
Load dependencies (arm64, gcc12) / Caching ✅ success view
Load dependencies (arm64, gcc12) / Finalize ✅ success view
Load dependencies (arm64, gcc12) / Metadata ✅ success view
Load dependencies (arm64, llvm) / Caching ✅ success view
Load dependencies (arm64, llvm) / Finalize ✅ success view
Load dependencies (arm64, llvm) / Metadata ✅ success view
Load source build cache ⏩ skipped view
Load wheel dependencies (amd64, 12.6) / Caching ✅ success view
Load wheel dependencies (amd64, 12.6) / Finalize ✅ success view
Load wheel dependencies (amd64, 12.6) / Metadata ✅ success view
Load wheel dependencies (amd64, 13.0) / Caching ✅ success view
Load wheel dependencies (amd64, 13.0) / Finalize ✅ success view
Load wheel dependencies (amd64, 13.0) / Metadata ✅ success view
Load wheel dependencies (arm64, 12.6) / Caching ✅ success view
Load wheel dependencies (arm64, 12.6) / Finalize ✅ success view
Load wheel dependencies (arm64, 12.6) / Metadata ✅ success view
Load wheel dependencies (arm64, 13.0) / Caching ✅ success view
Load wheel dependencies (arm64, 13.0) / Finalize ✅ success view
Load wheel dependencies (arm64, 13.0) / Metadata ✅ success view
Prepare cache clean-up ❔ in_progress view
Retrieve PR info ✅ success view
Validate CUDA 12 Python wheels ⏩ skipped view
✅ Required checks (7/7) — declared in .github/required-checks.yml for push
Required check Status Link
Build and test (amd64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (amd64, llvm, openmpi) / Dev environment (Python) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Python) ✅ success view
Build and test (amd64, gcc12, openmpi) / Dev environment (Debug) ✅ success view
Build and test (amd64, gcc12, openmpi) / Dev environment (Python) ✅ success view
Documentation / Build and check docs ✅ success view

@khalatepradnya
khalatepradnya added this pull request to the merge queue Oct 29, 2026
@github-actions

Copy link
Copy Markdown

CI Summary (merge_group) — ✅ passed

Run #40962879832 · ✅ 5 · ⏩ 13 · ❌ 0 · ⛔ 0

⚡ Fast merge queue — only the llvm dev-environment build+test legs ran.
Wheels, metapackages, installers, Docker images, and the gcc12 legs were skipped.
Set the repository variable MERGE_QUEUE_FAST to false to restore the full matrix.

Top-level jobs (18)
Job Result
binaries ⏩ skipped
build_and_test ✅ success
changes ✅ success
config_devdeps ✅ success
config_source_build ⏩ skipped
config_wheeldeps ⏩ skipped
devdeps ✅ success
docker_image ⏩ skipped
documentation ⏩ skipped
gen_code_coverage ⏩ skipped
metadata ✅ success
python_devel_wheel ⏩ skipped
python_metapackages ⏩ skipped
python_wheels ⏩ skipped
python_wheels_cu12_validation ⏩ skipped
python_wheels_cu13 ⏩ skipped
source_build ⏩ skipped
wheeldeps ⏩ skipped
⏩ Skipped jobs (13) — intentionally skipped on PR builds; run on merge_group / workflow_dispatch
Job
binaries
config_source_build
config_wheeldeps
docker_image
documentation
gen_code_coverage
python_devel_wheel
python_metapackages
python_wheels_cu12_validation
python_wheels_cu13
python_wheels
source_build
wheeldeps
All sub-jobs (28) — every matrix leg, with links
Job Status Link
Build and test (amd64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (amd64, llvm, openmpi) / Dev environment (Python) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Python) ✅ success view
CI Summary ❔ in_progress view
Check for stable CUDA-Q changes ✅ success view
Configure build (devdeps) ✅ success view
Configure build (source_build) ⏩ skipped view
Configure build (wheeldeps) ⏩ skipped view
Create CUDA 12 Python wheels ⏩ skipped view
Create CUDA 13 Python wheels ⏩ skipped view
Create CUDA Quantum installer ⏩ skipped view
Create Docker images ⏩ skipped view
Create Python metapackages ⏩ skipped view
Create shared Python development wheel ⏩ skipped view
Documentation ⏩ skipped view
Gen code coverage ⏩ skipped view
Load dependencies (amd64, llvm) / Caching ✅ success view
Load dependencies (amd64, llvm) / Finalize ✅ success view
Load dependencies (amd64, llvm) / Metadata ✅ success view
Load dependencies (arm64, llvm) / Caching ✅ success view
Load dependencies (arm64, llvm) / Finalize ✅ success view
Load dependencies (arm64, llvm) / Metadata ✅ success view
Load source build cache ⏩ skipped view
Load wheel dependencies ⏩ skipped view
Prepare cache clean-up ❔ in_progress view
Retrieve PR info ✅ success view
Validate CUDA 12 Python wheels ⏩ skipped view
✅ Required checks (4/4) — declared in .github/required-checks.yml for merge_group_fast
Required check Status Link
Build and test (amd64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (amd64, llvm, openmpi) / Dev environment (Python) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Python) ✅ success view

Merged via the queue into NVIDIA:main with commit 3a1dcc2 Oct 30, 2026
87 checks passed
@khalatepradnya
khalatepradnya deleted the fix/drop-bare-result-records branch October 30, 2026 00:15
github-actions Bot pushed a commit that referenced this pull request Oct 30, 2026
anpaz pushed a commit to justinlietz/cuda-quantum that referenced this pull request Oct 30, 2026
…IR output logs (NVIDIA#5768)

### Summary

- Removes the `RecordLogParser` path that accepted `RESULT` records
without an enclosing `ARRAY` record. Such a record is now an error, and
the parser no longer reads `METADATA` values.
- Indexes each `RESULT` record by its position in its array, which fixes
those kernels.

### Motivation

- NVIDIA#3553 added `qir-insert-array-record`, which declares an `array<i1 x
N>` before the result records of every sampled entry point. It kept the
bare-`RESULT` path as a temporary workaround "until all backends
consistently use the new transformation pass".
- That condition holds now:
- Both QIR lowering pipelines schedule the pass
(`addConvertToQIRAPIPipeline` and `addWiresetToProfileQIRPipeline`).
- The pass counts every `result_record_output` call in the entry point,
user-specified measurements included. It skips only `run` entry points,
whose logs carry typed return-value records.
- `quantinuum` is the only target that enables `output_log`, and
`QuantinuumServerHelper` is the only caller of
`createSampleResultFromQirOutput`.
- Indices from labels:
- The parser read a result's index from its label: `r00003` gave 3 and
`name%2` gave 2. But a label is a register name. `UpdateRegisterNames`
restarts the `%` suffix for each register, and the `r` counter counts
only unnamed results.
- Records arrive in the order the kernel measured them, which is the
order codegen numbers results in (`ConvertToQIRAPI.cpp`). A result's
index is its position in its array.
- NVIDIA#3530 added the label parsing for a log whose records arrived out of
order. No current producer reorders them (`qci` was removed)
- Sub-registers: This path returns only the global register, as before.
Sub-registers in `sample_result` are deprecated, as the runtime warns.

---------

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

runtime CUDA quantum runtime testing Relates to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants