API documentation¶
- pytket.extensions.qujax.qujax_convert.print_circuit(circuit, symbol_map=None, qubit_min=0, qubit_max=inf, gate_ind_min=0, gate_ind_max=inf, sep_length=1)[source]¶
Returns and prints basic string representation of circuit.
For more information on the
symbol_mapparameter refer to thetk_to_qujax()ortk_to_qujax_args()documentation.- Parameters:
circuit (
Circuit) – Circuit to be converted (without any measurement commands).If
None, parameterised gates determined byqujax.gates.If
dict, maps symbolic pytket parameters following the order in this dict.qubit_min (
int) – Index of first qubit to display.qubit_max (
int) – Index of final qubit to display.gate_ind_min (
int) – Index of gate to start circuit printing.gate_ind_max (
int) – Index of gate to stop circuit printing.sep_length (
int) – Number of dashes to separate gates.
- Return type:
- Returns:
String representation of circuit
- pytket.extensions.qujax.qujax_convert.qujax_args_to_tk(gate_seq, qubit_inds_seq, param_inds_seq, n_qubits=None, param=None)[source]¶
Convert qujax args into pytket Circuit.
- Parameters:
gate_seq (
Sequence[str]) – Sequence of gates. Each element is a string matching an array or function inqujax.gatesqubit_inds_seq (
Sequence[Sequence[int]]) – Sequences of qubits (ints) that gates are acting on.param_inds_seq (
Sequence[Sequence[int]]) – Sequence of parameter indices that gates are using, i.e. [[0], [], [5, 2]] tells qujax that the first gate uses the first parameter, the second gate is not parameterised and the third gates used the fifth and second parameters.param (
Array|None) – Circuit parameters, if parameterised. Defaults to all zeroes.
- Return type:
- Returns:
Circuit
- pytket.extensions.qujax.qujax_convert.tk_to_param(circuit)[source]¶
Extract the parameter vector for non-symbolic circuits. i.e. an array where each element corresponds to the parameter of a parameterised gate found in the circuit
- pytket.extensions.qujax.qujax_convert.tk_to_qujax(circuit, symbol_map=None, simulator='statetensor')[source]¶
Converts a pytket circuit into a function that maps circuit parameters to a statetensor (or densitytensor). Assumes all circuit gates can be found in
qujax.gates. Thesymbol_mapargument controls the interpretation of any symbolic parameters found incircuit.free_symbols().If
symbol_mapisNone,circuit.free_symbols()will be ignored. Parameterised gates will be determined based on whether they are stored as functions (parameterised) or arrays (non-parameterised) in qujax.gates. The order of qujax circuit parameters is the same as incircuit.get_commands().If
symbol_mapis provided as adict, assign qujax circuit parameters to symbolic parameters incircuit.free_symbols(); the order of qujax circuit parameters will be given by this dict. Keys of the dict should be symbolic pytket parameters as incircuit.free_symbols()and the values indicate the index of the qujax circuit parameter – integer indices starting from 0.
The conversion can be checked by examining the output from
tk_to_qujax_args()orprint_circuit().- Parameters:
circuit (
Circuit) – Circuit to be converted (without any measurement commands).If
None, parameterised gates determined byqujax.gates.If
dict, maps symbolic pytket parameters following the order in this dict.simulator (
str) – string in (‘statetensor’, ‘densitytensor’, ‘unitarytensor’) corresponding to qujax simulator type. Defaults to statetensor.
- Return type:
Union[CallableArrayAndOptionalArray,CallableOptionalArray]- Returns:
Function which maps parameters (and optional statetensor_in) to a statetensor. If the circuit has no parameters, the resulting function will only take the optional
statetensor_inas an argument.
- pytket.extensions.qujax.qujax_convert.tk_to_qujax_args(circuit, symbol_map=None)[source]¶
Converts a pytket circuit into a tuple of arguments representing a qujax quantum circuit. Assumes all circuit gates can be found in
qujax.gatesThesymbol_mapargument controls the interpretation of any symbolic parameters found incircuit.free_symbols().If
symbol_mapisNone,circuit.free_symbols()will be ignored. Parameterised gates will be determined based on whether they are stored as functions (parameterised) or arrays (non-parameterised) in qujax.gates. The order of qujax circuit parameters is the same as incircuit.get_commands().If
symbol_mapis provided as adict, assign qujax circuit parameters to symbolic parameters incircuit.free_symbols(); the order of qujax circuit parameters will be given by this dict. Keys of the dict should be symbolic pytket parameters as incircuit.free_symbols()and the values indicate the index of the qujax circuit parameter – integer indices starting from 0.
The conversion can also be checked with
print_circuit().- Parameters:
- Return type:
tuple[Sequence[str|Callable[[Array],Array]],Sequence[Sequence[int]],Sequence[Sequence[int]],int]- Returns:
Tuple of arguments defining a (parameterised) quantum circuit that can be sent to
qujax.get_params_to_statetensor_func. The elements of the tuple (qujax args) are as followsSequence of gate name strings to be found in
qujax.gates.Sequence of sequences describing which qubits gates act on.
Sequence of sequences of parameter indices that gates are using.
Number of qubits.