Circuit primitives¶
hqnn_forge.circuits ¶
hqnn_forge.circuits¶
Reusable, device-agnostic VQC ansatz primitives.
These functions are pure quantum functions — they are intended to be called
inside a QNode context (i.e. called within a function decorated with
@qml.qnode). They apply in-place gate sequences and return nothing.
Exported symbols
strongly_entangling_layer CNOT ring + per-qubit Rot(φ, θ, ω) block. hardware_efficient_layer CZ ladder + per-qubit RY(θ) block (lower CNOT depth).
These are the blocks the encoding layers run, selected by their entangler
argument through hqnn_forge.encoding.angle_embedding.apply_variational_layers:
entangler="ring"(the default) isstrongly_entangling_layerper layer. Despite the name, it is notentangler="strongly_entangling", which is PennyLane'sqml.StronglyEntanglingLayers(Rot first, then a CNOT ring of growing range).entangler="hardware_efficient"ishardware_efficient_layerper layer.
hardware_efficient_layer ¶
hardware_efficient_layer(weights: Tensor, n_qubits: int) -> None
Apply one hardware-efficient block to the current quantum circuit.
Gate count per call:
- n_qubits - 1 CZ gates (nearest-neighbour ladder)
- n_qubits RY gates (1 trainable parameter each)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights
|
Tensor
|
Rotation angles tensor of shape |
required |
n_qubits
|
int
|
Number of qubits. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
strongly_entangling_layer ¶
strongly_entangling_layer(weights: Tensor, n_qubits: int) -> None
Apply one strongly-entangling block to the current quantum circuit.
Gate count per call:
- n_qubits CNOT gates (entangling ring)
- n_qubits Rot gates (3 parameters each → 3 * n_qubits trainable angles)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights
|
Tensor
|
Rotation angles tensor of shape |
required |
n_qubits
|
int
|
Number of qubits. Must match |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |