paddle_quantum.locc.locc_net
The source file of the LoccNet class.
- class paddle_quantum.locc.locc_net.LoccNet
Bases:
Layer
Used to design LOCC protocols and perform training or verification.
- set_init_state(state, qubits_idx)
Initialize the LoccState of LoccNet.
- Parameters:
state (State) – Matrix form of the input quantum state.
qubits_idx (Iterable) – Indices of the qubits corresponding to the input quantum state. It should be a
tuple
of(party_id, qubit_id)
, or alist
of it.
- Raises:
ValueError – Party’s ID should be
str
orint
.
- partial_state(state, qubits_idx, is_desired=True)
Get the quantum state of the qubits of interest.
- Parameters:
qubits_idx (Iterable) – Indices of the qubits of interest. It should be a
tuple
of(party_id, qubit_id)
, or alist
of it.is_desired (bool) – If
True
, return the partial quantum state with the respect to the given qubits; ifFalse
, return the partial quantum state with the respect to the remaining qubits. Defaults toTrue
.
- Raises:
ValueError – Party’s ID should be
str
orint
.ValueError – The
state
should beLoccState
or alist
of it.
- Returns:
LOCC state after obtaining partial quantum state.
- Return type:
- reset_state(status, state, which_qubits)
Reset the quantum state of the qubits of interest.
- Parameters:
- Raises:
ValueError – Party’s ID should be
str
orint
.ValueError – The
state
should beLoccState
or alist
of it.
- Returns:
LOCC state after resetting the state of part of the qubits.
- Return type:
- add_new_party(qubits_number, party_name=None)
Add a new LOCC party.
- Parameters:
qubits_number (int) – Number of qubits of the party.
party_name (str | None) – Name of the party. Defaults to
None
.
Note
You can use a string or a number as a party’s ID. If a string is preferred, you can set
party_name
; if a number is preferred, then you don’t need to setparty_name
and the party’s index number will be automatically assigned.- Raises:
ValueError – The
party_name
should bestr
.- Returns:
ID of the party.
- Return type:
int | str
- create_ansatz(party_id)
Create a new local ansatz.
- Parameters:
party_id (int | str) – Party’s ID.
- Raises:
ValueError – Party’s ID should be
str
orint
.- Returns:
Created local ansatz.
- Return type:
- measure(status, which_qubits, results_desired, theta=None)
Perform 0-1 measurement or parameterized measurement on an LOCC state.
- Parameters:
- Raises:
ValueError – The
results_desired
should bestr
or alist
of it.ValueError – Party’s ID should be
str
orint
.ValueError – The
status
should beLoccState
or alist
of it.
- Returns:
LOCC state after measurement.
- Return type:
- get_num_qubits()
Get the number of the qubits in this LOCCNet.
- Returns:
The number of qubits in LOCCNet.
- Return type:
int