feat: support dynamic allocation and arrays#48
Conversation
74e0b5b to
dc39cde
Compare
There was a problem hiding this comment.
Pull request overview
Adds Adaptive Profile support for capability-gated dynamic qubit/result allocation and fixed-size pointer arrays, including validation + lowering paths, with new/updated snapshot fixtures and documentation updates.
Changes:
- Add capability-flag parsing/validation and gate dynamic RT API acceptance on module flags.
- Lower dynamic qubit/result allocation/release and result-array output recording (compiler-managed result slots).
- Expand fixtures/snapshots and align linting across pre-commit and CI.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib.rs | Implements capability-flag parsing, capability-gated validation, and new lowering paths for dynamic allocation/arrays. |
| src/convert.rs | Updates native-call lowering to support dynamic qubit handles and propagates capability context into IR-defined lowering. |
| qtm-qir-reference.md | Documents supported capability flags, accepted RT APIs, and the fixed-size pointer-array support boundary. |
| .pre-commit-config.yaml | Aligns clippy invocation/strictness for local lint runs. |
| .github/workflows/CI.yml | Switches CI lint job to run the same prek-based checks as local linting. |
| tests/data/dynamic_qubit_alloc.ll | New input fixture covering dynamic qubit allocate/release. |
| tests/data/dynamic_qubit_array_ssa.ll | New input fixture covering dynamic qubit arrays with SSA swapping patterns. |
| tests/data/dynamic_result_alloc.ll | New input fixture covering dynamic result allocate/release + output. |
| tests/data/dynamic_result_array.ll | New input fixture covering result arrays (allocate/record/release). |
| tests/data/dynamic_result_mixed_array_output.ll | New input fixture covering mixed result allocation + array output flows. |
| tests/snaps/dynamic_qubit_alloc.ll.snap | New snapshot for dynamic qubit allocation lowering output. |
| tests/snaps/dynamic_qubit_array_ssa.ll.snap | New snapshot for dynamic qubit array SSA lowering output. |
| tests/snaps/dynamic_result_alloc.ll.snap | New snapshot for dynamic result allocation lowering output. |
| tests/snaps/dynamic_result_array.ll.snap | New snapshot for dynamic result array output/lowering output. |
| tests/snaps/dynamic_result_mixed_array_output.ll.snap | New snapshot for mixed dynamic result + array output lowering output. |
| tests/snaps/barrier.ll.snap | Updates snapshot expectations after internal lowering/refactor changes. |
| tests/snaps/barrier_multi.ll.snap | Updates snapshot expectations after internal lowering/refactor changes. |
| tests/snaps/adaptive.ll.snap | Updates snapshot expectations after internal lowering/refactor changes. |
| tests/snaps/adaptive_ir_fns.ll.snap | Updates snapshot expectations after internal lowering/refactor changes. |
| tests/snaps/adaptive_iter.ll.snap | Updates snapshot expectations after internal lowering/refactor changes. |
| tests/snaps/adaptive_iter_fn.ll.snap | Updates snapshot expectations after internal lowering/refactor changes. |
| tests/snaps/adaptive_cond_loop.ll.snap | Updates snapshot expectations after internal lowering/refactor changes. |
| tests/snaps/ArithOps_switch.ll.snap | Updates snapshot expectations after internal lowering/refactor changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dc39cde to
104f727
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b544aad to
1d86541
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 27 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 27 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e88e37d to
391722c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 25 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/convert.rs:1194
- Allowing internal calls like
___qalloc/panic/print_*in any IR-defined function whose name starts withqir_qis.creates a namespace-injection risk: an input module can defineqir_qis.*functions to make these internal calls appear “expected”, and (combined with helper-creation routines that reuse existingqir_qis.*functions) can change compiler behavior. It would be safer to reject/rename any user-suppliedqir_qis.*definitions during validation, or to gate this exception on stronger properties (e.g., exact helper names + private linkage + expected signature).
"___qalloc"
| "___qfree"
| "___reset"
| "panic"
| "___read_future_bool"
| "___dec_future_refcount"
| "print_int"
| "print_bool" => {
let defined_name = defined_fn.get_name().to_str().ok();
if defined_name != Some(INIT_QARRAY_FN)
&& !defined_name.is_some_and(|name| name.starts_with("qir_qis."))
{
log::error!(
"Unexpected call to internal function: {fn_name} in function {}",
defined_fn.get_name().to_str().unwrap_or("unknown")
);
return Err(format!("Unexpected call to internal function: {fn_name}"));
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7daa2f6 to
c9cc10c
Compare
dd7de21 to
f51d951
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 32 out of 34 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
628e4b6 to
34b9593
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 30 out of 32 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 30 out of 32 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment was marked as resolved.
This comment was marked as resolved.
5147250 to
bc0f3d2
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 30 out of 32 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
e959ec1 to
b05cbdd
Compare
b05cbdd to
792ee59
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 30 out of 32 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Fixes #46 by adding Adaptive Profile support for
dynamic_qubit_management,dynamic_result_management, and fixed-size pointer arrays, and by hardening the Selene smoke coverage needed to exercise the new path on CI.Included
allocate/releaseand arrayallocate/releaseallocate/release, arrayallocate/release, andrecord_outputusing compiler-managed result slotsalloca,load,store,getelementptr,extractvalue,insertvalue, compatiblebitcast-backed storage, and zero-indexgetelementptrviews of fixed[N x ptr]backing arraysRESULT_ARRAYrecords throughprint_bool_arr(...)result_array_record_outputlengths that do not fit the current downstreami32array ABIqtm-qir-reference.mdto document the supported surfacemain.pyregression coverage for the new dynamic allocation and array behaviorsCI
tests/test_main.pysmoke coverage to the workflowselene-sim0.2.15 from the package index for the Selene smoke environmentValidation
make lintmake test