cirq_superstaq.compiler_output

Classes

CompilerOutput

A class that arranges compiled cirq circuit information.

Functions

active_qubit_indices(→ list[int])

Returns the indices of the non-idle qubits in a quantum circuit.

measured_qubit_indices(→ list[int])

Returns the indices of the measured qubits in a quantum circuit.

read_json(→ CompilerOutput)

Reads out returned JSON from Superstaq API's IBMQ compilation endpoint.

read_json_aqt(→ CompilerOutput)

Reads out returned JSON from Superstaq API's AQT compilation endpoint.

read_json_qscout(→ CompilerOutput)

Reads out returned JSON from Superstaq API's QSCOUT compilation endpoint.

Module Contents

class cirq_superstaq.compiler_output.CompilerOutput(circuits: cirq.Circuit | list[cirq.Circuit] | list[list[cirq.Circuit]], initial_logical_to_physicals: dict[cirq.Qid, cirq.Qid] | list[dict[cirq.Qid, cirq.Qid]] | list[list[dict[cirq.Qid, cirq.Qid]]], final_logical_to_physicals: dict[cirq.Qid, cirq.Qid] | list[dict[cirq.Qid, cirq.Qid]] | list[list[dict[cirq.Qid, cirq.Qid]]], pulse_gate_circuits: Any | None = None, seq: qtrl.sequencer.Sequence | None = None, jaqal_programs: list[str] | None = None)

Bases: general_superstaq.BaseCompilerOutput[cirq.Circuit, cirq.Qid]

A class that arranges compiled cirq circuit information.

cirq_superstaq.compiler_output.active_qubit_indices(circuit: cirq.AbstractCircuit) list[int]

Returns the indices of the non-idle qubits in a quantum circuit.

Note

The “index” refers to the argument of a LineQubit (so e.g. cirq.LineQubit(5) has index 5 regardless of the total number of qubits in the circuit).

Parameters:

circuit – The input quantum circuit.

Returns:

A list of active qubit indicies.

Raises:

TypeError – If qubit indices are requested for non-line qubits.

cirq_superstaq.compiler_output.measured_qubit_indices(circuit: cirq.AbstractCircuit) list[int]

Returns the indices of the measured qubits in a quantum circuit.

Note

The “index” refers to the argument of a cirq.LineQubit (so e.g. cirq.LineQubit(5) has index 5 regardless of the total number of qubits in the circuit).

Parameters:

circuit – The input quantum circuit.

Returns:

A list of the measurement qubit indices.

Raises:

TypeError – If qubit indices are requested for non-line qubits.

cirq_superstaq.compiler_output.read_json(json_dict: dict[str, Any], circuits_is_list: bool) CompilerOutput

Reads out returned JSON from Superstaq API’s IBMQ compilation endpoint.

Parameters:
  • json_dict – A JSON dictionary matching the format returned by /ibmq_compile endpoint

  • circuits_is_list – A bool flag that controls whether the returned object has a .circuits attribute (if True) or a .circuit attribute (False).

Returns:

A CompilerOutput object with the compiled circuit(s). If included in the server response, the returned object also stores the corresponding pulse gate circuit(s) in its .pulse_gate_circuit(s) attribute (provided qiskit-superstaq is available locally).

cirq_superstaq.compiler_output.read_json_aqt(json_dict: dict[str, Any], circuits_is_list: bool, num_eca_circuits: int | None = None) CompilerOutput

Reads out returned JSON from Superstaq API’s AQT compilation endpoint.

Parameters:
  • json_dict – A JSON dictionary matching the format returned by aqt_compile endpoint.

  • circuits_is_list – A bool flag that controls whether the returned object has a .circuits attribute (if True) or a .circuit attribute (False).

  • num_eca_circuits – Number of logically equivalent random circuits to generate for each input circuit.

Returns:

A CompilerOutput object with the compiled circuit(s). If qtrl is available locally, the returned object also stores the pulse sequence in the .seq attribute.

cirq_superstaq.compiler_output.read_json_qscout(json_dict: dict[str, Any], circuits_is_list: bool, num_eca_circuits: int | None = None) CompilerOutput

Reads out returned JSON from Superstaq API’s QSCOUT compilation endpoint.

Parameters:
  • json_dict – A JSON dictionary matching the format returned by qscout_compile endpoint.

  • circuits_is_list – A bool flag that controls whether the returned object has a .circuits attribute (if True) or a .circuit attribute (False).

  • num_eca_circuits – Optional number of logically equivalent random circuits to generate for each input circuit.

Returns:

A CompilerOutput object with the compiled circuit(s) and a list of jaqal programs represented as strings.