API Reference#
diffqc Package#
diffqc: Differentiable Quantum Circuit Simulator#
See also
diffqc.dense
Densely Represented Operations
diffqc.sparse
Sparsely Represented Operations
diffqc.lib
Builtin Algorithms
diffqc.nn
Builtin Neural Network Modules
diffqc.util
Utility Functions
diffqc.pennylane
PennyLane Plugin
Examples
>>> import jax.numpy as jnp
>>> from diffqc import dense as op
>>> q0 = op.zeros(2, jnp.complex64) # |00>
>>> op.expectZ(q0, (0,))
1
>>> q1 = op.PauliX(q0, (0,)) # |10>
>>> op.expectZ(q1, (0,))
-1
>>> qh = op.Hadamard(q0, (0,)) # (|00> + |10>)/sqrt(2)
>>> qhcnot = op.CNOT(qh, (0, 1)) # (|00> + |11>)/sqrt(2)
>>> op.expectZ(qhcnot, (1,))
0
Functions#
|
Expectation of |
|
Calculate marginal probabilities |
|
Calculate probabilities for n-qubit state |
|
Sample proportional to probabilities |
diffqc.dense Module#
Densely Represented Operations (diffqc.dense
)#
Core operations with internal dense representation.
See also
diffqc.sparse
Sparsely Represented Operations
Notes
Internally probability amplitudes of all possible
2**(qubits)
quantum states are recorded as
an array with (2, 2, ..., 2)
shape.
Functions#
|
Create |
|
Convert qubits internal representation to state vector |
|
Expectation of X measurement |
|
Expectation of Y measurement |
|
Expectation of Z measurement |
|
Expectation of Unitary measurement |
|
Apply Hadamard Gate |
|
Apply Pauli X Gate |
|
Apply Pauli Y Gate |
|
Apply Pauli Z Gate |
|
Apply S Gate (Single qubite Phase Gate) |
|
Apply T Gate |
|
Apply Square Root X Gate |
|
Apply controlled-NOT Gate |
|
Apply controlled-Z Gate |
|
Apply controlled-Y Gate |
|
Apply SWAP Gate |
|
Apply i-SWAP Gate |
|
Apply Echoed RZX(pi/2) Gate |
|
Apply Square Root i-SWAP Gate |
|
Apply Square Root i-SWAP Gate |
|
Apply controlled SWAP Gate |
|
Apply Toffoli Gate (controlled controlled X Gate) |
|
Apply Rotation Gate |
|
Apply Rotation X Gate |
|
Apply Rotation Y Gate |
|
Apply Rotation Z Gate |
|
Apply Local Phase Shift Gate |
|
Apply controlled Phase Shift Gate |
|
Apply controlled Phase Shift Gate |
|
Apply Phase Shift Gate for |
|
Apply Phase Shift Gate for |
|
Apply Phase Shift Gate for |
|
Apply controlled RX Gate |
|
Apply controlled RY Gate |
|
Apply controlled RZ Gate |
|
Apply controlled Rotation Gate |
|
Apply Local Phase Shift Gate |
|
Apply controlled U2 Gate |
|
Apply U3 Gate |
|
Apply Phase SWAP Gate |
|
Rotate XX (exp(-iXX * theta)) |
|
Rotate YY (exp(-iYY * theta)) |
|
Rotate ZZ (exp(-iZZ * theta)) |
|
Unitary Gate |
|
Controlled Unitary Gate |
diffqc.sparse Module#
Sparsely Represented Operations (diffqc.sparse
)#
Core operations with internal sparse representation.
See also
diffqc.dense
Densely Represented Operations
Notes
Internally probability ampulitudes of possible quantum states
are recorded as an array with (superpositions, qubits, 2)
shape.
Warning
Since JAX requires static shape, we cannot remove zero-amplitude quantum states from superposition. Moreover, same quantum states might be traced separately.
Functions#
|
Create |
|
Convert qubits internal representation to state vector |
|
Expectation of X measurement |
|
Expectation of Y measurement |
|
Expectation of Z measurement |
|
Expectation of Unitary measurement |
|
Apply Hadamard Gate |
|
Apply Pauli X Gate |
|
Apply Pauli Y Gate |
|
Apply Pauli Z Gate |
|
Apply S Gate (Single qubite Phase Gate) |
|
Apply T Gate |
|
Apply Square Root X Gate |
|
Apply controlled-NOT Gate |
|
Apply controlled-Z Gate |
|
Apply controlled-Y Gate |
|
Apply SWAP Gate |
|
Apply i-SWAP Gate |
|
Apply Echoed RZX(pi/2) Gate |
|
Apply Square Root i-SWAP Gate |
|
Apply Square Root i-SWAP Gate |
|
Apply controlled SWAP Gate |
|
Apply Toffoli Gate (controlled controlled X Gate) |
|
Apply Rotation Gate |
|
Apply Rotation X Gate |
|
Apply Rotation Y Gate |
|
Apply Rotation Z Gate |
|
Apply Local Phase Shift Gate |
|
Apply controlled Phase Shift Gate |
|
Apply controlled Phase Shift Gate |
|
Apply Phase Shift Gate for |
|
Apply Phase Shift Gate for |
|
Apply Phase Shift Gate for |
|
Apply controlled RX Gate |
|
Apply controlled RY Gate |
|
Apply controlled RZ Gate |
|
Apply controlled Rotation Gate |
|
Apply Local Phase Shift Gate |
|
Apply controlled U2 Gate |
|
Apply U3 Gate |
|
Apply Phase SWAP Gate |
|
Rotate XX (exp(-iXX * thta)) |
|
Rotate YY (exp(-iYY * thta)) |
|
Rotate ZZ (exp(-iZZ * thta)) |
|
Unitary Gate |
|
Controlled Unitary Gate |
diffqc.lib Module#
Builtin Algorithms (diffqc.lib
)#
Notes
To support multiple internal representations,
operation module (aka. diffqc.dense
or diffqc.sparse
) is passed.
Functions#
diffqc.nn Module#
Builtin Neural Network Modules (diffqc.nn
)#
Notes
To support multiple internal representations,
operation module (aka. diffqc.dense
or diffqc.sparse
) is passed.
Functions#
|
Apply Circuit Centric Block as Parameterized Quantum Circuit (PQC) |
|
Create Convolution Function |
|
Apply Josephson Sampler as Parameterized Quantum Circuit (PQC) |
|
Max Pooling for 2D |
diffqc.util Module#
Utility Functions (diffqc.util
)#
Notes
To support multiple internal representations,
operation module (aka. diffqc.dense
or diffqc.sparse
) is passed.
Functions#
|
Create Transition Matrix from function |
|
Create all possible state |
diffqc.pennylane Module#
PennyLane Plugin (diffqc.pennylane
)#
PennyLane [1] plugin providing an device with diffqc.
Warning
This module is still under development, and missing some features.
References
Examples
>>> import pennylane as qml
>>> dev = qml.device("diffqc.qubit", wires=2, mode="dense")
Classes#
|