def serialize_single_circuit(
        self,
        circuit: cirq.AbstractCircuit,
        job_settings: dict | None = None,
        error_mitigation: dict | None = None,
    ) -> SerializedProgram:
        """Serialize the given circuit.

        Raises:
            ValueError: if the circuit has gates that are not supported or is otherwise invalid.
        """
        self._validate_circuit(circuit)
        self._validate_qubits(circuit.all_qubits())
        num_qubits = self._num_qubits(circuit)

        serialized_ops = self._serialize_circuit(circuit)

        gateset = "qis" if not _NATIVE_GATES.validate(circuit) else "native"

        # IonQ API does not support measurements, so we pass the measurement keys through
        # the metadata field.  Here we split these out of the serialized ops.
        body = {
            'gateset': gateset,
            'qubits': num_qubits,
            'circuit': [op for op in serialized_ops if op['gate'] != 'meas'],
        }
        metadata = self._serialize_measurements(op for op in serialized_ops if op['gate'] == 'meas')

        return SerializedProgram(
            body=body,
            metadata=metadata,
            settings=(job_settings or {}),
            error_mitigation=error_mitigation,
        )
Serialize the given circuit.

        Raises:
            ValueError: if the circuit has gates that are not supported or is otherwise invalid.
        
cirq-ionq/cirq_ionq/serializer.py