Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel
- ✨ Add conversions between Jeff and QCO ([#1479], [#1548]) ([**@denialhaag**])
- ✨ Add a `place-and-route` pass for mapping circuits to architectures with restricted topologies ([#1537], [#1547]) ([**@MatthiasReumann**])
- ✨ Add initial infrastructure for new QC and QCO MLIR dialects
([#1264], [#1330], [#1402], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475], [#1506], [#1510], [#1513], [#1521], [#1548], [#1550], [#1554])
([#1264], [#1330], [#1402], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475], [#1506], [#1510], [#1513], [#1521], [#1548], [#1550], [#1554], [#1567])
([**@burgholzer**], [**@denialhaag**], [**@taminob**], [**@DRovara**], [**@li-mingbao**], [**@Ectras**], [**@MatthiasReumann**], [**@simon1hofmann**])

### Changed
Expand Down Expand Up @@ -331,6 +331,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool

<!-- PR links -->

[#1567]: https://github.com/munich-quantum-toolkit/core/pull/1567
[#1554]: https://github.com/munich-quantum-toolkit/core/pull/1554
[#1550]: https://github.com/munich-quantum-toolkit/core/pull/1550
[#1549]: https://github.com/munich-quantum-toolkit/core/pull/1549
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Compiler/CompilerPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class QuantumCompilerPipeline {
* @brief Add canonicalization and cleanup passes
*
* @details
* Always adds the standard MLIR canonicalization pass followed by dead
* value removal.
* Always adds the standard MLIR canonicalization pass followed by common
* sub-expression elimination and dead value removal.
*/
static void addCleanupPasses(PassManager& pm);

Expand Down
4 changes: 3 additions & 1 deletion mlir/lib/Compiler/CompilerPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ static void prettyPrintStage(ModuleOp module, const llvm::StringRef stageName,
}

void QuantumCompilerPipeline::addCleanupPasses(PassManager& pm) {
// Always run canonicalization and dead value removal
// Always run canonicalization, common sub-expression elimination, and dead
// value removal
pm.addPass(createCanonicalizerPass());
pm.addPass(createCSEPass());
pm.addPass(createRemoveDeadValuesPass());
}

Expand Down
1 change: 1 addition & 0 deletions mlir/lib/Support/Passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ using namespace mlir;
void runCanonicalizationPasses(ModuleOp module) {
PassManager pm(module.getContext());
pm.addPass(createCanonicalizerPass());
pm.addPass(createCSEPass());
pm.addPass(createRemoveDeadValuesPass());
if (pm.run(module).failed()) {
llvm::errs() << "Failed to run canonicalization passes.\n";
Expand Down
5 changes: 5 additions & 0 deletions mlir/unittests/Compiler/test_compiler_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ INSTANTIATE_TEST_SUITE_P(
"StaticQubits", nullptr, MQT_NAMED_BUILDER(mlir::qc::staticQubits),
MQT_NAMED_BUILDER(mlir::qc::staticQubits),
MQT_NAMED_BUILDER(mlir::qir::staticQubits), false},
CompilerPipelineTestCase{
"StaticQubitsWithDuplicates", nullptr,
MQT_NAMED_BUILDER(mlir::qc::staticQubitsWithDuplicates),
MQT_NAMED_BUILDER(mlir::qc::staticQubits),
MQT_NAMED_BUILDER(mlir::qir::staticQubits), false},
CompilerPipelineTestCase{"AllocQubit",
MQT_NAMED_BUILDER(qc::allocQubit), nullptr,
MQT_NAMED_BUILDER(mlir::qc::allocQubit),
Expand Down
3 changes: 3 additions & 0 deletions mlir/unittests/Dialect/QC/IR/test_qc_ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,9 @@ INSTANTIATE_TEST_SUITE_P(
MQT_NAMED_BUILDER(emptyQC)},
QCTestCase{"StaticQubits", MQT_NAMED_BUILDER(staticQubits),
MQT_NAMED_BUILDER(emptyQC)},
QCTestCase{"StaticQubitsWithDuplicates",
MQT_NAMED_BUILDER(staticQubitsWithDuplicates),
MQT_NAMED_BUILDER(staticQubitsCanonical)},
QCTestCase{"AllocDeallocPair", MQT_NAMED_BUILDER(allocDeallocPair),
MQT_NAMED_BUILDER(emptyQC)}));
/// @}
22 changes: 22 additions & 0 deletions mlir/unittests/programs/qc_programs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ void staticQubits(QCProgramBuilder& b) {
b.staticQubit(1);
}

void staticQubitsWithDuplicates(QCProgramBuilder& b) {
const auto q0a = b.staticQubit(0);
const auto q1a = b.staticQubit(1);
const auto q0b = b.staticQubit(0);
const auto q1b = b.staticQubit(1);

b.h(q0a);
b.h(q1a);
b.x(q0b);
b.x(q1b);
}

void staticQubitsCanonical(QCProgramBuilder& b) {
const auto q0 = b.staticQubit(0);
const auto q1 = b.staticQubit(1);

b.h(q0);
b.h(q1);
b.x(q0);
b.x(q1);
}

void allocDeallocPair(QCProgramBuilder& b) {
auto q = b.allocQubit();
b.dealloc(q);
Expand Down
7 changes: 7 additions & 0 deletions mlir/unittests/programs/qc_programs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ void allocLargeRegister(QCProgramBuilder& b);
/// Allocates two inline qubits.
void staticQubits(QCProgramBuilder& b);

/// Allocates duplicate static qubits for the same indices and applies gates.
void staticQubitsWithDuplicates(QCProgramBuilder& b);

/// Allocates canonical static qubits (one per index) and applies equivalent
/// gates.
void staticQubitsCanonical(QCProgramBuilder& b);

/// Allocates and explicitly deallocates a single qubit.
void allocDeallocPair(QCProgramBuilder& b);

Expand Down
Loading