Skip to content

✨ Integrate registers#1580

Draft
denialhaag wants to merge 7 commits intomainfrom
registers
Draft

✨ Integrate registers#1580
denialhaag wants to merge 7 commits intomainfrom
registers

Conversation

@denialhaag
Copy link
Member

Description

After #1542 has added support for linear tensors, this PR integrates registers deeper into our infrastructure. Furthermore, it updates our QIR code to use the dynamic allocations introduced in qir-alliance/qir-spec#60.

Some known shortcomings at this point:

  • Vast majority of failing tests are due to the conversion between QCO and Jeff. The problem is that Jeff's QuregType does not have any information about the register size. I will create an issue and/or follow up on Slack.
  • The remaining (15 or so) failing tests either have an easy solution that I already have in mind, or I haven't looked at them yet. That said, I don't expect bigger issues at this point.
  • Existing docstrings are outdated or missing, especially for the conversion from QC to QIR where a lot had changed.
  • At the moment, the QIR code do not support static qubits. I will look into this once ✨ Improve Static Qubit Handling #1569 is merged.
  • There will probably be a good amount of linter issues.

Checklist

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

@denialhaag denialhaag self-assigned this Mar 24, 2026
@denialhaag denialhaag added enhancement Improvement of existing feature MLIR Anything related to MLIR labels Mar 24, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2026

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy (v22.1.3) reports: 13 concern(s)
  • mlir/lib/Conversion/QCOToQC/QCOToQC.cpp:68:25: warning: [misc-include-cleaner]

    no header providing "mlir::RankedTensorType" is directly included

       25 |     addConversion([ctx](RankedTensorType type) -> Type {
          |                         ^
  • mlir/lib/Conversion/QCOToQC/QCOToQC.cpp:71:16: warning: [misc-include-cleaner]

    no header providing "mlir::MemRefType" is directly included

       71 |         return MemRefType::get({ShapedType::kDynamic}, qc::QubitType::get(ctx));
          |                ^
  • mlir/lib/Conversion/QCToQCO/QCToQCO.cpp:167:21: warning: [misc-include-cleaner]

    no header providing "mlir::ShapedType" is directly included

       26 |     if (shape[0] == ShapedType::kDynamic) {
          |                     ^
  • mlir/lib/Conversion/QCToQIR/QCToQIR.cpp:236:21: warning: [misc-include-cleaner]

    no header providing "mlir::ShapedType" is directly included

       36 |     if (shape[0] == ShapedType::kDynamic) {
          |                     ^
  • mlir/lib/Conversion/QCToQIR/QCToQIR.cpp:433:28: warning: [misc-unused-parameters]

    parameter 'op' is unused

      433 |   matchAndRewrite(StaticOp op, OpAdaptor adaptor,
          |                            ^~
          |                             /*op*/
  • mlir/lib/Conversion/QCToQIR/QCToQIR.cpp:433:42: warning: [misc-unused-parameters]

    parameter 'adaptor' is unused

      433 |   matchAndRewrite(StaticOp op, OpAdaptor adaptor,
          |                                          ^~~~~~~
          |                                           /*adaptor*/
  • mlir/lib/Conversion/QCToQIR/QCToQIR.cpp:434:46: warning: [misc-unused-parameters]

    parameter 'rewriter' is unused

      434 |                   ConversionPatternRewriter& rewriter) const override {
          |                                              ^~~~~~~~
          |                                               /*rewriter*/
  • mlir/lib/Dialect/QC/Builder/QCProgramBuilder.cpp:99:57: warning: [misc-unused-parameters]

    parameter 'name' is unused

       99 |                                      const std::string& name) {
          |                                                         ^~~~
          |                                                          /*name*/
  • mlir/lib/Dialect/QCO/Builder/QCOProgramBuilder.cpp:105:58: warning: [misc-unused-parameters]

    parameter 'name' is unused

      105 |                                       const std::string& name) {
          |                                                          ^~~~
          |                                                           /*name*/
  • mlir/lib/Dialect/QIR/Builder/QIRProgramBuilder.cpp:103:26: warning: [readability-convert-member-functions-to-static]

    method 'staticQubit' can be made static

      103 | Value QIRProgramBuilder::staticQubit(const int64_t index) {
          |                          ^
  • mlir/lib/Dialect/QIR/Builder/QIRProgramBuilder.cpp:103:52: warning: [misc-unused-parameters]

    parameter 'index' is unused

      103 | Value QIRProgramBuilder::staticQubit(const int64_t index) {
          |                                                    ^~~~~
          |                                                     /*index*/
  • mlir/lib/Dialect/QTensor/IR/Operations/AllocOp.cpp:43:8: warning: [clang-analyzer-deadcode.DeadStores]

    Value stored to 'resultSize' during its initialization is never read

       43 |   auto resultSize = resultType.getShape()[0];
          |        ^~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/core/core/mlir/lib/Dialect/QTensor/IR/Operations/AllocOp.cpp:43:8: note: Value stored to 'resultSize' during its initialization is never read
       43 |   auto resultSize = resultType.getShape()[0];
          |        ^~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~
  • mlir/lib/Dialect/QTensor/IR/Operations/InsertOp.cpp:31:5: warning: [readability-else-after-return]

    do not use 'else' after 'return'

       31 |   } else if (llvm::isa<InsertOp>(definingOp)) {
          |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       32 |     auto nestedInsertOp = llvm::cast<InsertOp>(definingOp);
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       33 |     return findExtractOp(nestedInsertOp);
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       34 |   }
          |   ~

Have any feedback or feature suggestions? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvement of existing feature MLIR Anything related to MLIR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant