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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel

### Added

- ✨ Add initial infrastructure for new QC and QCO MLIR dialects ([#1264]) ([**@burgholzer**], [**@denialhaag**])
- ✨ Add initial infrastructure for new QC and QCO MLIR dialects ([#1264], [#1402]) ([**@burgholzer**], [**@denialhaag**])
- ✨ Return device handle from `add_dynamic_device_library` for direct backend creation ([#1381]) ([**@marcelwa**])
- ✨ Add IQM JSON support for job submission in Qiskit-QDMI Backend ([#1375], [#1382]) ([**@marcelwa**], [**@burgholzer**])
- ✨ Add authentication support for QDMI sessions with token, username/password, auth file, auth URL, and project ID parameters ([#1355]) ([**@marcelwa**])
Expand Down Expand Up @@ -286,6 +286,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool

<!-- PR links -->

[#1402]: https://github.com/munich-quantum-toolkit/core/pull/1402
[#1385]: https://github.com/munich-quantum-toolkit/core/pull/1385
[#1384]: https://github.com/munich-quantum-toolkit/core/pull/1384
[#1383]: https://github.com/munich-quantum-toolkit/core/pull/1383
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Dialect/QC/Builder/QCProgramBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ class QCProgramBuilder final : public OpBuilder {
*
* @par Example:
* ```c++
* builder.ctrl(q0, [&](auto& b) { b.x(q1); });
* builder.ctrl(q0, [&] { builder.x(q1); });
* ```
* ```mlir
* qc.ctrl(%q0) {
Expand All @@ -842,7 +842,7 @@ class QCProgramBuilder final : public OpBuilder {
* ```
*/
QCProgramBuilder& ctrl(ValueRange controls,
const std::function<void(OpBuilder&)>& body);
const std::function<void()>& body);

//===--------------------------------------------------------------------===//
// Deallocation
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/QC/IR/QCOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ def CtrlOp : QCOp<"ctrl",

let builders = [
OpBuilder<(ins "ValueRange":$controls, "UnitaryOpInterface":$bodyUnitary)>,
OpBuilder<(ins "ValueRange":$controls, "const std::function<void(OpBuilder &)>&":$bodyBuilder)>
OpBuilder<(ins "ValueRange":$controls, "const std::function<void()>&":$bodyBuilder)>
];

let hasCanonicalizer = 1;
Expand Down
11 changes: 6 additions & 5 deletions mlir/include/mlir/Dialect/QCO/Builder/QCOProgramBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -987,10 +987,11 @@ class QCOProgramBuilder final : public OpBuilder {
*
* @par Example:
* ```c++
* {controls_out, targets_out} = builder.ctrl(q0_in, q1_in, [&](auto& b) {
* auto q1_res = b.x(q1_in);
* return {q1_res};
* });
* {controls_out, targets_out} =
* builder.ctrl(q0_in, q1_in, [&](ValueRange targets) {
* auto q1_res = builder.x(targets[0]);
* return {q1_res};
* });
* ```
* ```mlir
* %controls_out, %targets_out = qco.ctrl(%q0_in) %q1_in {
Expand All @@ -1001,7 +1002,7 @@ class QCOProgramBuilder final : public OpBuilder {
*/
std::pair<ValueRange, ValueRange>
ctrl(ValueRange controls, ValueRange targets,
const std::function<ValueRange(OpBuilder&, ValueRange)>& body);
const std::function<ValueRange(ValueRange)>& body);

//===--------------------------------------------------------------------===//
// Deallocation
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/QCO/IR/QCOOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ def CtrlOp : QCOOp<"ctrl", traits =
build($_builder, $_state, controls.getTypes(), targets.getTypes(), controls, targets);
}]>,
OpBuilder<(ins "ValueRange":$controls, "ValueRange":$targets, "UnitaryOpInterface":$bodyUnitary)>,
OpBuilder<(ins "ValueRange":$controls, "ValueRange":$targets, "const std::function<ValueRange(OpBuilder &, ValueRange)>&":$bodyBuilder)>
OpBuilder<(ins "ValueRange":$controls, "ValueRange":$targets, "const std::function<ValueRange(ValueRange)>&":$bodyBuilder)>
];

let hasCanonicalizer = 1;
Expand Down
35 changes: 16 additions & 19 deletions mlir/lib/Dialect/QC/Builder/QCProgramBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ QCProgramBuilder& QCProgramBuilder::reset(Value qubit) {
const std::variant<double, Value>&(PARAM), ValueRange controls) { \
checkFinalized(); \
CtrlOp::create(*this, loc, controls, \
[&](OpBuilder& b) { OP_CLASS::create(b, loc, PARAM); }); \
[&] { OP_CLASS::create(*this, loc, PARAM); }); \
return *this; \
}

Expand All @@ -191,7 +191,7 @@ DEFINE_ZERO_TARGET_ONE_PARAMETER(GPhaseOp, gphase, theta)
Value target) { \
checkFinalized(); \
CtrlOp::create(*this, loc, controls, \
[&](OpBuilder& b) { OP_CLASS::create(b, loc, target); }); \
[&] { OP_CLASS::create(*this, loc, target); }); \
return *this; \
}

Expand Down Expand Up @@ -228,9 +228,8 @@ DEFINE_ONE_TARGET_ZERO_PARAMETER(SXdgOp, sxdg)
const std::variant<double, Value>&(PARAM), ValueRange controls, \
Value target) { \
checkFinalized(); \
CtrlOp::create(*this, loc, controls, [&](OpBuilder& b) { \
OP_CLASS::create(b, loc, target, PARAM); \
}); \
CtrlOp::create(*this, loc, controls, \
[&] { OP_CLASS::create(*this, loc, target, PARAM); }); \
return *this; \
}

Expand Down Expand Up @@ -263,8 +262,8 @@ DEFINE_ONE_TARGET_ONE_PARAMETER(POp, p, theta)
const std::variant<double, Value>&(PARAM2), ValueRange controls, \
Value target) { \
checkFinalized(); \
CtrlOp::create(*this, loc, controls, [&](OpBuilder& b) { \
OP_CLASS::create(b, loc, target, PARAM1, PARAM2); \
CtrlOp::create(*this, loc, controls, [&] { \
OP_CLASS::create(*this, loc, target, PARAM1, PARAM2); \
}); \
return *this; \
}
Expand Down Expand Up @@ -300,8 +299,8 @@ DEFINE_ONE_TARGET_TWO_PARAMETER(U2Op, u2, phi, lambda)
const std::variant<double, Value>&(PARAM3), ValueRange controls, \
Value target) { \
checkFinalized(); \
CtrlOp::create(*this, loc, controls, [&](OpBuilder& b) { \
OP_CLASS::create(b, loc, target, PARAM1, PARAM2, PARAM3); \
CtrlOp::create(*this, loc, controls, [&] { \
OP_CLASS::create(*this, loc, target, PARAM1, PARAM2, PARAM3); \
}); \
return *this; \
}
Expand All @@ -326,9 +325,8 @@ DEFINE_ONE_TARGET_THREE_PARAMETER(UOp, u, theta, phi, lambda)
QCProgramBuilder& QCProgramBuilder::mc##OP_NAME( \
ValueRange controls, Value qubit0, Value qubit1) { \
checkFinalized(); \
CtrlOp::create(*this, loc, controls, [&](OpBuilder& b) { \
OP_CLASS::create(b, loc, qubit0, qubit1); \
}); \
CtrlOp::create(*this, loc, controls, \
[&] { OP_CLASS::create(*this, loc, qubit0, qubit1); }); \
return *this; \
}

Expand Down Expand Up @@ -358,8 +356,8 @@ DEFINE_TWO_TARGET_ZERO_PARAMETER(ECROp, ecr)
const std::variant<double, Value>&(PARAM), ValueRange controls, \
Value qubit0, Value qubit1) { \
checkFinalized(); \
CtrlOp::create(*this, loc, controls, [&](OpBuilder& b) { \
OP_CLASS::create(b, loc, qubit0, qubit1, PARAM); \
CtrlOp::create(*this, loc, controls, [&] { \
OP_CLASS::create(*this, loc, qubit0, qubit1, PARAM); \
}); \
return *this; \
}
Expand Down Expand Up @@ -394,8 +392,8 @@ DEFINE_TWO_TARGET_ONE_PARAMETER(RZZOp, rzz, theta)
const std::variant<double, Value>&(PARAM2), ValueRange controls, \
Value qubit0, Value qubit1) { \
checkFinalized(); \
CtrlOp::create(*this, loc, controls, [&](OpBuilder& b) { \
OP_CLASS::create(b, loc, qubit0, qubit1, PARAM1, PARAM2); \
CtrlOp::create(*this, loc, controls, [&] { \
OP_CLASS::create(*this, loc, qubit0, qubit1, PARAM1, PARAM2); \
}); \
return *this; \
}
Expand All @@ -417,9 +415,8 @@ QCProgramBuilder& QCProgramBuilder::barrier(ValueRange qubits) {
// Modifiers
//===----------------------------------------------------------------------===//

QCProgramBuilder&
QCProgramBuilder::ctrl(ValueRange controls,
const std::function<void(OpBuilder&)>& body) {
QCProgramBuilder& QCProgramBuilder::ctrl(ValueRange controls,
const std::function<void()>& body) {
checkFinalized();
CtrlOp::create(*this, loc, controls, body);
return *this;
Expand Down
8 changes: 4 additions & 4 deletions mlir/lib/Dialect/QC/IR/Modifiers/CtrlOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ struct CtrlInlineGPhase final : OpRewritePattern<CtrlOp> {
SmallVector<Value> newControls(op.getControls());
const auto newTarget = newControls.back();
newControls.pop_back();
CtrlOp::create(rewriter, op.getLoc(), newControls, [&](OpBuilder& b) {
POp::create(b, op.getLoc(), newTarget, gPhaseOp.getTheta());
CtrlOp::create(rewriter, op.getLoc(), newControls, [&] {
POp::create(rewriter, op.getLoc(), newTarget, gPhaseOp.getTheta());
});
rewriter.eraseOp(op);

Expand Down Expand Up @@ -161,14 +161,14 @@ void CtrlOp::build(OpBuilder& odsBuilder, OperationState& odsState,

void CtrlOp::build(OpBuilder& odsBuilder, OperationState& odsState,
ValueRange controls,
const std::function<void(OpBuilder&)>& bodyBuilder) {
const std::function<void()>& bodyBuilder) {
const OpBuilder::InsertionGuard guard(odsBuilder);
odsState.addOperands(controls);
auto* region = odsState.addRegion();
auto& block = region->emplaceBlock();

odsBuilder.setInsertionPointToStart(&block);
bodyBuilder(odsBuilder);
bodyBuilder();
odsBuilder.create<YieldOp>(odsState.location);
}

Expand Down
Loading
Loading