Skip to content

✨ Support array-valued OpenQASM outputs #2592

Description

@simon1hofmann

🤖 AI text below 🤖

Problem Statement

The classical-array work in #2109 supports internal storage, but array-valued
OpenQASM outputs remain unsupported. Users must currently copy selected elements
into scalar outputs. An output array must retain its shape, element type, and
values after the entry function returns; returning the current stack-backed
memref.alloca storage would leave a dangling reference.

This gap was deliberately deferred until after #2546, which changes computed
output handling and recording.

Proposed Solution

Support array-valued output declarations using a defined value or ownership
contract shared by the frontend and its consumers.

  • Define the lifetime and ownership of returned arrays, including empty and
    multidimensional arrays, without exposing expired stack storage.
  • Preserve output shape, element type, order, and integer/angle representation
    through QC/QCO conversion and supported serialization paths.
  • Extend native result handling and QIR output recording consistently with the
    computed-output contract established by ✨ Preserve structured compilation and execution #2546. Diagnose output element types
    or target profiles that cannot be represented.
  • Test mutable arrays, aliased views, output snapshots, empty dimensions,
    repeated calls, and rejection of uninitialized output elements.

Acceptance: a program can return a fully initialized array and retrieve the
same typed, shaped values through each supported execution/export path, without
dangling storage, silent truncation, or changed scalar-output behavior.

Follow-up to #2109; depends on #2546. Classical subroutines and array-reference
parameters are separate work, not prerequisites for standalone array outputs.

Activity

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

Metadata

Metadata

Assignees

Labels

MLIRAnything related to MLIROpenQASMAnything related to OpenQASMfeatureNew feature or request

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions