amazon-braket / amazon-braket/qirtoqasm

Lower QIR subroutine (non-intrinsic) calls beyond the entry point

Open
#19 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
2
Forks
1
Avg merge
3d 21h
Merged PRs (30d)
5

Description

**Describe the feature you'd like**
Currently the translator structurally lowers only the entry-point function. Calls to user-defined subroutines that aren't QIS intrinsics either error out as unsupported or rely on the producer to have inlined them. Lower QIR subroutine bodies into OpenQASM 3 subroutine constructs — `def` for routines mixing classical and quantum operands, `gate` for purely-quantum helpers — and emit calls to them at the original call sites.

**How would this feature be used? Please describe.**
Producers that emit modular QIR (multiple `define`s with calls between them, rather than a single inlined entry point) currently force users to manually flatten their QIR before handing it to qirtoqasm. A direct translation path would remove that step and produce OpenQASM 3 output that mirrors the input's modular structure.

**Describe alternatives you've considered**
Inlining at the producer side is the current workaround and works for many cases, but it inflates QIR size and makes debugging harder.

**Additional context**
Scope needs to be defined carefully. Pure-quantum subroutines map naturally to `gate`; mixed subroutines map to `def`. Subroutine return values today are captured at the call site as a single SSA id; full lowering would need to model their structure (single value vs. struct, scalar vs. array, etc.) so the emitted signature matches the call sites.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.