Skip to content

✨ Add QIR Output Schemas support to the QIR runtime #1798

@rturrado

Description

@rturrado

Problem Statement

The QIR runtime currently emits output records in a custom label: value format that does not conform to the QIR specification. The spec defines two output schemas (Labeled and Ordered) that wrap each shot's output in HEADER / START / END framing and emit each record as a tab-separated OUTPUT\t<TYPE>\t<value>\t<label> line.
Without spec-conformant output, MQT Core's QIR runtime cannot interoperate with downstream tools that consume QIR output records.

QIR output schemas spec: https://github.com/qir-alliance/qir-spec/tree/main/specification/output_schemas

Depends on: #1797

Proposed Solution

  1. Spec-mandated framing.
    The Runtime emits a HEADER line before the shot loop and brackets each shot with START / END markers.
  2. Labeling schema selection driven by the QIR program.
    The JIT session reads the output_labeling_schema function attribute from the QIR module and configures the Runtime accordingly. The HEADER block also emits a METADATA\toutput_labeling_schema\t<schema> line so the schema is self-describing in the output. No external toggle is exposed; the program declares its preferred schema.

Note

The output_labeling_schema function attribute is optional. When a program does not declare it, the Runtime defaults to Labeled.

  1. QIR's per-type record API.
    The __quantum__rt__*_record_output functions delegate to the Runtime's per-type record methods, so JIT-compiled QIR programs emit in spec format with no source change.
  2. Runtime's per-type record API.
    The Runtime exposes a per-type record method for each QIR output type (recordResult, recordBool, recordInt, recordFloat, recordTuple, recordArray).
    Each emits the spec-defined OUTPUT\t<TYPE>\t<value>\t<label> line.
  3. Consumer wiring (Runner and DDSIM QDMI Device).
    Both the mqt-core-qir-runner CLI and the DDSIM QDMI Device emit the program header once before running, and bracket each shot with start/end framing.
  4. Tests for both schemas.
    Cover the framing shape, per-type line shape, the METADATA line, and the Labeled vs. Ordered branch driven by the function attribute.

Metadata

Metadata

Assignees

Labels

QIRAnything related to QIRc++Anything related to C++ codeenhancementImprovement of existing feature
No fields configured for Feature.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions