Infleqtion / client-superstaq

https://superstaq.readthedocs.io
Apache License 2.0
84 stars 19 forks source link

validate qubit types in cirq-superstaq #1011

Closed richrines1 closed 1 week ago

richrines1 commented 1 month ago

What is happening?

we only support qubit types defined in cirq-core. cirq-rigetti and cirq-pasqal both define custom qubit types, which currently result in internal server errors when submitted to superstaq, e.g.

css.Service().compile(
    cirq.Circuit(cirq.X(cirq_rigetti.AspenQubit(2, 3))),
    target="ss_unconstrained_simulator"
)  # SuperstaqServerException: Internal Server Error (Status code: 500)

css.Service().compile(
    cirq.Circuit(cirq.X(cirq_rigetti.AspenQubit(2, 3))),
    target="ss_unconstrained_simulator"
)  # SuperstaqServerException: Internal Server Error (Status code: 500)

we should add a validator to reject these circuits client-side with a helpful message

something like this should be sufficient:

supported_qid_types = (
    cirq.LineQubit, cirq.LineQid, cirq.GridQubit, cirq.GridQid, cirq.NamedQubit, cirq.NamedQid
)
if not all(isinstance(q, supported_qid_types) for q in circuit.all_qubits()):
    raise ...

What are the current alternatives?

Any additional context?

No response