Skip to content

[iqm] Don't reject user-named measurement registers - #4985

Open
mitchdz wants to merge 2 commits into
mainfrom
fix-iqm-nondigit-measurement-key
Open

[iqm] Don't reject user-named measurement registers#4985
mitchdz wants to merge 2 commits into
mainfrom
fix-iqm-nondigit-measurement-key

Conversation

@mitchdz

@mitchdz mitchdz commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

PR #4818 added a numerical sort of the IQM measurement_keys to reorder result bitstrings into physical-qubit order, guarded by a check that every key ends in a digit. That assumption only holds for the auto-generated r00000, r00001, ... register names. A kernel that names its measurement register explicitly (e.g. auto result = mz(q)) produces a key such as result, which tripped the guard and threw "Malformed measurement key received: result", aborting the job.

The unit tests exercised only digit-suffixed keys via the mock server, so this passed CI at merge time but broke the nightly IQM integration test (targettests/iqm/callable_kernel_arg.cpp) every night since.

Non-numeric keys carry no positional information, so there is nothing to sort by. Skip the reordering in that case and leave the bitstrings in the order the measurements were emitted -- the behavior prior to #4818 -- rather than rejecting the response. Numeric keys keep the #4818 reordering.

Adds a regression test covering a non-numeric measurement key.

PR #4818 added a numerical sort of the IQM `measurement_keys` to reorder
result bitstrings into physical-qubit order, guarded by a check that every
key ends in a digit. That assumption only holds for the auto-generated
`r00000`, `r00001`, ... register names. A kernel that names its measurement
register explicitly (e.g. `auto result = mz(q)`) produces a key such as
`result`, which tripped the guard and threw "Malformed measurement key
received: result", aborting the job.

The unit tests exercised only digit-suffixed keys via the mock server, so
this passed CI at merge time but broke the nightly IQM integration test
(targettests/iqm/callable_kernel_arg.cpp) every night since.

Non-numeric keys carry no positional information, so there is nothing to
sort by. Skip the reordering in that case and leave the bitstrings in the
order the measurements were emitted -- the behavior prior to #4818 -- rather
than rejecting the response. Numeric keys keep the #4818 reordering.

Adds a regression test covering a non-numeric measurement key.

Signed-off-by: mdzurick <mitch_dz@hotmail.com>
@schweitzpgi
schweitzpgi requested a review from anpaz July 23, 2026 20:33

@schweitzpgi schweitzpgi 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.

Seems like a good change. Should this look for the "rXXXX" format to be a small step safer? Also, a malicious user could easily use "r00000" as a name to mess that up. What fun.

@sacpis

sacpis commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Adding @iqm-bhoffmann for viz.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

CI Summary (push) — ✅ passed

Run #30128116325 · ✅ 6 · ⏩ 7 · ❌ 0 · ⛔ 0

Top-level jobs (13)
Job Result
binaries ⏩ skipped
build_and_test ✅ success
config_devdeps ✅ success
config_source_build ⏩ skipped
config_wheeldeps ✅ success
devdeps ✅ success
docker_image ⏩ skipped
gen_code_coverage ⏩ skipped
metadata ✅ success
python_metapackages ⏩ skipped
python_wheels ⏩ skipped
source_build ⏩ skipped
wheeldeps ✅ success
⏩ Skipped jobs (7) — intentionally skipped on PR builds; run on merge_group / workflow_dispatch
Job
binaries
config_source_build
docker_image
gen_code_coverage
python_metapackages
python_wheels
source_build
All sub-jobs (42) — 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
Configure build (devdeps) ✅ success view
Configure build (source_build) ⏩ skipped view
Configure build (wheeldeps) ✅ success view
Create CUDA Quantum installer ⏩ skipped view
Create Docker images ⏩ skipped view
Create Python metapackages ⏩ skipped view
Create Python wheels ⏩ skipped 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
✅ Required checks (6/6) — 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

@github-actions github-actions Bot added the runtime CUDA quantum runtime label Jul 24, 2026
@iqm-bhoffmann

Copy link
Copy Markdown
Contributor

@sacpis thank you for adding me to the conversation.
I was not aware of this way to generate names (keys) for measurements. So my change assumed keys consisting of a fixed alphabetic prefix followed by a sortable numeric part. This helps to sort the results from our backend to resolve #4621 .

The proposed change will suppress the exception for the presented testcase but will most likely make #4621 re-appear with kernels which name the measurements. If I can confirm this I will re-open #4621 to do a more sophisticated solution than just sorting the keys. In the meantime the change can be merged but could have the described side effect.

@iqm-bhoffmann

Copy link
Copy Markdown
Contributor

Opened PR #5074 with my proposal to fix the problem. This solves also my concern from my last comment that multiple named measurements would still fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

runtime CUDA quantum runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants