general_decomposer
check_gate_replacement
Checks that the replacement gate(s) are valid by verifying that they operate on the same qubits and preserve the quantum state up to a global phase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gate
|
Gate
|
Gate that is being replaced. |
required |
replacement_gates
|
Iterable[Gate]
|
Gate(s) that are replacing the original gate. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the replacement gates do not operate on the same qubits as the original gate. |
ValueError
|
If the replacement gates do not preserve the quantum state up to a global phase. |
Source code in opensquirrel/passes/decomposer/general_decomposer.py
decompose
Decomposes the statements in the circuit IR using the provided decomposer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ir
|
IR
|
The circuit IR to decompose. |
required |
decomposer
|
Decomposer
|
The decomposer to use for decomposing the gates. |
required |
Source code in opensquirrel/passes/decomposer/general_decomposer.py
replace
Replaces all occurrences of a specific gate in the circuit IR with a given sequence of other gates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ir
|
IR
|
The circuit IR to modify. |
required |
gate
|
type[Gate]
|
Gate to replace. |
required |
replacement_gates_function
|
Callable[..., list[Gate]]
|
Function that returns a list of replacement gates. |
required |