Skip to content

[Feature]: Add post rebase 1Q gate optimisation in QSystemPass #1419

@CalMacCQ

Description

@CalMacCQ

Problem Statement

There are oppurtunities to reduce the number of 1Q gates after we compile to the QSystem native gateset. These are fairly simple to add in.

This would involve calling the pytket SquashRzPhasedX pass in QSystemPass after the conversion to the hardware native gate set is performed. This should clean up some redundant single qubit gates.

We did this optimisation for pytket-quantinuum compilation. It shouldn't impact fault-tolerance of circuits as 2Q gates are preserved... Therefore errors will not spread differently in the transformed circuit.

Proposed Solution

It should be easy to make a call to Tket1Pass from the tket1-passes project in the implementation of QSystemPass.

Something like

let squash_pass_json = serde_json::to_string(&tket_json_rs::pass::BasePass::StandardPass {
            pass: tket_json_rs::pass::standard::StandardPass::SquashRzPhasedX,
        })
Tket1Pass::run_from_json(&squash_pass_json, &mut circuit_ptr).unwrap();

// Add appropriate decoding -> HUGR

Component

tket-qsystem

Effort Estimate

low

Additional Context

Here is a concrete example using pytket where such optimisations reduce the number of 1q gates

from pytket import Circuit, OpType
from pytket.passes import AutoRebase, SquashRzPhasedX
from pytket.circuit.display import render_circuit_jupyter as draw

# Define a circuit
circ = Circuit(3).H(0).H(1).H(2).CX(0, 1).CX(1, 2).Rz(1/4, 2)
draw(circ)
Image

We can now convert the circuit to {ZZPhase, Rz, PhasedX} with AutoRebase

AutoRebase({OpType.ZZPhase, OpType.Rz, OpType.PhasedX}).apply(circ)
print("#Rz gates:", circ.n_gates_of_type(OpType.Rz))
print("#PhasedX gates:", circ.n_gates_of_type(OpType.PhasedX))
draw(circ)
#Rz gates: 8
#PhasedX gates: 7
Image

Now if we apply 1Q squashing via SquashRzPhasedX

SquashRzPhasedX().apply(circ)
print("#Rz gates:", circ.n_gates_of_type(OpType.Rz))
print("#PhasedX gates:", circ.n_gates_of_type(OpType.PhasedX))
draw(circ)
#Rz gates: 3
#PhasedX gates: 5
Image

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions