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 a list of it.

Raises:

ValueError – Party’s ID should be str or int.

partial_state(state, qubits_idx, is_desired=True)

Get the quantum state of the qubits of interest.

Parameters:
  • state (List[LoccState] | LoccState) – Input LOCC state.

  • qubits_idx (Iterable) – Indices of the qubits of interest. It should be a tuple of (party_id, qubit_id), or a list of it.

  • is_desired (bool) – If True, return the partial quantum state with the respect to the given qubits; if False, return the partial quantum state with the respect to the remaining qubits. Defaults to True.

Raises:
  • ValueError – Party’s ID should be str or int.

  • ValueError – The state should be LoccState or a list of it.

Returns:

LOCC state after obtaining partial quantum state.

Return type:

List[LoccState] | LoccState

reset_state(status, state, which_qubits)

Reset the quantum state of the qubits of interest.

Parameters:
  • status (List[LoccState] | LoccState) – LOCC state before resetting.

  • state (State) – Matrix form of the input quantum state.

  • which_qubits (Iterable) – Indices of the qubits to be reset. It should be a tuple of (party_id, qubit_id), or a list of it.

Raises:
  • ValueError – Party’s ID should be str or int.

  • ValueError – The state should be LoccState or a list of it.

Returns:

LOCC state after resetting the state of part of the qubits.

Return type:

List[LoccState] | LoccState

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 set party_name and the party’s index number will be automatically assigned.

Raises:

ValueError – The party_name should be str.

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 or int.

Returns:

Created local ansatz.

Return type:

LoccAnsatz

measure(status, which_qubits, results_desired, theta=None)

Perform 0-1 measurement or parameterized measurement on an LOCC state.

Parameters:
  • status (List[LoccState] | LoccState) – LOCC state to be measured.

  • which_qubits (Iterable) – Indices of the qubits to be measured.

  • results_desired (List[str] | str) – Expected measurement outcomes.

  • theta (Tensor | None) – Parameters of measurement. Defaults to None, which means 0-1 measurement.

Raises:
  • ValueError – The results_desired should be str or a list of it.

  • ValueError – Party’s ID should be str or int.

  • ValueError – The status should be LoccState or a list of it.

Returns:

LOCC state after measurement.

Return type:

List[LoccState] | LoccState

get_num_qubits()

Get the number of the qubits in this LOCCNet.

Returns:

The number of qubits in LOCCNet.

Return type:

int