Skip to content

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

Open
rturrado wants to merge 5 commits into
munich-quantum-toolkit:mainfrom
rturrado:1797
Open

✨ Add non-bit record output functions to the QIR runtime#1799
rturrado wants to merge 5 commits 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

@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
src/qir/runtime/Runtime.cpp 87.5% 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!

@denialhaag denialhaag self-requested a review June 25, 2026 22:00

@denialhaag denialhaag left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks a lot for your contribution, @rturrado! 🙂

This looks really good to me! I only left a few minor comments, which you can find below.

Comment thread include/mqt-core/qir/runtime/QIR.h Outdated
Comment thread include/mqt-core/qir/runtime/QIR.h Outdated
Comment thread src/qir/runtime/QIR.cpp
Comment thread test/qdmi/devices/dd/results_sampling_test.cpp Outdated
@rturrado rturrado requested a review from denialhaag June 26, 2026 16:04

@denialhaag denialhaag left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This LGTM now! I'll leave the final approval to @burgholzer. 🙂

@denialhaag denialhaag requested a review from burgholzer June 26, 2026 22:57

@burgholzer burgholzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is looking great! Thanks for another nice contribution @rturrado 🙌
I have a couple of nitpick comments and maybe some stupid questions. Then this can go in 🚀

Comment thread src/qir/runtime/QIR.cpp
Comment thread src/qir/runtime/Runtime.cpp
Comment thread src/qir/runtime/Runtime.cpp
Comment thread src/qir/runtime/Runtime.cpp
Comment thread src/qir/runtime/Runtime.cpp
Comment thread test/circuits/AdaptiveRecordOutputs.ll Outdated
rturrado and others added 5 commits June 27, 2026 14:23
- 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
Signed-off-by: rturrado <rturrado@gmail.com>
Co-authored-by: Daniel Haag <121057143+denialhaag@users.noreply.github.com>
Signed-off-by: Roberto Turrado Camblor <rturrado@gmail.com>
Signed-off-by: rturrado <rturrado@gmail.com>
Assisted-by: Claude Opus 4.7 via Claude Code
Signed-off-by: rturrado <rturrado@gmail.com>
Matches QIR record_output (value, label) so call sites no longer flip args.

Assisted-by: Claude Opus 4.7 via Claude Code
Signed-off-by: rturrado <rturrado@gmail.com>
- QIR.cpp:
  add precision rationale for std::ostringstream in float record output.
  Drop unused <iostream> include.
- Runtime.cpp:
  remove redundant measurements.clear().
- test circuits:
  bump QIR version to 2.1.

Assisted-by: Claude Opus 4.7 via Claude Code
Signed-off-by: rturrado <rturrado@gmail.com>
@rturrado

Copy link
Copy Markdown
Contributor Author

Force-pushed to add DCO sign-off to previously unsigned commits. No code change.

@rturrado

Copy link
Copy Markdown
Contributor Author

This is looking great! Thanks for another nice contribution @rturrado 🙌 I have a couple of nitpick comments and maybe some stupid questions. Then this can go in 🚀

@burgholzer Many thanks! Very much OK with nitpicking. And no stupid questions 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

3 participants