Architecture#
This section presents the internal design of QML-HCS (Quantum Machine-Learning Hypercausal System), organized from the lowest foundational layers to the highest orchestration layers, and visualized through layered diagrams.
QML-HCS is fully modular. No single execution flow is mandatory. Instead, the system exposes interoperable components that can be assembled into custom pipelines depending on the experiment or backend.
Main Architecture Diagram#
The following diagram shows the entire architecture from bottom (foundations) to top (orchestration):
![digraph Architecture {
rankdir=TB;
node [shape=box, style="filled,rounded", color="#1E1E1E", fillcolor="#3A3A3A", fontcolor="white"];
Core [label="Level 1 - Core Module\n(Contracts, Types, Registry, HCModel)"];
Backends [label="Level 2 - Backends\n(PennyLane, Qiskit, C++, pybind11)"];
HC [label="Level 3 - Hypercausal Layer\n(HCNode, HCGraph, Policies)"];
Predictors [label="Level 4 - Predictors\n(Deterministic & Counterfactual)"];
Loss [label="Level 5 - Loss Module\n(Task • Coherence • Consistency)"];
Metrics [label="Level 6 - Metrics Module\n(Anomaly • Control • Forecasting)"];
Optim [label="Level 7 - Optimizers\n(SPSA, Adam, Natural-Grad, Trust-KL, KFAC)"];
Callbacks [label="Level 8 - Callbacks\n(Telemetry, DepthScheduler)"];
Core -> Backends -> HC -> Predictors -> Loss -> Metrics -> Optim -> Callbacks;
}](_images/graphviz-916b594623dbb6b7aaa259dd5a140f34527c570d.png)
This is the canonical structural view, not a required flow of execution.
Note
The diagram presents the canonical structural organization of QML-HCS. It is intended as a conceptual layering model rather than an operational pipeline. Component order in this diagram does not imply a mandatory execution sequence; QML-HCS supports modular use and flexible composition.
Level 1 - Core Module (Structural Foundation)#
See also the full Core documentation
The core defines:
Typed interfaces for backends, nodes, projection policies
Registry system
Formal validation
HCModel: optional high-level orchestrator
![digraph Core {
rankdir=LR;
node [shape=box, style="rounded,filled", fillcolor="#2E2E2E", fontcolor="white"];
Types [label="Types & Protocols"];
BackendIfc [label="QuantumBackend Interface"];
Registry [label="Backend Registry"];
Model [label="HCModel"];
Types -> BackendIfc -> Registry -> Model;
}](_images/graphviz-83e9b9058f4de1008eefd781e4bb1b74468f5625.png)
Level 2 - Backend Layer (Execution Engines)#
See also the full Backends documentation
Backends provide actual numerical or quantum-based execution.
Supported adapters:
PennyLane (analytic/differentiable)
Qiskit (shot-based, stochastic)
C++ pybind11 backend (deterministic, HPC speed)
![digraph Backends {
rankdir=LR;
node [shape=box, style="rounded,filled", fillcolor="#334455", fontcolor="white"];
PL [label="PennyLane Backend"];
QK [label="Qiskit Backend"];
CPP [label="C++ Backend"];
PL -> QK -> CPP;
}](_images/graphviz-c6d2c672ff18aaf87753c8957a4f16bfdddf2cce.png)
Level 3 - Hypercausal Layer (Logical Evolution Engine)#
See also the full Hypercausal Layer documentation
Defines how states evolve over time and across branches.
Components:
HCNode (input → state → futures → representative)
HCGraph (causal connections)
Projection policies
![digraph HC {
rankdir=LR;
node [shape=box, style="rounded,filled", fillcolor="#556677", fontcolor="white"];
HCNode [label="HCNode"];
HCGraph [label="HCGraph"];
Policy [label="Projection Policies"];
HCNode -> HCGraph;
HCGraph -> Policy;
}](_images/graphviz-d04d9d1f4f9482ac99cad231e6e437a37e26e2f5.png)
Level 4 - Predictors (Deterministic & Counterfactual)#
See also the full Predictors documentation
Predictors extend computation with:
LinearProjector
Counterfactual anticipators
Mirrored perturbations
![digraph Predictors {
rankdir=LR;
node [shape=box, style="rounded,filled", fillcolor="#774444", fontcolor="white"];
Proj [label="LinearProjector"];
CF [label="Counterfactual Anticipator"];
Pert [label="Perturbations"];
Proj -> CF -> Pert;
}](_images/graphviz-1de506f92e04dd5235e1cfdeca73b0f37dbfbb4a.png)
Level 5 - Loss Evaluation Layer#
See also the full Loss Module documentation
Measures:
Task accuracy
Inter-branch coherence
Triadic temporal consistency
![digraph Loss {
rankdir=LR;
node [shape=box, style="rounded,filled", fillcolor="#664466", fontcolor="white"];
Task [label="Task Losses"];
Coh [label="Coherence"];
Cons [label="Consistency"];
Task -> Coh -> Cons;
}](_images/graphviz-9371d8e746a4e9ba2756420cb819e5931da75749.png)
Level 6 - Metrics (Advanced Temporal & Statistical Analysis)#
See also the full Metrics Module documentation
Provides higher-order diagnostics:
anomaly detection
control stability
forecasting alignment
![digraph Metrics {
rankdir=LR;
node [shape=box, style="rounded,filled", fillcolor="#334433", fontcolor="white"];
Anom [label="Anomaly Metrics"];
Ctrl [label="Control Metrics"];
Fcast[label="Forecast Metrics"];
Anom -> Ctrl -> Fcast;
}](_images/graphviz-06ac4b778c6157634107548cb22360219e4d1110.png)
Level 7 - Optimization Module#
See also the full Optimization documentation
Algorithms:
finite-diff
SPSA
Adam
Natural-Grad
Trust-KL
Dual-Ascent
MPC
KFAC
![digraph Optim {
rankdir=LR;
node [shape=box, style="rounded,filled", fillcolor="#444444", fontcolor="white"];
GD [label="Finite-Diff"];
SPSA [label="SPSA"];
Adam [label="Adam"];
NG [label="Natural Grad"];
KL [label="Trust-KL"];
KFAC [label="KFAC"];
GD -> SPSA -> Adam -> NG -> KL -> KFAC;
}](_images/graphviz-90ec4dbc0544a761d3396666a89c2fffda3dd45e.png)
Level 8 - Callbacks Layer#
See also the full Callbacks documentation
Provides live monitoring and state adaptation.
TelemetryLogger
MemoryLogger
DepthScheduler
![digraph Callbacks {
rankdir=LR;
node [shape=box, style="rounded,filled", fillcolor="#555555", fontcolor="white"];
TL [label="TelemetryLogger"];
ML [label="MemoryLogger"];
DS [label="DepthScheduler"];
TL -> ML -> DS;
}](_images/graphviz-3272f3fc6fcfb70a78176a34bb04a3b9252d87ea.png)
Optional Execution Flows (Not Mandatory)#
QML-HCS allows multiple flows; these are optional examples.
Hypercausal Flow Example
![digraph FlowHC {
rankdir=LR;
node [shape=oval, style="filled", fillcolor="#335577", fontcolor="white"];
X [label="Input"];
S [label="State"];
K [label="Future Branches"];
R [label="Representative"];
X -> S -> K -> R;
}](_images/graphviz-8ea48a7b15a04fd5ef448311102be1a83c46194a.png)
Predictor/Counterfactual Flow Example
![digraph FlowCF {
rankdir=LR;
node [shape=oval, style="filled", fillcolor="#773333", fontcolor="white"];
St [label="State"];
LP [label="LinearProjector"];
CF [label="Counterfactuals"];
Ev [label="Evaluation"];
St -> LP -> CF -> Ev;
}](_images/graphviz-e2d82b1e5e90dfb4cdd0add83809b34be09aedcb.png)
Optimization Loop Example
![digraph FlowOptim {
rankdir=LR;
node [shape=oval, style="filled", fillcolor="#555555", fontcolor="white"];
P [label="Params"];
M [label="Model"];
L [label="Loss/Metrics"];
O [label="Optimizer Step"];
P -> M -> L -> O -> P;
}](_images/graphviz-69a2d54118c9ee8124a4b28e1ca196e3571baa32.png)
Summary#
QML-HCS is structured according to increasing abstraction:
Core Module - structural base
Backends - execution engines
Hypercausal Layer - logical evolution framework
Predictors - deterministic & counterfactual expansion
Loss Layer - coherence and task evaluation
Metrics - statistical and temporal interpretation
Optimization - adaptation and learning
Callbacks - runtime monitoring and control
The diagrams above reflect modular organization, not a required pipeline. Users may assemble custom computation flows depending on their needs.