RFC: Qubit Lifetime & Deallocation Semantics in QC/QCO #1585
Replies: 4 comments 3 replies
-
|
One observation from working on the QC-to-QIR conversion: QIR 2.1 now supports dynamic and static allocations. However, the spec reads to me as if dynamic and static allocations should not be mixed. When |
Beta Was this translation helpful? Give feedback.
-
|
To pick up on the thought from above: If we do not allow programs that mix static and dynamic qubits, then we also do not need to treat deallocs implicitly in QC.
|
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the RFC, sounds pretty good to me. Just some minor notes on the text itself:
|
Beta Was this translation helpful? Give feedback.
-
|
This has now been implemented in #1569 🎉 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Based on comments and discussion in #1569:
🧩 Problem Statement
We need a consistent and implementable model for:
Key challenge:
🎯 Goals
❌ Non-Goals
🔍 Observations from Existing Frameworks
Conclusion:
💡 Proposal
1. Unified Deallocation in QCO
Every qubit (static or dynamic) must be explicitly consumed
Introduce:
(or keep
qco.dealloc)Semantics:
2. QC lifetime model (static vs dynamic mode)
Lowering rules:
3. Linear Ownership Model
yield)4. Restrictions on Aggregates (Critical)
To ensure correctness, the following are invalid IR:
❌ Mixed ownership in aggregates
5. Valid Patterns
✅ Structured control flow
✅ Uniform aggregates
⚖️ Alternatives Considered
A. Always deallocate everything without restrictions
B. Reference counting / GC
C. Separate static/dynamic types
🧠 Rationale
The proposed design:
🚧 Open Questions
deallocvssink✅ Decision
Adopt:
📌 Consequences
Pros
Cons
🔮 Future Work
Beta Was this translation helpful? Give feedback.
All reactions