Skip to content

Add the qecl.fabricate op#2865

Merged
joeycarter merged 5 commits into
mainfrom
joeycarter/qecl-fabricate
May 25, 2026
Merged

Add the qecl.fabricate op#2865
joeycarter merged 5 commits into
mainfrom
joeycarter/qecl-fabricate

Conversation

@joeycarter
Copy link
Copy Markdown
Contributor

@joeycarter joeycarter commented May 21, 2026

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.fabricate op, this PR adds the qecl.fabricate op, 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):

%0 = qecl.fabricate [magic] : !qecl.codeblock<1>

The LogicalCodeblockInitState enum attribute has been updated to include the "magic" option for the fabrication of magic states. The qecl.fabricate op also includes a verifier that raises an error when attempting to fabricate a logical codeblock in the logical 'zero' state (instead, the qecl.encode op should be used). Similarly, a verifier has been added to the qecl.encode op that raises an error when attempting to encode an already-allocated codeblock in the magic state.

[sc-119923]

@joeycarter joeycarter marked this pull request as ready for review May 21, 2026 21:06
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.01%. Comparing base (ee16e92) to head (725b7b2).
⚠️ Report is 5 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@lillian542 lillian542 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @joeycarter!

Comment thread doc/releases/changelog-dev.md Outdated
joeycarter and others added 2 commits May 25, 2026 09:51
Co-authored-by: lillian542 <38584660+lillian542@users.noreply.github.com>
@joeycarter joeycarter merged commit f1054e9 into main May 25, 2026
39 checks passed
@joeycarter joeycarter deleted the joeycarter/qecl-fabricate branch May 25, 2026 17:35
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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants