paddle_quantum.locc.locc_ansatz
The source file of the LoccAnsatz class.
- class paddle_quantum.locc.locc_ansatz.LoccAnsatz(party)
Bases:
Circuit
Inherit the
Circuit
class. The purpose is to build a circuit template for an LOCC task.In an LOCC task, each party can only perform quantum operations on their own qubits. So we only allow local quantum gates to be added to each party’s qubits.
- Parameters:
party (LoccParty) – The owner of this circuit.
- append(operator)
Append an operator.
- Parameters:
operator (Iterable | Operator) – operator with a name or just an operator.
- extend(operators)
Append a list of operators.
- Parameters:
operators (List[Operator]) – List of operators.
- insert(index, operator)
Insert an operator at index
index
.- Parameters:
index (int) – Index to be inserted.
operator (Operator) – An operator.
- pop(operator)
Remove the matched operator.
- Parameters:
operator (Operator) – Matched with which the operator will be popped.
- forward(state)
Forward the input.
- h(qubits_idx='full', num_qubits=None, depth=1)
Add single-qubit Hadamard gates.
- Parameters:
qubits_idx (Iterable | int | str) – Indices of the qubits on which the gates are applied. Defaults to
'full'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- s(qubits_idx='full', num_qubits=None, depth=1)
Add single-qubit S gates.
- Parameters:
qubits_idx (Iterable | int | str) – Indices of the qubits on which the gates are applied. Defaults to
'full'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- t(qubits_idx='full', num_qubits=None, depth=1)
Add single-qubit T gates.
- Parameters:
qubits_idx (Iterable | int | str) – Indices of the qubits on which the gates are applied. Defaults to
'full'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- x(qubits_idx='full', num_qubits=None, depth=1)
Add single-qubit X gates.
- Parameters:
qubits_idx (Iterable | int | str) – Indices of the qubits on which the gates are applied. Defaults to
'full'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- y(qubits_idx='full', num_qubits=None, depth=1)
Add single-qubit Y gates.
- Parameters:
qubits_idx (Iterable | int | str) – Indices of the qubits on which the gates are applied. Defaults to
'full'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- z(qubits_idx='full', num_qubits=None, depth=1)
Add single-qubit Z gates.
- Parameters:
qubits_idx (Iterable | int | str) – Indices of the qubits on which the gates are applied. Defaults to
'full'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- p(qubits_idx='full', num_qubits=None, depth=1, param=None, param_sharing=False)
Add single-qubit P gates.
- Parameters:
qubits_idx (Iterable | int | str) – Indices of the qubits on which the gates are applied. Defaults to
'full'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- rx(qubits_idx='full', num_qubits=None, depth=1, param=None, param_sharing=False)
Add single-qubit rotation gates about the x-axis.
- Parameters:
qubits_idx (Iterable | int | str) – Indices of the qubits on which the gates are applied. Defaults to
'full'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- ry(qubits_idx='full', num_qubits=None, depth=1, param=None, param_sharing=False)
Add single-qubit rotation gates about the y-axis.
- Parameters:
qubits_idx (Iterable | int | str) – Indices of the qubits on which the gates are applied. Defaults to
'full'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- rz(qubits_idx='full', num_qubits=None, depth=1, param=None, param_sharing=False)
Add single-qubit rotation gates about the z-axis.
- Parameters:
qubits_idx (Iterable | int | str) – Indices of the qubits on which the gates are applied. Defaults to
'full'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- u3(qubits_idx='full', num_qubits=None, depth=1, param=None, param_sharing=False)
Add single-qubit rotation gates.
- Parameters:
qubits_idx (Iterable | int | str) – Indices of the qubits on which the gates are applied. Defaults to
'full'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | Iterable[float] | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- cnot(qubits_idx='cycle', num_qubits=None, depth=1)
Add CNOT gates.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- cx(qubits_idx='cycle', num_qubits=None, depth=1)
Same as cnot.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- cy(qubits_idx='cycle', num_qubits=None, depth=1)
Add controlled Y gates.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- cz(qubits_idx='cycle', num_qubits=None, depth=1)
Add controlled Z gates.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- swap(qubits_idx='cycle', num_qubits=None, depth=1)
Add SWAP gates.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- cp(qubits_idx='cycle', num_qubits=None, depth=1, param=None, param_sharing=False)
Add controlled P gates.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- crx(qubits_idx='cycle', num_qubits=None, depth=1, param=None, param_sharing=False)
Add controlled rotation gates about the x-axis.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- cry(qubits_idx='cycle', num_qubits=None, depth=1, param=None, param_sharing=False)
Add controlled rotation gates about the y-axis.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- crz(qubits_idx='cycle', num_qubits=None, depth=1, param=None, param_sharing=False)
Add controlled rotation gates about the z-axis.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- cu(qubits_idx='cycle', num_qubits=None, depth=1, param=None, param_sharing=False)
Add controlled single-qubit rotation gates.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- rxx(qubits_idx='cycle', num_qubits=None, depth=1, param=None, param_sharing=False)
Add RXX gates.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- ryy(qubits_idx='cycle', num_qubits=None, depth=1, param=None, param_sharing=False)
Add RYY gates.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- rzz(qubits_idx='cycle', num_qubits=None, depth=1, param=None, param_sharing=False)
Add RZZ gates.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- ms(qubits_idx='cycle', num_qubits=None, depth=1)
Add Mølmer-Sørensen (MS) gates.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- cswap(qubits_idx='cycle', num_qubits=None, depth=1)
Add CSWAP (Fredkin) gates.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- ccx(qubits_idx='cycle', num_qubits=None, depth=1)
Add CCX gates.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- universal_two_qubits(qubits_idx='cycle', num_qubits=None, depth=1, param=None, param_sharing=False)
Add universal two-qubit gates. One of such a gate requires 15 parameters.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- universal_three_qubits(qubits_idx='cycle', num_qubits=None, depth=1, param=None, param_sharing=False)
Add universal three-qubit gates. One of such a gate requires 81 parameters.
- Parameters:
qubits_idx (Iterable | str) – Indices of the qubits on which the gates are applied. Defaults to
'cycle'
.num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.param (Tensor | float | None) – Parameters of the gates. Defaults to
None
.param_sharing (bool) – Whether gates in the same layer share a parameter. Defaults to
False
.
- oracle(oracle, qubits_idx, num_qubits=None, depth=1)
Add an oracle gate.
- Parameters:
oracle (Tensor) – Unitary oracle to be implemented.
qubits_idx (Iterable[Iterable[int]] | Iterable[int] | int) – Indices of the qubits on which the gates are applied.
num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.
- control_oracle(oracle, qubits_idx, num_qubits=None, depth=1)
Add a controlled oracle gate.
- Parameters:
oracle (Tensor) – Unitary oracle to be implemented.
qubits_idx (Iterable[Iterable[int]] | Iterable[int]) – Indices of the qubits on which the gates are applied.
num_qubits (int | None) – Total number of qubits. Defaults to
None
.depth (int) – Number of layers. Defaults to
1
.