Add the qecl.fabricate op#2865
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2865 +/- ##
==========================================
- Coverage 97.01% 97.01% -0.01%
==========================================
Files 167 167
Lines 18753 18807 +54
Branches 1762 1768 +6
==========================================
+ Hits 18193 18245 +52
- Misses 415 417 +2
Partials 145 145 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
lillian542
approved these changes
May 22, 2026
Contributor
lillian542
left a comment
There was a problem hiding this comment.
LGTM, thanks @joeycarter!
Co-authored-by: lillian542 <38584660+lillian542@users.noreply.github.com>
paul0403
approved these changes
May 25, 2026
joeycarter
added a commit
that referenced
this pull request
May 25, 2026
**Context:** In order to support T gates and π/8 PPMs in the experimental QEC pipeline, in #2865 we added support to represent the fabrication of magic states in the QEC logical layer. Now, we need the ability to also deallocate single logical codeblocks. **Description of the Change:** This PR adds the `qecl.dealloc_cb` op, which deallocates a single logical codeblock. This operation is available in both MLIR and in the xDSL interface to Catalyst. This operation is generally used in conjunction with the `qecl.fabricate` op. For example, ```mlir %0 = qecl.fabricate [magic] : !qecl.codeblock<1> // %1 = operations on the magic state... qecl.dealloc_cb %1 : !qecl.codeblock<1> ``` In principle, it is also possible to deallocate a single logical codeblock extracted from a hyper-register, e.g. ```mlir %0 = qecl.alloc() : !qecl.hyperreg<3 x 1> %1 = qecl.extract %0[0] : !qecl.hyperreg<3 x 1> -> !qecl.codeblock<1> qecl.dealloc_cb %1 : !qecl.codeblock<1> ``` However, IR patterns like this should be used with caution for now since they require careful consideration in the `qecp` layer below and in the runtime (for instance, similar patterns of single-qubit deallocation in the `quantum` dialect generally require the use of array-backed registers to allow for execution of the compiled workload). [sc-119924]
joeycarter
added a commit
that referenced
this pull request
May 26, 2026
**Context:** In order to support T gates and π/8 PPMs in the experimental QEC pipeline, in #2865 and #2866, we added support to represent the fabrication of magic states in the QEC logical layer and to deallocate single logical codeblocks. Now, we need the ability to also deallocate single _physical_ codeblocks in the `qecp` layer. **Description of the Change:** This PR adds the `qecp.alloc_cb` and `qecp.dealloc_cb` ops, which allocate and deallocate a single physical codeblock, respectively. This operation is available in both MLIR and in the xDSL interface to Catalyst. For example: ```mlir %0 = qecp.alloc_cb : !qecp.codeblock<1 x 7> // %1 = operations on the physical codeblock... qecp.dealloc_cb %1 : !qecp.codeblock<1 x 7> ``` [sc-119925]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context: In order to support T gates and π/8 PPMs in the experimental QEC pipeline, we require an operation to represent the fabrication of magic states in the QEC logical layer.
Description of the Change: Mirroring the
pbc.fabricateop, this PR adds theqecl.fabricateop, which fabricates a logical codeblock in a specified initial state (typically a magic state). This operation is available in both MLIR and in the xDSL interface to Catalyst.For example, the following operation represents the fabrication of a logical codeblock in the magic state (where the codeblock encodes k = 1 logical qubits):
The
LogicalCodeblockInitStateenum attribute has been updated to include the "magic" option for the fabrication of magic states. Theqecl.fabricateop also includes a verifier that raises an error when attempting to fabricate a logical codeblock in the logical 'zero' state (instead, theqecl.encodeop should be used). Similarly, a verifier has been added to theqecl.encodeop that raises an error when attempting to encode an already-allocated codeblock in the magic state.[sc-119923]