quairkit.application.comb.comb¶
The source file of the PQCombNet class.
-
class quairkit.application.comb.comb.PQCombNet(target_function, num_slots=
1
, ancilla=0
, slot_dim=2
, train_unitary_info=1000
, test_unitary_info=0
, train_mode='process'
, task_name=None
, is_ctrl_U=False
, seed=None
)¶ Parameterized Quantum Comb Net.
- Parameters:¶
- target_function : Callable[[Tensor], Tensor]¶
The function to apply to each unitary in the dataset.
- num_slots : int¶
The number of unitaries to be queried.
- ancilla : List[int] | int¶
The ancilla dimension or dimension list.
- slot_dim : int¶
The slot dimension for the unitaries to be queried.
- train_unitary_info : int | Tensor¶
The number of unitaries or the unitary dataset to be used for training or the training unitary set.
- test_unitary_info : int | Tensor¶
The number of unitaries or the unitary dataset to be used for testing or the testing unitary set.
- train_mode : str¶
The training mode, which can be “process”, “comb”, or “swap”, default is “process”.
- task_name : str¶
Optional name for the task, useful for data logging and storage.
- is_ctrl_U : bool¶
Flag to indicate if a controlled-U operation is used in the training process.
- seed : int | None¶
Optional seed for random number generation, enhancing reproducibility.
- update_V_circuit(index, new_V)¶
Update the V circuit at the specified index with a new circuit.
- Parameters:¶
- index : int¶
The index of the V circuit to update.
- new_V : Circuit | ParamOracle | Tensor | Tuple[Tensor, List[int]]¶
The new V circuit, which can be a ParamOracle, Circuit, torch.Tensor or Tuple[torch.Tensor, List[int]].
- Raises:¶
ValueError – If the index is out of range or if the dimension of the provided Circuit does not match the dimension of the existing Circuit.
TypeError – If the new_V is not a Circuit, ParamOracle, torch.Tensor, or Tuple[torch.Tensor, List[int]].
-
train(projector=
None
, base_lr=0.1
, max_epochs=10000
, is_save_data=False
, is_auto_stop=True
)¶ Train the PQCombNet model.
- Parameters:¶
- projector : Tensor | None¶
The projector to apply to the ancilla system of the output state.
- base_lr : float¶
The base learning rate for the optimizer.
- max_epochs : int¶
The maximum number of epochs to train for.
- is_save_data : bool¶
A flag to indicate whether to save the training data.
- is_auto_stop : bool¶
A flag to indicate whether to stop training early if the learning rate is too low.
- extract_highest_fidelity()¶
Call the _extract_highest_fidelity function to generate the fidelity tables. If the file does not exist, prompt the user to set is_save_data to True.
- plot()¶
Plot the quantum comb circuit.