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

Add CliffordCircuitPredicate if we're using the stabilizer simulator #560

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

isobelhooper
Copy link

Description

QuantinuumBackend currently doesn't check if a circuit compiled for or run on the stabilizer simulator is a Clifford circuit. This PR fixes that by adding a predicate check in that case.

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.

@isobelhooper isobelhooper requested a review from yao-cqc as a code owner January 9, 2025 16:36
@isobelhooper isobelhooper force-pushed the add-clifford-predicate-when-compiling-for-stabilizer branch from 06e4876 to 8114290 Compare January 9, 2025 16:44
@@ -615,6 +616,8 @@ def required_predicates(self) -> list[Predicate]:
assert self.backend_info is not None
preds.append(MaxNQubitsPredicate(self.backend_info.n_nodes))
preds.append(MaxNClRegPredicate(cast(int, self.backend_info.n_cl_reg)))
if self.simulator_type == "stabilizer":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a test or two showing that this is working?

Copy link
Author

Choose a reason for hiding this comment

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

Will do - I think this makes sense to just be a unit test. Any objections to me adding a new unit test file, given that this doesn't really fit with any of the existing unit test filenames?

Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a related test here which could be extended. (In fact, don't we expect that test to now throw an error from process_circuit()?)

It's possible to request the stabilizer simulator for non-Clifford circuits
at the moment, which doesn't make sense. This commit adds a predicate
to make sure that if we request the (non-default) stabilizer simulator,
the circuit we submit or compile has to be a Clifford circuit.
@isobelhooper isobelhooper force-pushed the add-clifford-predicate-when-compiling-for-stabilizer branch 3 times, most recently from 333fa91 to e7d1410 Compare January 16, 2025 14:03
Added a new unit test that checks we include the CliffordCircuitPredicate
only when we're running with a stabilizer simulator type (and not
when we have a statevector simulator).

Also update test_simulator to expect to fail on compilation, rather
than breaking on get_result().
@isobelhooper isobelhooper force-pushed the add-clifford-predicate-when-compiling-for-stabilizer branch from e7d1410 to 1c671f3 Compare January 16, 2025 14:08
@isobelhooper
Copy link
Author

Integration test is currently failing because CliffordCircuitPredicate doesn't allow Measure operations. It's reasonable for a stabilizer simulator to allow measurement, so this is a problem in the predicate itself. Alec's opened CQCL/tket#1742 to address that, and this PR will wait until that's in TKET.

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