qpe_toolbox.circuit.circuits_opt

Functions

svd_optimal_gate_update(tensor, left_inds)

Solve for the SVD-optimal isometric update of a variational tensor.

tn_fit(tn, tn_target, *[, tags, steps, tol, ...])

Fit tensor network tn to target tensor network tn_target.

Module Contents

qpe_toolbox.circuit.circuits_opt.svd_optimal_gate_update(tensor, left_inds)[source]

Solve for the SVD-optimal isometric update of a variational tensor.

tensor is the environment of a variational tensor: the rest of a tensor network, fully contracted, with that tensor removed. This is the closed-form solution of the associated unconstrained linear problem: the isometry \(X\) maximizing \(\mathrm{Re}\,\mathrm{Tr}(X^\dagger B)\) is \(X = U V^\dagger\), where \(B = U S V^\dagger\) is the SVD of the environment. The singular values \(S\) are not returned, only their sum.

Parameters:
  • tensor (Tensor) – Contracted environment tensor.

  • left_inds (sequence of str) – Subset of tensor’s indices forming the left side of the SVD bipartition; the remaining indices form the right side.

Returns:

  • new_isometry (Tensor) – Optimal unitary (isometric if not square) tensor, with the same indices as tensor but not necessarily in the same order.

  • objective (float) – Sum of the singular values of \(B\), i.e. the achieved value of \(\mathrm{Re}\,\mathrm{Tr}(X^\dagger B)\).

qpe_toolbox.circuit.circuits_opt.tn_fit(tn, tn_target, *, tags='SU4SWAP', steps=100, tol=1e-08, contract_optimize='auto-hq')[source]

Fit tensor network tn to target tensor network tn_target.

Parameters:
  • tn (TensorNetwork) – The tensor network to be optimized (in-place).

  • tn_target (TensorNetwork) – The target tensor network (usually a state we want to approximate).

  • tags (str or sequence of str, optional) – Tags selecting which tensors of tn to optimize (any tag matches). Default is "SU4SWAP".

  • steps (int) – Number of sweeps.

  • tol (float) – Convergence tolerance on the change of the overlap.

  • contract_optimize (str) – Contraction strategy for the environments.

Raises:
  • TypeError – If a tensor selected by tags is parametrized.

  • ValueError – If a tensor selected by tags is not a whole two-qubit gate. A Circuit built with the default gate_contract='auto-split-gate' splits gates that are not full rank (e.g. identity or CNOT): build it with gate_contract=False.

Notes

Progress is shown via a tqdm bar; set the TQDM_DISABLE environment variable to silence it.