dbac.dme¶
Density matrix exponentiation (DME): applying \(e^{it\rho}\) to a data state \(\sigma\) using copies of \(\rho\) instead of knowledge of \(\rho\). This is the subroutine inside every DBAC step.
The module offers the same channel four ways, so the implementations can be checked against
each other. All take (data, instruction, t, M): the data and instruction density matrices, the
total duration, and the number of Trotter steps (instruction copies used).
See Density matrix exponentiation for how DME works and which implementation to pick.
Note
DBAC steps do not call this module: they use dbac.dbqite.DME, which takes the arguments in
the order (instruction, data, t, M).
|
DME as on hardware: apply a partial SWAP |
|
DME using the closed form of one channel step, |
|
DME built from qibo's SWAP gate matrix and qibo's partial trace. |
|
The exact evolution |
|
Partial trace of a bipartite |
Approximate DME (Trotterized)¶
- dme_channel(data, instruction, t, M)[source]¶
DME as on hardware: apply a partial SWAP
exp(i (t / M) SWAP)todata (x) instruction, trace out the instruction, and repeat M times with a fresh instruction copy.- Parameters:
- Returns:
The final data state, and the data state after each step.
- Return type:
Example
>>> import numpy as np >>> from dbac.dme import dme_channel, dme_expm >>> data = np.array([[1, 0], [0, 0]], dtype=complex) >>> instruction = np.full((2, 2), 0.5, dtype=complex) >>> exact = dme_expm(data, instruction, 1.0) >>> [round(float(np.linalg.norm(exact - dme_channel(data, instruction, 1.0, M)[0])), 4) ... for M in (1, 10, 100)] # error shrinks like 1/M [0.5969, 0.0757, 0.0079]
- dme_channel_equivalent(data, instruction, t, M)[source]¶
DME using the closed form of one channel step,
cos^2 data + sin^2 instruction + i sin cos [instruction, data](with anglet / M), which avoids building two-qubit matrices.- Parameters:
- Returns:
The final data state, and the data state after each step.
- Return type:
Exact reference¶
- dme_expm(data, instruction, t, M=None)[source]¶
The exact evolution
exp(i t instruction) data exp(-i t instruction), i.e. the M -> infinity limit that DME approximates. The reference for the other implementations.- Parameters:
data (np.ndarray) – 2x2 data density matrix.
instruction (np.ndarray) – 2x2 instruction density matrix (the Hamiltonian).
t (float) – Duration.
M – Ignored; accepted so the signature matches the other implementations.
- Returns:
The evolved 2x2 data density matrix (not a tuple).
- Return type:
np.ndarray
Helpers¶
- ptrace(matrix, index=1, n1=2, n2=2)[source]¶
Partial trace of a bipartite
(n1 * n2) x (n1 * n2)matrix.- Parameters:
matrix (np.ndarray) – Operator on subsystems 1 (dimension n1) and 2 (dimension n2).
index (int) – Which subsystem to trace out: 1 traces out subsystem 2 and keeps subsystem 1; 2 traces out subsystem 1 and keeps subsystem 2.
n1 (int) – Dimensions of the two subsystems.
n2 (int) – Dimensions of the two subsystems.
- Returns:
The reduced operator.
- Return type:
np.ndarray