Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 8 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,20 @@ repos:

# Priority 1: Second-pass fixers

## Clang-format the C++ part of the code base automatically
## Format C++ files with clang-format
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v22.1.0
hooks:
- id: clang-format
types_or: [c++, c, cuda]
priority: 1
- id: clang-format
name: clang-format (TableGen)
types_or: [file]
files: \.td$
priority: 1

## CMake format and lint the CMakeLists.txt files
## Format CMakeLists.txt files
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
Expand All @@ -127,7 +132,7 @@ repos:
rev: v3.8.1
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
types_or: [yaml, markdown, html, css, scss, javascript, json, json5]
priority: 1

## Python linting using ruff
Expand Down
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], [#1565]) ([**@denialhaag**])
- ✨ Add a `place-and-route` pass for mapping circuits to architectures with restricted topologies ([#1537], [#1547], [#1568]) ([**@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], [#1542], [#1548], [#1550], [#1554], [#1570], [#1572])
([#1264], [#1330], [#1402], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475], [#1506], [#1510], [#1513], [#1521], [#1542], [#1548], [#1550], [#1554], [#1570], [#1572], [#1573])
([**@burgholzer**], [**@denialhaag**], [**@taminob**], [**@DRovara**], [**@li-mingbao**], [**@Ectras**], [**@MatthiasReumann**], [**@simon1hofmann**])

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

<!-- PR links -->

[#1573]: https://github.com/munich-quantum-toolkit/core/pull/1573
[#1572]: https://github.com/munich-quantum-toolkit/core/pull/1572
[#1571]: https://github.com/munich-quantum-toolkit/core/pull/1571
[#1570]: https://github.com/munich-quantum-toolkit/core/pull/1570
Expand Down
9 changes: 4 additions & 5 deletions mlir/include/mlir/Conversion/JeffToQCO/JeffToQCO.td
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ def JeffToQCO : Pass<"jeff-to-qco"> {
- Support for multiple functions is currently limited
}];

let dependentDialects = [
"mlir::arith::ArithDialect",
"mlir::math::MathDialect",
"mlir::tensor::TensorDialect",
"mlir::qco::QCODialect",
let dependentDialects = ["mlir::arith::ArithDialect",
"mlir::math::MathDialect",
"mlir::tensor::TensorDialect",
"mlir::qco::QCODialect",
];
}
4 changes: 1 addition & 3 deletions mlir/include/mlir/Conversion/QCOToJeff/QCOToJeff.td
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@ def QCOToJeff : Pass<"qco-to-jeff"> {
Note that this pass is still in development as QCO and Jeff do not have full feature parity yet.
}];

let dependentDialects = [
"mlir::jeff::JeffDialect",
];
let dependentDialects = ["mlir::jeff::JeffDialect"];
}
4 changes: 1 addition & 3 deletions mlir/include/mlir/Conversion/QCOToQC/QCOToQC.td
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ def QCOToQC : Pass<"qco-to-qc"> {
It handles the transformation of qubit values in QCO to qubit references in QC, ensuring that the semantics of quantum operations are preserved during the conversion process.
}];

let dependentDialects = [
"mlir::qc::QCDialect",
];
let dependentDialects = ["mlir::qc::QCDialect"];
}
4 changes: 1 addition & 3 deletions mlir/include/mlir/Conversion/QCToQCO/QCToQCO.td
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ def QCToQCO : Pass<"qc-to-qco"> {
It handles the transformation of qubit references in QC to qubit values in QCO, ensuring that the semantics of quantum operations are preserved during the conversion process.
}];

let dependentDialects = [
"mlir::qco::QCODialect",
];
let dependentDialects = ["mlir::qco::QCODialect"];
}
8 changes: 3 additions & 5 deletions mlir/include/mlir/Conversion/QCToQIR/QCToQIR.td
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
include "mlir/Pass/PassBase.td"

def QCToQIR : Pass<"qc-to-qir"> {
let summary = "Lower the QC dialect to the LLVM dialect compliant with QIR 2.0";
let summary =
"Lower the QC dialect to the LLVM dialect compliant with QIR 2.0";

let description = [{
This pass lowers all operations from the QC dialect to their equivalent operations in the LLVM dialect, ensuring compliance with the QIR 2.0 standard.
Expand Down Expand Up @@ -44,8 +45,5 @@ def QCToQIR : Pass<"qc-to-qir"> {
```
}];


let dependentDialects = [
"mlir::LLVM::LLVMDialect",
];
let dependentDialects = ["mlir::LLVM::LLVMDialect"];
}
10 changes: 5 additions & 5 deletions mlir/include/mlir/Dialect/QC/IR/QCDialect.td
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
include "mlir/IR/DialectBase.td"

def QCDialect : Dialect {
let name = "qc";
let name = "qc";

let summary = "The QC (reference semantics) dialect for quantum computing.";
let summary = "The QC (reference semantics) dialect for quantum computing.";

let description = [{
let description = [{
The QC dialect uses **reference semantics** where quantum operations
modify qubits in place, similar to how hardware physically transforms
quantum states. This model provides:
Expand All @@ -35,9 +35,9 @@ def QCDialect : Dialect {
```
}];

let cppNamespace = "::mlir::qc";
let cppNamespace = "::mlir::qc";

let useDefaultTypePrinterParser = 1;
let useDefaultTypePrinterParser = 1;
}

#endif // MLIR_DIALECT_QC_IR_QCDIALECT_TD
98 changes: 39 additions & 59 deletions mlir/include/mlir/Dialect/QC/IR/QCInterfaces.td
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include "mlir/IR/OpBase.td"
//===----------------------------------------------------------------------===//

def UnitaryOpInterface : OpInterface<"UnitaryOpInterface"> {
let description = [{
let description = [{
This interface provides a unified API for all operations that apply or
produce a unitary transformation. This includes base gates, user-defined
gates, modifier operations (control, inverse, power), and sequences.
Expand All @@ -25,68 +25,48 @@ def UnitaryOpInterface : OpInterface<"UnitaryOpInterface"> {
across all unitary operations in the QC dialect.
}];

let cppNamespace = "::mlir::qc";
let cppNamespace = "::mlir::qc";

let methods = [
// Qubit accessors
InterfaceMethod<
"Returns the number of qubits acted on by the unitary operation.",
"size_t", "getNumQubits", (ins)
>,
InterfaceMethod<
"Returns the number of target qubits (excluding control qubits).",
"size_t", "getNumTargets", (ins)
>,
InterfaceMethod<
"Returns the number of control qubits (both positive and negative).",
"size_t", "getNumControls", (ins)
>,
InterfaceMethod<
"Returns the i-th qubit (targets + controls combined).",
"Value", "getQubit", (ins "size_t":$i)
>,
InterfaceMethod<
"Returns the i-th target qubit.",
"Value", "getTarget", (ins "size_t":$i)
>,
InterfaceMethod<
"Returns the i-th control qubit.",
"Value", "getControl", (ins "size_t":$i)
>,
let methods = [
// Qubit accessors
InterfaceMethod<
"Returns the number of qubits acted on by the unitary operation.",
"size_t", "getNumQubits", (ins)>,
InterfaceMethod<
"Returns the number of target qubits (excluding control qubits).",
"size_t", "getNumTargets", (ins)>,
InterfaceMethod<
"Returns the number of control qubits (both positive and negative).",
"size_t", "getNumControls", (ins)>,
InterfaceMethod<"Returns the i-th qubit (targets + controls combined).",
"Value", "getQubit", (ins "size_t":$i)>,
InterfaceMethod<"Returns the i-th target qubit.", "Value", "getTarget",
(ins "size_t":$i)>,
InterfaceMethod<"Returns the i-th control qubit.", "Value", "getControl",
(ins "size_t":$i)>,

// Parameter handling
InterfaceMethod<
"Returns the number of parameters.",
"size_t", "getNumParams", (ins)
>,
InterfaceMethod<
"Returns the i-th parameter.",
"Value", "getParameter", (ins "size_t":$i)
>,
// Parameter handling
InterfaceMethod<"Returns the number of parameters.", "size_t",
"getNumParams", (ins)>,
InterfaceMethod<"Returns the i-th parameter.", "Value", "getParameter",
(ins "size_t":$i)>,

// Convenience methods
InterfaceMethod<
"Returns true if the operation has any control qubits, otherwise false.",
"bool", "isControlled", (ins),
[{ return $_op.getNumControls() > 0; }]
>,
InterfaceMethod<
"Returns true if the operation only acts on a single qubit.",
"bool", "isSingleQubit", (ins),
[{ return $_op.getNumQubits() == 1; }]
>,
InterfaceMethod<
"Returns true if the operation acts on two qubits.",
"bool", "isTwoQubit", (ins),
[{ return $_op.getNumQubits() == 2; }]
>,
// Convenience methods
InterfaceMethod<"Returns true if the operation has any control qubits, "
"otherwise false.",
"bool", "isControlled", (ins),
[{ return $_op.getNumControls() > 0; }]>,
InterfaceMethod<
"Returns true if the operation only acts on a single qubit.", "bool",
"isSingleQubit", (ins), [{ return $_op.getNumQubits() == 1; }]>,
InterfaceMethod<"Returns true if the operation acts on two qubits.",
"bool", "isTwoQubit", (ins),
[{ return $_op.getNumQubits() == 2; }]>,

// Identification
InterfaceMethod<
"Returns the base symbol/mnemonic of the operation.",
"StringRef", "getBaseSymbol", (ins)
>,
];
// Identification
InterfaceMethod<"Returns the base symbol/mnemonic of the operation.",
"StringRef", "getBaseSymbol", (ins)>,
];
}

#endif // MLIR_DIALECT_QC_IR_QCINTERFACES_TD
Loading
Loading