pdft.bases.CircuitBasis#

class pdft.bases.CircuitBasis(m, n, tensors=None, code=None, inv_code=None)[source]#

Bases: BasisTransforms

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

tensors holds one tensor per gate, Hadamards first (Julia’s perm_vec); program says which gate each one is and when it acts. code and inv_code are the program’s forward and inverse appliers; they compare by program, so they and program are left out of the repr. To compare two bases use bases_allclose: == compares the tensor lists and raises as soon as it reaches two distinct arrays (it is True only when every tensor is the same object). program is derived, never passed in, which keeps dataclasses.replace(basis, tensors=...) working on the bases whose fields are all constructor arguments.

Every subclass is registered as a JAX pytree: the leaves are tensors, in order, which is the contract train_basis relies on. Every other attribute of the instance is aux data, so it must be hashable. Unflattening restores the attributes without running the constructor, so no gate list is rebuilt.

A family whose circuit depends on m and n alone sets emit to its gate emitter and is done. One with options of its own defines a constructor that emits its gates and hands them to _init.

Parameters:
__init__(m, n, tensors=None, code=None, inv_code=None)[source]#
Parameters:

Methods

__init__(m, n[, tensors, code, inv_code])

forward_transform(pic)

inverse_transform(pic)

conj(tensors) through inv_code, exactly like Julia's basis.inverse_code(conj.(basis.tensors)..., ...).

Attributes

freezes_to_blocked

image_size

inv_tensors

The tensor list itself.

num_parameters

m

n

tensors

program

code

inv_code

emit

m: int#
n: int#
tensors: list[Array]#
program: Program#
code: object#
inv_code: object#
freezes_to_blocked: ClassVar[bool] = False#
emit: ClassVar[Callable[[int, int], list[Gate]]]#