paddle_quantum.backend.quleaf
The source file of the quleaf backend.
- paddle_quantum.backend.quleaf.set_quleaf_backend(backend)
Set the backend of the QuLeaf.
- Parameters:
backend (str) – The backend you want to set.
- paddle_quantum.backend.quleaf.get_quleaf_backend()
Get the current backend of the QuLeaf.
- Returns:
Current backend of the QuLeaf.
- Return type:
str
- paddle_quantum.backend.quleaf.set_quleaf_token(token)
Set the token of the QuLeaf.
You need to input your token if you want tu use the cloud server.
- Parameters:
token (str) – Your token.
- paddle_quantum.backend.quleaf.get_quleaf_token()
Get the token you set.
- Returns:
The token you set.
- Return type:
str
- class paddle_quantum.backend.quleaf.ExpecValOp
Bases:
PyLayer
- static forward(ctx, state, hamiltonian, shots, *parameters)
The forward function to compute the expectation value of the observable in the QuLeaf Backend.
- Parameters:
ctx (PyLayerContext) – To save some variables so that they can be used in the backward function.
param – The parameters in the previous quantum gates.
state (State) – The quantum state to be measured.
hamiltonian (Hamiltonian) – The observable.
shots (Tensor) – The number of measurement shots.
*parameters – The parameters in the parameterized quantum circuit.
- Returns:
The expectation value of the observable for the input state.
- Return type:
Tensor
- static backward(ctx, expec_val_grad)
The backward function which is to compute the gradient of the input parameters.
- Parameters:
ctx (PyLayerContext) – To get the variables saved in the forward function.
expec_val_grad (Tensor) – The gradient of the expectation value.
- Returns:
The gradient of the parameters for the quantum gates.
- Return type:
Tensor