Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor greedy pauli simp #1611

Draft
wants to merge 39 commits into
base: main
Choose a base branch
from
Draft

Refactor greedy pauli simp #1611

wants to merge 39 commits into from

Conversation

yao-cqc
Copy link
Contributor

@yao-cqc yao-cqc commented Oct 8, 2024

Description

Supports mid-circuit measurements, resets, conditionals and classical gates.

A modified version of the existing Pauli graph is needed for this feature.

Related issues

Please mention any github issues addressed by this PR.

Checklist

  • I have performed a self-review of my code.
  • I have commented hard-to-understand parts of my code.
  • I have made corresponding changes to the public API documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the changelog with any user-facing changes.

Copy link
Contributor

@sjdilkes sjdilkes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, just a question on functionality!

@@ -74,9 +44,9 @@ SCENARIO("Clifford synthesis") {
}
GIVEN("2Q Simple Clifford") {
Circuit circ(2);
circ.add_op<unsigned>(OpType::Y, {0});
// circ.add_op<unsigned>(OpType::Y, {0});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add these back in to the tests?

/**
* @brief Conditional Pauli rotation
*/
class ConditionalPauliRotation : public PauliRotation {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we only have ConditionalPauliRotation and not ConditionalClifford? My concern is that if a user provides a conditional Clifford operation, and not a conditional rotation, then each conditional Clifford adds new branching as a series of ConditionalPauliRotation? Is this how they would be handled currently?

SpPauliStabiliser qpt = cliff_.get_row_product(SpPauliStabiliser(qpm));
auto [pauli_dense, theta] = dense_pauli(qpt, n_qubits_, angle);
PauliNode_ptr node;
if (conditional) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah Ok. So on conditional = true, regardless of whether it's a Clifford angle or not, we add it to the circuit as a Pauli Exponential (or potentially one with a Clifford angle), and they get resolved at synthesis. So if it happens to have a Clifford angle, it doesn't matter, we can still use the pre-existing logic, it just turns out eventually it will get synthesised with only Cliffords coincidentially.

That's a really nice solution!

/**
* @brief Black box node for classical Ops
*/
class ClassicalNode : public PauliNode {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this cover all the ops for pytket-quantinuum? i.e.:

_ADDITIONAL_GATES = {
    OpType.Reset,
    OpType.Measure,
    OpType.Barrier,
    OpType.RangePredicate,
    OpType.MultiBit,
    OpType.ExplicitPredicate,
    OpType.ExplicitModifier,
    OpType.SetBits,
    OpType.CopyBits,
    OpType.ClassicalExpBox,
    OpType.WASM,
}


unsigned ACPairNode::tqe_cost() const {
return static_cast<unsigned>(
1.5 * (n_anti_commute_entries_ - 1) + n_commute_entries_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you add a comment explaining the rationale behind this cost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants