-
-
Notifications
You must be signed in to change notification settings - Fork 59
✨ Add qtensor dialect to MLIR
#1542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
117 commits
Select commit
Hold shift + click to select a range
7e25940
add base qtensor implementation
8f65b5a
add additional operations
affb356
adjust build functions
c7dc6a5
add builders in QCO
efa7aff
add canonicalization for extract
3c3901e
add additional canonicalization
fd009b6
add tests for qtensor
8cefca0
copy tensor insertslice
78bf30b
add additional tests
596636c
add docstrings in QCOProgramBuilder
bb093a2
adjust builder functions in QCOProgramBuilder
b705471
add general canonicalization
4b310cd
fix wrong operation in folExtractAfterInsertSlice
b8cf644
adjust structure of qtensor dialect
34af394
adjust headers
85906f8
refactor dialect structure
bdd1753
fix issues in copied code
bd06b9d
smaller fixes
f905111
Merge remote-tracking branch 'upstream/main' into qtensor
5eea7b9
remove memref interface for now
9817a9b
remove duplicated code
a4c9713
add allocTensorOp
1f767de
fix some headers
0523a00
Merge remote-tracking branch 'upstream/main' into qtensor
6f2a2a5
add allocDeallocPair canonicalization
b1f18e6
fix linter issues
9dacf34
remove unused code
c30daaa
🎨 pre-commit fixes
pre-commit-ci[bot] 511cfc0
more linter issue fixes
03bc636
update slice operations to newer version
a47cee6
update descriptions and docs to fit project style
6f8dcb6
remove useless functions
0750cc8
add fromTensor test
5865cc2
fix linter issue
092024c
smaller fixes
496425a
add source of copied parts
aca212d
adjust tablegen file
aa91580
add additional test for dynamic indices
edd2151
remove redundant dialect includes
8147bb1
address code rabbit suggestions
509205d
fix linter issues
45a457a
address more coderabbit suggestions
b9824b2
fix typo
892443a
rename test name
16541bb
separate tensor and qubit tracking
98befe5
Merge remote-tracking branch 'upstream/main' into qtensor
4c15542
fix linter issues
cdc77e8
address more coderabbit feedback
8473d1d
more coderabbit suggestions
5109e32
more coderabbit feedback
b2766ed
address review feedback
a108608
correct error message
c91e17d
use newer style of operation creation
840a0fb
add missing word
74ac8b7
fix name in CMakeLists
c6593d6
more coderabbit fixes
76459db
more coderabbit fixes
1d78b38
make strides optional and set default values
8cb17d9
remove conversion to tensor operations for insertOp and fromElementsOp
6c0885a
Merge remote-tracking branch 'upstream/main' into qtensor
df1f5d8
address coderabbit suggestions
7cc00fa
remove redundant tests
38d8d37
Apply suggestions from code review
li-mingbao 7cf19f3
🎨 pre-commit fixes
pre-commit-ci[bot] b27e5d9
simplify implementation by only allowing dynamic size and offset
a1f86ad
adjust extractSlice and insertSlice operations
c248490
rename class names
8133739
refactor implementation
caa7784
rename builder function names
368b69c
add sameIndex function to check for identical index values
8e869d3
remove more redundant code
910a076
minor fixes
9a727a8
rearrange verifiers and add docstrings
7546009
clean up headers
4656a86
apply changes to tests
61eb098
rearrange tablegen file
3c4f5db
removed unused interface
97b8b1b
reorder results of extract and extractSliceOp
a19cc25
Merge remote-tracking branch 'upstream/main' into qtensor
9135e7a
remove redundant builder
21c8860
fix linter issues
ba96c3b
fix extractInsert fold
fdadc42
add additional tests and rename tests
aa532e8
fix linter issues
db886ad
clean up code a bit
a405300
Merge remote-tracking branch 'upstream/main' into qtensor
3d8d1c7
fix linter issues
fc615a4
address coderabbit comments
6195f23
address more coderabbit comments
a343e0f
fix typo
0c05031
Apply suggestions from code review
li-mingbao ff9f278
simplify code and use 1D tensor as type
bb6d65c
add qubit type constraint in tablegen to simplify verifiers
0027839
remove redundant headers
01bddad
Update CHANGELOG.md
7f41930
fix linter issues
0261825
apply coderabbit suggestions
60bb305
apply coderabbit feedback
b034a3b
fix linter issue
c05500a
Merge remote-tracking branch 'upstream/main' into qtensor
1937a75
fix grammar mistakes
d265531
Apply suggestions from code review
li-mingbao 46d06a8
update the descriptions
6cc90e6
apply code review suggestions and simplify code
a8cbaf6
remove dead code
4799bb8
remove redundant helper function
d7bc3e2
add dynamic sizes for allocOp
7414ebd
apply coderabbit feedback
2a5a25c
address coderabbit comments and linter issues
2afb9e6
add back accidently removed functioN
b31cf8d
add additional tests at different indices and offsets
d16d34d
Merge branch 'main' into qtensor
denialhaag 45ca236
Merge branch 'main' into qtensor
denialhaag 2e7195b
Address the Rabbit's comments
denialhaag 83c936a
Move dialect definition to separate TableGen file
denialhaag 755a2ce
Fix generation of QTensorDialect.md
denialhaag 86d631b
Address the Rabbit's new comments
denialhaag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| tocdepth: 3 | ||
| --- | ||
|
|
||
| ```{include} Dialects/QTensorDialect.md | ||
| :heading-offset: 1 | ||
| ``` |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,4 @@ | |
|
|
||
| add_subdirectory(QC) | ||
| add_subdirectory(QCO) | ||
| add_subdirectory(QTensor) | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Copyright (c) 2023 - 2026 Chair for Design Automation, TUM | ||
| # Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # Licensed under the MIT License | ||
|
|
||
| add_subdirectory(IR) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Copyright (c) 2023 - 2026 Chair for Design Automation, TUM | ||
| # Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # Licensed under the MIT License | ||
|
|
||
| add_mlir_dialect(QTensorOps qtensor) | ||
|
|
||
| add_mlir_doc(QTensorOps QTensorDialect Dialects/ -gen-dialect-doc -dialect=qtensor) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * Copyright (c) 2023 - 2026 Chair for Design Automation, TUM | ||
| * Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH | ||
| * All rights reserved. | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| * | ||
| * Licensed under the MIT License | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <mlir/IR/Dialect.h> | ||
| #include <mlir/IR/OpDefinition.h> | ||
|
|
||
| #define DIALECT_NAME_QTensor "qtensor" | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // QTensor Dialect | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "mlir/Dialect/QTensor/IR/QTensorOpsDialect.h.inc" // IWYU pragma: export | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Types | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #define GET_TYPEDEF_CLASSES | ||
| #include "mlir/Dialect/QTensor/IR/QTensorOpsTypes.h.inc" // IWYU pragma: export |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // Copyright (c) 2023 - 2026 Chair for Design Automation, TUM | ||
| // Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH | ||
| // All rights reserved. | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
| // | ||
| // Licensed under the MIT License | ||
|
|
||
| #ifndef MLIR_DIALECT_QTENSOR_IR_QTENSORDIALECT_TD | ||
| #define MLIR_DIALECT_QTENSOR_IR_QTENSORDIALECT_TD | ||
|
|
||
| include "mlir/IR/DialectBase.td" | ||
|
|
||
| def QTensorDialect : Dialect { | ||
| let name = "qtensor"; | ||
|
|
||
| let summary = "The QTensor dialect for one-dimensional tensors of qubits with linear typing."; | ||
|
|
||
| let description = [{ | ||
| The QTensor dialect is an adjusted variant of the standard tensor dialect of MLIR that supports linear typing for one-dimensional tensors of qubits. | ||
| In order to support linear typing, the extract operations of this dialect are modified so that they also return the updated tensor. | ||
| In addition, alloc/dealloc operations are added to the dialect to support the bulk allocation and deallocation of qubit tensors with linear types. | ||
| }]; | ||
|
|
||
| let dependentDialects = ["::mlir::qco::QCODialect"]; | ||
|
|
||
| let cppNamespace = "::mlir::qtensor"; | ||
| } | ||
|
|
||
| #endif // MLIR_DIALECT_QTENSOR_IR_QTENSORDIALECT_TD |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * Copyright (c) 2023 - 2026 Chair for Design Automation, TUM | ||
| * Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH | ||
| * All rights reserved. | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| * | ||
| * Licensed under the MIT License | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| // Suppress warnings about ambiguous reversed operators in MLIR | ||
| // (see https://github.com/llvm/llvm-project/issues/45853) | ||
| #include <mlir/IR/OpDefinition.h> | ||
| #ifdef __clang__ | ||
| #pragma clang diagnostic push | ||
| #pragma clang diagnostic ignored "-Wambiguous-reversed-operator" | ||
| #endif | ||
| #include <mlir/Interfaces/InferTypeOpInterface.h> | ||
| #ifdef __clang__ | ||
| #pragma clang diagnostic pop | ||
| #endif | ||
|
|
||
| #include "mlir/Dialect/QCO/IR/QCODialect.h" | ||
| #include "mlir/Dialect/QTensor/IR/QTensorDialect.h" | ||
|
|
||
| #include <mlir/Bytecode/BytecodeOpInterface.h> | ||
| #include <mlir/Interfaces/SideEffectInterfaces.h> | ||
|
|
||
| #define GET_OP_CLASSES | ||
| #include "mlir/Dialect/QTensor/IR/QTensorOps.h.inc" // IWYU pragma: export |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.