✨ Add native RCCX (relative-phase Toffoli) gate support#1886
✨ Add native RCCX (relative-phase Toffoli) gate support#1886simon1hofmann wants to merge 61 commits into
Conversation
…tation and update operation type mapping
… QC translation layer
…ed RCCX gates in QuantumComputation class
…QuantumComputation class
…nalityConstruction
|
What is still missing and up to debate:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@python/mqt/core/plugins/qiskit/qiskit_to_mqt.py`:
- Around line 321-324: Update the rccx handling in the conversion function to
pass the already computed qubits list to StandardOperation instead of
recomputing the qubit_map comprehension. Preserve the existing OpType.rccx
operation and return behavior.
In `@test/ir/test_io.cpp`:
- Around line 80-86: Add the direct <string_view> standard header include to
test_io.cpp for the std::string_view parameters in expectRccxExport, removing
reliance on transitive includes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6b41173f-e440-43b8-88a9-0da83fe59c08
📒 Files selected for processing (25)
docs/qdmi/qdmi_backend.mdinclude/mqt-core/ir/QuantumComputation.hppinclude/mqt-core/ir/operations/OpType.hppinclude/mqt-core/ir/operations/StandardOperation.hppinclude/mqt-core/qasm3/StdGates.hppinclude/mqt-core/zx/FunctionalityConstruction.hppmlir/include/mlir/Dialect/QCO/IR/QCOOps.tdmlir/include/mlir/Dialect/QCO/QCOUtils.hmlir/lib/Conversion/JeffToQCO/JeffToQCO.cppmlir/lib/Conversion/QCOToJeff/QCOToJeff.cppmlir/lib/Dialect/QCO/IR/Operations/StandardGates/RCCXOp.cppmlir/lib/Dialect/QIR/Builder/QIRProgramBuilder.cppmlir/unittests/Compiler/test_compiler_pipeline.cppmlir/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cppmlir/unittests/Dialect/QCO/IR/test_qco_ir.cppmlir/unittests/programs/qco_programs.cppmlir/unittests/programs/qco_programs.hpython/mqt/core/ir/__init__.pyipython/mqt/core/ir/operations.pyipython/mqt/core/plugins/qiskit/mqt_to_qiskit.pypython/mqt/core/plugins/qiskit/qiskit_to_mqt.pysrc/ir/operations/StandardOperation.cppsrc/qdmi/devices/dd/Device.cpptest/ir/test_io.cpptest/python/plugins/test_qiskit.py
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Did not anticipate that many changes to add another gate, @denialhaag would it be possible to get a review? |
Hahah. Yeah, it's quite wild how far reaching adding a single native gate is 😅 |
denialhaag
left a comment
There was a problem hiding this comment.
Thanks a lot for going through all of this, @simon1hofmann! 🙂
This already looks good to me. I just have some minor nitpicks, which you can find below. Don't be surprised by the number of comments; 16 of them are the same comment.
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Thanks for addressing my comments! This LGTM now! 🙂
We should also add a changelog entry for the non-MLIR changes. I'm also wondering if we want to backport this. If we do so, I would not update MQTOpt and MQTRef, though. 🤔
I'll leave the final say to @burgholzer! 😌
Thanks a lot for the review @denialhaag 🙏 |
Ahh, good catch! The commits look good to me! 👍 |
Signed-off-by: simon1hofmann <119581649+simon1hofmann@users.noreply.github.com>
Description
Adds native RCCX (relative-phase Toffoli) support across MQT Core.
Gate convention (Qiskit / OpenQASM):
rccx(q0, q1, q2)—q0andq1are the inner controls,q2is the target. Controlled variants follow the usual pattern:crccx(c, q0, q1, q2)andmcrccx({c…}, q0, q1, q2).RCCX is self-inverse and differs from CCX by relative phases on the computational basis.
IR & Python
OpType::RCCXwithrccx/crccx/mcrccxonQuantumComputationStandardOperation::invert()treats RCCX as self-inverseMLIR (QC / QCO / QIR)
RCCXOpin QC, QCO, and QIR dialects with closed-form 8×8 unitaryrccx,crccx,mcrccxQuantumComputationtranslation testsDecision diagrams (DD)
getRccxDDbuilds the gate via canonical elementary decompositioncrccx/mcrccx; single-qubit steps on the target onlyZX functionality construction
addRccx— bare RCCX viaaddZSpider/addCnotaddCrccx— single outer control viaaddCphase,addMcphase,addMcxaddMcrccx— multi-control viaaddMcrz/addMcrx/addMcz/addMcphase/addMcx(delegates toaddCrccxfor one control)parseOpdispatches by control count, consistent with other gatesCanonical decomposition (matches
decompose-multi-controlled-gates/emitRCCXSequence):H(t) → T(t) → CX(c1,t) → Tdg(t) → CX(c0,t) → T(t) → CX(c1,t) → Tdg(t) → H(t)Qiskit plugin & QDMI
rccx/crccx/mcrccxAI Assistance
Used
Composer 2.5via Cursor for parts of this change. I reviewed the fulldiff and take responsibility for everything in this PR.
Checklist
If PR contains AI-assisted content:
Assisted-by: [Model Name] via [Tool Name]footer.