Skip to content

✨ Add non-bit record output functions to the QIR runtime#1799

Open
rturrado wants to merge 1 commit into
munich-quantum-toolkit:mainfrom
rturrado:1797
Open

✨ Add non-bit record output functions to the QIR runtime#1799
rturrado wants to merge 1 commit into
munich-quantum-toolkit:mainfrom
rturrado:1797

Conversation

@rturrado

Copy link
Copy Markdown
Contributor

Description

This PR completes the runtime side of QIR Adaptive Profile support. PR #1766 already added the format routing for QIRADAPTIVE{MODULE,STRING} and the bit-recording infrastructure. This follow-up fills the remaining gap: the five spec-defined __quantum__rt__*_record_output entry points for non-bit values (bool, int, float, tuple, array). Without them, any Adaptive program emitting classical compute outputs alongside measurement results would fail to link at JIT time.

The new entry points emit in MQT Core's current custom label: value format. Switching to the spec-mandated HEADER / START / END output schemas (Labeled / Ordered) is tracked separately as a follow-up issue.

Fixes #1797

- QIR.h, QIR.cpp: implement the five spec-defined `__quantum__rt__{bool,int,float,tuple,array}_record_output` functions used by QIR Adaptive Profile programs to emit classical compute outputs alongside measurement results.
- Runtime.hpp, Runtime.cpp: add `outputValue` and `outputContainer` helpers.
  Rename the per-shot bit accumulator (`recordOutput` to `appendMeasurementBit`, `recordedOutputs` to `measurements`, `getRecordedOutputs` to `getMeasurements`) so its name reflects its role in histogram bucketing rather than implying any tie to QIR's `record_output` verb.
- Session.cpp: register the new symbols so JIT-compiled Adaptive programs resolve them.
- AdaptiveRecordOutputs.ll plus runtime- and QDMI-level tests exercising every new function in one circuit.

Assisted-by: Claude Opus 4.7 via Claude Code
@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/qir/runtime/Runtime.cpp 88.8% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@burgholzer burgholzer added enhancement Improvement of existing feature c++ Anything related to C++ code QIR Anything related to QIR labels Jun 21, 2026
@burgholzer burgholzer added this to the QIR Support milestone Jun 21, 2026
@burgholzer

Copy link
Copy Markdown
Member

Hey @rturrado 👋🏻
This looks pretty good already! Is this ready for a review?

@rturrado

Copy link
Copy Markdown
Contributor Author

Hey @rturrado 👋🏻
This looks pretty good already! Is this ready for a review?

@burgholzer Hello! Yes, it is. And if you consider that the issue description needs refining and that that can affect the subsequent PR, no problem with that also.

@burgholzer

Copy link
Copy Markdown
Member

Hey @rturrado 👋🏻
This looks pretty good already! Is this ready for a review?

@burgholzer Hello! Yes, it is. And if you consider that the issue description needs refining and that that can affect the subsequent PR, no problem with that also.

Nice! The issue descriptions read just fine as they are 🙂👍🏻
I'll try to get a review in here in the coming days.

@rturrado

Copy link
Copy Markdown
Contributor Author

Nice! The issue descriptions read just fine as they are 🙂👍🏻
I'll try to get a review in here in the coming days.

Thanks so much. No rush at all!

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

Labels

c++ Anything related to C++ code enhancement Improvement of existing feature QIR Anything related to QIR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Add QIR Adaptive Profile non-bit output recording to the QIR runtime

2 participants