pyqrack.qrack_neuron_torch_layer

Attributes

_IS_TORCH_AVAILABLE

_IS_TORCH_AVAILABLE

param_shift_eps

init_phi

fp_type

Classes

QrackNeuronTorchFunction

Static forward/backward/apply functions for QrackNeuronTorch

QrackNeuronTorch

Torch wrapper for QrackNeuron

QrackNeuronTorchLayer

Torch layer wrapper for QrackNeuron (with maximally expressive set of neurons between inputs and outputs)

Functions

dummy_post_init_fn(simulator)

Module Contents

pyqrack.qrack_neuron_torch_layer._IS_TORCH_AVAILABLE = True
pyqrack.qrack_neuron_torch_layer._IS_TORCH_AVAILABLE = False
pyqrack.qrack_neuron_torch_layer.param_shift_eps = 1.5707963267948966
pyqrack.qrack_neuron_torch_layer.init_phi
pyqrack.qrack_neuron_torch_layer.fp_type
class pyqrack.qrack_neuron_torch_layer.QrackNeuronTorchFunction

Bases: Function if _IS_TORCH_AVAILABLE else object

Static forward/backward/apply functions for QrackNeuronTorch

static _apply(angles, neuron)
static forward(ctx, x, neuron)
static _backward(angles, neuron, simulator)
static backward(ctx, grad_output)
class pyqrack.qrack_neuron_torch_layer.QrackNeuronTorch(neuron, x)

Bases: nn.Module if _IS_TORCH_AVAILABLE else object

Torch wrapper for QrackNeuron

neuron

QrackNeuron backing this torch wrapper

Type:

QrackNeuron

neuron
weights
forward()
pyqrack.qrack_neuron_torch_layer.dummy_post_init_fn(simulator)
class pyqrack.qrack_neuron_torch_layer.QrackNeuronTorchLayer(input_qubits, output_qubits, hidden_qubits=None, lowest_combo_count=0, highest_combo_count=2, activation=int(NeuronActivationFn.Generalized_Logistic), parameters=None, post_init_fn=dummy_post_init_fn, **kwargs)

Bases: nn.Module if _IS_TORCH_AVAILABLE else object

Torch layer wrapper for QrackNeuron (with maximally expressive set of neurons between inputs and outputs)

simulator

Prototype simulator that batching copies to use with QrackNeuron instances. (You may customize or overwrite the initialization or reference, before calling forward(x).)

Type:

QrackSimulator

simulators

In-flight copies of prototype simulator corresponding to batch count

Type:

list[QrackSimulator]

input_indices

simulator qubit indices used as QrackNeuron inputs

Type:

list[int], read-only

output_indices

simulator qubit indices used as QrackNeuron outputs

Type:

list[int], read-only

hidden_indices

simulator qubit indices used as QrackNeuron hidden inputs (in maximal superposition)

Type:

list[int], read-only

neurons

QrackNeuronTorch wrappers (for PyQrack QrackNeurons) in this layer, corresponding to weights

Type:

ModuleList[QrackNeuronTorch]

weights

List of tensors corresponding one-to-one with weights of list of neurons

Type:

ParameterList

apply_fn

Corresponds to QrackNeuronTorchFunction.apply(x, neuron_wrapper) (or override with a custom implementation)

Type:

Callable[Tensor, QrackNeuronTorch]

post_init_fn

Function that is applied after forward(x) state initialization, before inference. (As the function depends on nothing but the simulator, it’s differentiable.)

Type:

Callable[QrackSimulator]

simulator
simulators = []
input_indices
hidden_indices
output_indices
activation
dtype
apply_fn
post_init_fn
neurons
forward(x)