uniqc.circuit_builder.random_originir module#

Random OriginIR circuit generator.

This module provides functions for generating random quantum circuits in OriginIR format. It supports random gate selection, error channel insertion, and full measurement generation for testing and simulation purposes.

Key exports:

build_originir_gate: Build a single OriginIR gate string. build_originir_error_channel: Build an error channel instruction. build_full_measurements: Generate measurement instructions for all qubits. random_originir: Generate a complete random OriginIR program.

uniqc.circuit_builder.random_originir.build_full_measurements(n_qubits)[source]#

Build a line of OriginIR code for a full measurement on a set of qubits.

Parameters:

n_qubits (list) – Number of qubits to measure.

Returns:

A line of OriginIR code

Return type:

str

uniqc.circuit_builder.random_originir.build_originir_error_channel(channel, qubits, params)[source]#

Build a line of OriginIR code for a given error channel, qubits, and parameters.

Parameters:
  • channel (str) – The name of the error channel.

  • qubits (list) – A list of qubits the error channel acts on.

Returns:

A line of OriginIR code

Return type:

str

uniqc.circuit_builder.random_originir.build_originir_gate(gate, qubits, params, dagger_flag=False, control_qubit_set=None)[source]#

Build a line of OriginIR code for a given gate, qubits, and parameters.

Parameters:
  • gate (str) – The name of the gate.

  • qubits (list) – A list of qubits the gate acts on.

  • params (list) – A list of parameters for the gate.

Returns:

A line of OriginIR code

Return type:

str

uniqc.circuit_builder.random_originir.random_originir(n_qubits, n_gates, instruction_set={'BARRIER': {'param': 0, 'qubit': -1}, 'CNOT': {'param': 0, 'qubit': 2}, 'CSWAP': {'param': 0, 'qubit': 3}, 'CZ': {'param': 0, 'qubit': 2}, 'H': {'param': 0, 'qubit': 1}, 'I': {'param': 0, 'qubit': 1}, 'ISWAP': {'param': 0, 'qubit': 2}, 'PHASE2Q': {'param': 3, 'qubit': 2}, 'RPhi': {'param': 2, 'qubit': 1}, 'RPhi180': {'param': 1, 'qubit': 1}, 'RPhi90': {'param': 1, 'qubit': 1}, 'RX': {'param': 1, 'qubit': 1}, 'RY': {'param': 1, 'qubit': 1}, 'RZ': {'param': 1, 'qubit': 1}, 'S': {'param': 0, 'qubit': 1}, 'SX': {'param': 0, 'qubit': 1}, 'T': {'param': 0, 'qubit': 1}, 'TOFFOLI': {'param': 0, 'qubit': 3}, 'U1': {'param': 1, 'qubit': 1}, 'U2': {'param': 2, 'qubit': 1}, 'UU15': {'param': 15, 'qubit': 2}, 'X': {'param': 0, 'qubit': 1}, 'XX': {'param': 1, 'qubit': 2}, 'XY': {'param': 1, 'qubit': 2}, 'Y': {'param': 0, 'qubit': 1}, 'YY': {'param': 1, 'qubit': 2}, 'Z': {'param': 0, 'qubit': 1}, 'ZZ': {'param': 1, 'qubit': 2}}, channel_set=None, allow_control=False, allow_dagger=False)[source]#

Generate a random OriginIR program with a given number of qubits and gates.

Parameters:
  • n_qubits (int) – The number of qubits in the program.

  • n_gates (int) – The number of gates in the program.

  • instruction_set (dict) – A dictionary of available gates and their properties.

Returns:

A string of OriginIR code.

Return type:

str