Repository navigation
The decomposition solver uses a generalized Dijkstra's algorithm #3334
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 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
72bcac0
solver rework
kipawaa 10f9a21
cmake
kipawaa ad3c4e8
tests
kipawaa d3e5e27
E2E test for cycle handling
kipawaa 627c67e
error handling and tests for gateset weights
kipawaa 2088e98
Update mlir/unittests/DecompGraphSolver/Test_DecompGraphSolver.cpp
kipawaa fbfa4d9
fix solution caching behaviour
kipawaa 6ebd635
changelog
kipawaa d43cfc2
op references in queue and std::format
kipawaa 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
55 changes: 55 additions & 0 deletions
55
frontend/test/lit/GraphDecomposition/TestGatesetWeights.mlir
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,55 @@ | ||
| // Copyright 2026 Xanadu Quantum Technologies Inc. | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
|
|
||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| // see https://github.com/llvm/llvm-project/blob/cc6b3b5a1d0fba10d92be143cd52268c62f2a2a9/mlir/test/IR/parser.mlir#L1078 for examples of F64 special values | ||
|
|
||
| // Invalid weights must fail with a diagnostic rather than throwing from the solver. | ||
| // RUN: not catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set=TestGate=-1.0})' %s 2>&1 | FileCheck %s --check-prefix=NEGATIVE | ||
| // RUN: not catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set={TestGate=-1.0 : f64}})' %s 2>&1 | FileCheck %s --check-prefix=NEGATIVE-F64 | ||
| // RUN: not catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set=TestGate=-inf})' %s 2>&1 | FileCheck %s --check-prefix=NEGATIVE-INF | ||
| // this is the hex code for MLIR's negative infinity f64 | ||
| // RUN: not catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set={TestGate = 0xFFF0000000000000 : f64}})' %s 2>&1 | FileCheck %s --check-prefix=NEGATIVE-INF-F64 | ||
| // RUN: not catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set=TestGate=nan})' %s 2>&1 | FileCheck %s --check-prefix=NAN | ||
| // signalling NaNs | ||
| // RUN: not catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set={TestGate = 0x7FF0000000000001 : f64}})' %s 2>&1 | FileCheck %s --check-prefix=NAN-F64 | ||
| // RUN: not catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set={TestGate = 0x7FF8000000000000 : f64}})' %s 2>&1 | FileCheck %s --check-prefix=NAN-F64 | ||
| // quiet NaNs | ||
| // RUN: not catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set={TestGate = 0x7FF0000001000000 : f64}})' %s 2>&1 | FileCheck %s --check-prefix=NAN-F64 | ||
| // RUN: not catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set={TestGate = 0xFFF0000001000000 : f64}})' %s 2>&1 | FileCheck %s --check-prefix=NAN-F64 | ||
| // RUN: not catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set=TestGate=invalid})' %s 2>&1 | FileCheck %s --check-prefix=MALFORMED | ||
| // RUN: not catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set=TestGate=})' %s 2>&1 | FileCheck %s --check-prefix=MISSING | ||
| // NEGATIVE: error: Invalid cost '-1.0' for gate 'TestGate' in the target gateset: expected a non-negative number (not NaN). | ||
| // NEGATIVE-F64: error: Invalid cost '-1.0 : f64' for gate 'TestGate' in the target gateset: expected a non-negative number (not NaN). | ||
| // NEGATIVE-INF: error: Invalid cost '-inf' for gate 'TestGate' in the target gateset: expected a non-negative number (not NaN). | ||
| // NEGATIVE-INF-F64: error: Invalid cost '0xFFF0000000000000 : f64' for gate 'TestGate' in the target gateset: expected a non-negative number (not NaN). | ||
| // NAN: error: Invalid cost 'nan' for gate 'TestGate' in the target gateset: expected a non-negative number (not NaN). | ||
| // NAN-F64: error: Invalid cost '{{.+}} : f64' for gate 'TestGate' in the target gateset: expected a non-negative number (not NaN). | ||
| // MALFORMED: error: Invalid cost 'invalid' for gate 'TestGate' in the target gateset: expected a non-negative number (not NaN). | ||
| // MISSING: error: Invalid cost '' for gate 'TestGate' in the target gateset: expected a non-negative number (not NaN). | ||
|
|
||
| // Zero, fractional, and positive infinite weights are permitted, as strings or as float attrs | ||
| // RUN: catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set=TestGate=0.0})' %s | FileCheck %s | ||
| // RUN: catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set={TestGate=0.0 : f64}})' %s | FileCheck %s | ||
| // RUN: catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set=TestGate=0.5})' %s | FileCheck %s | ||
| // RUN: catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set={TestGate=0.5 : f64}})' %s | FileCheck %s | ||
| // RUN: catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set=TestGate=inf})' %s | FileCheck %s | ||
| // This is the hex code for MLIR's infinite f64 | ||
| // RUN: catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set={TestGate = 0x7FF0000000000000 : f64}})' %s | FileCheck %s | ||
|
|
||
| // CHECK-LABEL: func.func @circuit | ||
| // CHECK: quantum.custom "TestGate" | ||
| func.func @circuit(%q: !quantum.bit) -> !quantum.bit { | ||
| %out = quantum.custom "TestGate"() %q : !quantum.bit | ||
| return %out : !quantum.bit | ||
| } | ||
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
70 changes: 0 additions & 70 deletions
70
mlir/lib/Quantum/Transforms/GraphDecomposition/DecompGraphSolver/CMakeLists.txt
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
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
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.