Bases

Bases#

Trainable sparsifying bases. Circuit bases (QFT, entangled QFT, TEBD, MERA, Rich, RealRich, DCT-IV) act on a whole 2^m x 2^n image; BlockedBasis tiles an inner basis over image blocks. Every circuit basis is a CircuitBasis: a gate program and the tensors of its gates. The *_code helpers return a family’s applier and initial tensors; ft_mat and ift_mat apply one to an image.

Sparse-basis subpackage.

Every name is importable from here. Where things live:

  • bases.core — what every basis shares: CircuitBasis, the transforms, bases_allclose, with_tensors and the parameter views (ParameterView).

  • bases.base — the QFT, EntangledQFT, TEBD, MERA and DCT4 classes.

  • bases.circuit — one module per circuit family with its gate emitter (<family>_gates); the Rich and RealRich classes; freeze_as_blocked.

  • bases.block — BlockedBasis, an inner basis tiled over image blocks.

Contents

QFTBasis

QFT tensor-network basis.

EntangledQFTBasis

QFT with an entanglement layer on min(m, n) row/col qubit pairs, after it or before it.

TEBDBasis

2D TEBD basis with row + column rings of controlled-phase gates.

MERABasis

2D MERA basis.

DCT4Basis

DCT-IV tensor-network basis: the real-orthogonal, ancilla-free analogue of QFTBasis.

RichBasis

QFT topology with H + learnable U(4) gates instead of H + CP.

RealRichBasis

QFT topology with H + real-orthogonal 2-qubit gates.

BlockedBasis

Wraps an inner parametric basis as a within-block transform.

CircuitBasis

A basis that is a gate circuit on m row qubits and n column qubits.

AbstractSparseBasis

Structural interface shared by every basis: an image_size, a num_parameters count, and forward_transform / inverse_transform on a 2^m x 2^n image.

freeze_as_blocked

Return (basis_copy_with_identity_outer_gates, frozen_indices).

fit_to_dct

Fit a parametric basis so its forward circuit ≈ DCT_2D.

bases_allclose

Semantic equality across any of the registered basis types.

program_of

The gate program of a basis; for a blocked basis, the one of the circuit it tiles.

with_tensors

A copy of basis holding tensors in place of its own; everything else is kept.

cp_phases

The angle of every controlled-phase gate, in stored order: the phase-only parameters.

with_cp_phases

A copy of basis whose controlled-phase gates have the angles phases.

cp_diagonals

The four phases of every controlled-phase tensor, in stored order: shape (gates, 2, 2).

with_cp_diagonals

A copy of basis whose controlled-phase tensors are exp(i * phases).

ParameterView

What a trainer moves in place of a basis's tensors.

tensors_view

What a trainer moves in place of a basis's tensors.

cp_phases_view

What a trainer moves in place of a basis's tensors.

cp_diagonals_view

What a trainer moves in place of a basis's tensors.

qft_code

Return (code, initial_tensors) for 2D QFT on (2^m, 2^n) images.

entangled_qft_code

Return (code, initial_tensors, n_entangle); see entangled_qft_gates.

tebd_code

Return (code, initial_tensors, n_row_gates, n_col_gates); see tebd_gates.

mera_code

Return (code, initial_tensors, n_row_gates, n_col_gates); see mera_gates.

dct4_code

Return (code, initial_tensors) for 2D DCT-IV; see dct4_gates.

ft_mat

Apply code to one (2**m, 2**n) image, in double precision.

ift_mat

Apply code to one (2**m, 2**n) image, in double precision.