|
1 | 1 | Architecture |
2 | 2 | ============ |
3 | 3 |
|
4 | | -This section describes the internal design of QML-HCS, including its modular |
5 | | -quantum-classical architecture and interaction between core components. |
| 4 | +This section presents the internal design of QML-HCS (Quantum Machine-Learning |
| 5 | +Hypercausal System), organized from the **lowest foundational layers** to the |
| 6 | +**highest orchestration layers**, and visualized through layered diagrams. |
6 | 7 |
|
| 8 | +QML-HCS is fully modular. No single execution flow is mandatory. Instead, the |
| 9 | +system exposes interoperable components that can be assembled into custom |
| 10 | +pipelines depending on the experiment or backend. |
7 | 11 |
|
8 | | -.. warning:: |
| 12 | +Main Architecture Diagram |
| 13 | +------------------------- |
9 | 14 |
|
10 | | - 🚧 These sections are currently under active development. |
11 | | - Content will be expanded soon with detailed explanations, diagrams, and examples. |
| 15 | +The following diagram shows the entire architecture from bottom (foundations) |
| 16 | +to top (orchestration): |
| 17 | + |
| 18 | +.. graphviz:: |
| 19 | + :align: center |
| 20 | + |
| 21 | + digraph Architecture { |
| 22 | + rankdir=TB; |
| 23 | + node [shape=box, style="filled,rounded", color="#1E1E1E", fillcolor="#3A3A3A", fontcolor="white"]; |
| 24 | + |
| 25 | + Core [label="Level 1 - Core Module\n(Contracts, Types, Registry, HCModel)"]; |
| 26 | + Backends [label="Level 2 - Backends\n(PennyLane, Qiskit, C++, pybind11)"]; |
| 27 | + HC [label="Level 3 - Hypercausal Layer\n(HCNode, HCGraph, Policies)"]; |
| 28 | + Predictors [label="Level 4 - Predictors\n(Deterministic & Counterfactual)"]; |
| 29 | + Loss [label="Level 5 - Loss Module\n(Task • Coherence • Consistency)"]; |
| 30 | + Metrics [label="Level 6 - Metrics Module\n(Anomaly • Control • Forecasting)"]; |
| 31 | + Optim [label="Level 7 - Optimizers\n(SPSA, Adam, Natural-Grad, Trust-KL, KFAC)"]; |
| 32 | + Callbacks [label="Level 8 - Callbacks\n(Telemetry, DepthScheduler)"]; |
| 33 | + |
| 34 | + Core -> Backends -> HC -> Predictors -> Loss -> Metrics -> Optim -> Callbacks; |
| 35 | + } |
| 36 | + |
| 37 | +This is the **canonical structural view**, not a required flow of execution. |
| 38 | + |
| 39 | +.. note:: |
| 40 | + |
| 41 | + The diagram presents the canonical structural organization of QML-HCS. It is |
| 42 | + intended as a conceptual layering model rather than an operational pipeline. |
| 43 | + Component order in this diagram does *not* imply a mandatory execution sequence; |
| 44 | + QML-HCS supports modular use and flexible composition. |
| 45 | + |
| 46 | +Level 1 - Core Module (Structural Foundation) |
| 47 | +--------------------------------------------- |
| 48 | +**See also the** :doc:`full Core documentation <modules/qmlhc/core/index>` |
| 49 | + |
| 50 | +The core defines: |
| 51 | + |
| 52 | +- Typed interfaces for backends, nodes, projection policies |
| 53 | +- Registry system |
| 54 | +- Formal validation |
| 55 | +- HCModel: optional high-level orchestrator |
| 56 | + |
| 57 | +.. graphviz:: |
| 58 | + :align: center |
| 59 | + |
| 60 | + digraph Core { |
| 61 | + rankdir=LR; |
| 62 | + node [shape=box, style="rounded,filled", fillcolor="#2E2E2E", fontcolor="white"]; |
| 63 | + |
| 64 | + Types [label="Types & Protocols"]; |
| 65 | + BackendIfc [label="QuantumBackend Interface"]; |
| 66 | + Registry [label="Backend Registry"]; |
| 67 | + Model [label="HCModel"]; |
| 68 | + |
| 69 | + Types -> BackendIfc -> Registry -> Model; |
| 70 | + } |
| 71 | + |
| 72 | +Level 2 - Backend Layer (Execution Engines) |
| 73 | +------------------------------------------- |
| 74 | +**See also the** :doc:`full Backends documentation <modules/qmlhc/backends/index>` |
| 75 | + |
| 76 | +Backends provide actual numerical or quantum-based execution. |
| 77 | + |
| 78 | +Supported adapters: |
| 79 | + |
| 80 | +- PennyLane (analytic/differentiable) |
| 81 | +- Qiskit (shot-based, stochastic) |
| 82 | +- C++ pybind11 backend (deterministic, HPC speed) |
| 83 | + |
| 84 | +.. graphviz:: |
| 85 | + :align: center |
| 86 | + |
| 87 | + digraph Backends { |
| 88 | + rankdir=LR; |
| 89 | + node [shape=box, style="rounded,filled", fillcolor="#334455", fontcolor="white"]; |
| 90 | + |
| 91 | + PL [label="PennyLane Backend"]; |
| 92 | + QK [label="Qiskit Backend"]; |
| 93 | + CPP [label="C++ Backend"]; |
| 94 | + |
| 95 | + PL -> QK -> CPP; |
| 96 | + } |
| 97 | + |
| 98 | + |
| 99 | +Level 3 - Hypercausal Layer (Logical Evolution Engine) |
| 100 | +------------------------------------------------------ |
| 101 | +**See also the** :doc:`full Hypercausal Layer documentation <modules/qmlhc/hc/index>` |
| 102 | + |
| 103 | +Defines how states evolve over time and across branches. |
| 104 | + |
| 105 | +Components: |
| 106 | + |
| 107 | +- HCNode (input → state → futures → representative) |
| 108 | +- HCGraph (causal connections) |
| 109 | +- Projection policies |
| 110 | + |
| 111 | +.. graphviz:: |
| 112 | + :align: center |
| 113 | + |
| 114 | + digraph HC { |
| 115 | + rankdir=LR; |
| 116 | + node [shape=box, style="rounded,filled", fillcolor="#556677", fontcolor="white"]; |
| 117 | + |
| 118 | + HCNode [label="HCNode"]; |
| 119 | + HCGraph [label="HCGraph"]; |
| 120 | + Policy [label="Projection Policies"]; |
| 121 | + |
| 122 | + HCNode -> HCGraph; |
| 123 | + HCGraph -> Policy; |
| 124 | + } |
| 125 | + |
| 126 | + |
| 127 | +Level 4 - Predictors (Deterministic & Counterfactual) |
| 128 | +----------------------------------------------------- |
| 129 | +**See also the** :doc:`full Predictors documentation <modules/qmlhc/predictors/index>` |
| 130 | + |
| 131 | +Predictors extend computation with: |
| 132 | + |
| 133 | +- LinearProjector |
| 134 | +- Counterfactual anticipators |
| 135 | +- Mirrored perturbations |
| 136 | + |
| 137 | +.. graphviz:: |
| 138 | + :align: center |
| 139 | + |
| 140 | + digraph Predictors { |
| 141 | + rankdir=LR; |
| 142 | + node [shape=box, style="rounded,filled", fillcolor="#774444", fontcolor="white"]; |
| 143 | + |
| 144 | + Proj [label="LinearProjector"]; |
| 145 | + CF [label="Counterfactual Anticipator"]; |
| 146 | + Pert [label="Perturbations"]; |
| 147 | + |
| 148 | + Proj -> CF -> Pert; |
| 149 | + } |
| 150 | + |
| 151 | + |
| 152 | +Level 5 - Loss Evaluation Layer |
| 153 | +------------------------------- |
| 154 | +**See also the** :doc:`full Loss Module documentation <modules/qmlhc/loss/index>` |
| 155 | + |
| 156 | +Measures: |
| 157 | + |
| 158 | +- **Task accuracy** |
| 159 | +- **Inter-branch coherence** |
| 160 | +- **Triadic temporal consistency** |
| 161 | + |
| 162 | +.. graphviz:: |
| 163 | + :align: center |
| 164 | + |
| 165 | + digraph Loss { |
| 166 | + rankdir=LR; |
| 167 | + node [shape=box, style="rounded,filled", fillcolor="#664466", fontcolor="white"]; |
| 168 | + |
| 169 | + Task [label="Task Losses"]; |
| 170 | + Coh [label="Coherence"]; |
| 171 | + Cons [label="Consistency"]; |
| 172 | + |
| 173 | + Task -> Coh -> Cons; |
| 174 | + } |
| 175 | + |
| 176 | + |
| 177 | +Level 6 - Metrics (Advanced Temporal & Statistical Analysis) |
| 178 | +------------------------------------------------------------ |
| 179 | +**See also the** :doc:`full Metrics Module documentation <modules/qmlhc/metrics/index>` |
| 180 | + |
| 181 | +Provides higher-order diagnostics: |
| 182 | + |
| 183 | +- anomaly detection |
| 184 | +- control stability |
| 185 | +- forecasting alignment |
| 186 | + |
| 187 | +.. graphviz:: |
| 188 | + :align: center |
| 189 | + |
| 190 | + digraph Metrics { |
| 191 | + rankdir=LR; |
| 192 | + node [shape=box, style="rounded,filled", fillcolor="#334433", fontcolor="white"]; |
| 193 | + |
| 194 | + Anom [label="Anomaly Metrics"]; |
| 195 | + Ctrl [label="Control Metrics"]; |
| 196 | + Fcast[label="Forecast Metrics"]; |
| 197 | + |
| 198 | + Anom -> Ctrl -> Fcast; |
| 199 | + } |
| 200 | + |
| 201 | + |
| 202 | +Level 7 - Optimization Module |
| 203 | +----------------------------- |
| 204 | +**See also the** :doc:`full Optimization documentation <modules/qmlhc/optim/index>` |
| 205 | + |
| 206 | +Algorithms: |
| 207 | + |
| 208 | +- finite-diff |
| 209 | +- SPSA |
| 210 | +- Adam |
| 211 | +- Natural-Grad |
| 212 | +- Trust-KL |
| 213 | +- Dual-Ascent |
| 214 | +- MPC |
| 215 | +- KFAC |
| 216 | + |
| 217 | +.. graphviz:: |
| 218 | + :align: center |
| 219 | + |
| 220 | + digraph Optim { |
| 221 | + rankdir=LR; |
| 222 | + node [shape=box, style="rounded,filled", fillcolor="#444444", fontcolor="white"]; |
| 223 | + |
| 224 | + GD [label="Finite-Diff"]; |
| 225 | + SPSA [label="SPSA"]; |
| 226 | + Adam [label="Adam"]; |
| 227 | + NG [label="Natural Grad"]; |
| 228 | + KL [label="Trust-KL"]; |
| 229 | + KFAC [label="KFAC"]; |
| 230 | + |
| 231 | + GD -> SPSA -> Adam -> NG -> KL -> KFAC; |
| 232 | + } |
| 233 | + |
| 234 | + |
| 235 | +Level 8 - Callbacks Layer |
| 236 | +------------------------- |
| 237 | +**See also the** :doc:`full Callbacks documentation <modules/qmlhc/callbacks/index>` |
| 238 | + |
| 239 | +Provides live monitoring and state adaptation. |
| 240 | + |
| 241 | +- TelemetryLogger |
| 242 | +- MemoryLogger |
| 243 | +- DepthScheduler |
| 244 | + |
| 245 | +.. graphviz:: |
| 246 | + :align: center |
| 247 | + |
| 248 | + digraph Callbacks { |
| 249 | + rankdir=LR; |
| 250 | + node [shape=box, style="rounded,filled", fillcolor="#555555", fontcolor="white"]; |
| 251 | + |
| 252 | + TL [label="TelemetryLogger"]; |
| 253 | + ML [label="MemoryLogger"]; |
| 254 | + DS [label="DepthScheduler"]; |
| 255 | + |
| 256 | + TL -> ML -> DS; |
| 257 | + } |
| 258 | + |
| 259 | + |
| 260 | +Optional Execution Flows (Not Mandatory) |
| 261 | +---------------------------------------- |
| 262 | + |
| 263 | +QML-HCS allows multiple flows; these are optional examples. |
| 264 | + |
| 265 | +**Hypercausal Flow Example** |
| 266 | + |
| 267 | +.. graphviz:: |
| 268 | + :align: center |
| 269 | + |
| 270 | + digraph FlowHC { |
| 271 | + rankdir=LR; |
| 272 | + node [shape=oval, style="filled", fillcolor="#335577", fontcolor="white"]; |
| 273 | + |
| 274 | + X [label="Input"]; |
| 275 | + S [label="State"]; |
| 276 | + K [label="Future Branches"]; |
| 277 | + R [label="Representative"]; |
| 278 | + |
| 279 | + X -> S -> K -> R; |
| 280 | + } |
| 281 | + |
| 282 | + |
| 283 | +**Predictor/Counterfactual Flow Example** |
| 284 | + |
| 285 | +.. graphviz:: |
| 286 | + :align: center |
| 287 | + |
| 288 | + digraph FlowCF { |
| 289 | + rankdir=LR; |
| 290 | + node [shape=oval, style="filled", fillcolor="#773333", fontcolor="white"]; |
| 291 | + |
| 292 | + St [label="State"]; |
| 293 | + LP [label="LinearProjector"]; |
| 294 | + CF [label="Counterfactuals"]; |
| 295 | + Ev [label="Evaluation"]; |
| 296 | + |
| 297 | + St -> LP -> CF -> Ev; |
| 298 | + } |
| 299 | + |
| 300 | + |
| 301 | +**Optimization Loop Example** |
| 302 | + |
| 303 | +.. graphviz:: |
| 304 | + :align: center |
| 305 | + |
| 306 | + digraph FlowOptim { |
| 307 | + rankdir=LR; |
| 308 | + node [shape=oval, style="filled", fillcolor="#555555", fontcolor="white"]; |
| 309 | + |
| 310 | + P [label="Params"]; |
| 311 | + M [label="Model"]; |
| 312 | + L [label="Loss/Metrics"]; |
| 313 | + O [label="Optimizer Step"]; |
| 314 | + |
| 315 | + P -> M -> L -> O -> P; |
| 316 | + } |
| 317 | + |
| 318 | + |
| 319 | +Summary |
| 320 | +------- |
| 321 | + |
| 322 | +QML-HCS is structured according to increasing abstraction: |
| 323 | + |
| 324 | +1. Core Module - structural base |
| 325 | +2. Backends - execution engines |
| 326 | +3. Hypercausal Layer - logical evolution framework |
| 327 | +4. Predictors - deterministic & counterfactual expansion |
| 328 | +5. Loss Layer - coherence and task evaluation |
| 329 | +6. Metrics - statistical and temporal interpretation |
| 330 | +7. Optimization - adaptation and learning |
| 331 | +8. Callbacks - runtime monitoring and control |
| 332 | + |
| 333 | +The diagrams above reflect modular organization, not a required pipeline. |
| 334 | +Users may assemble custom computation flows depending on their needs. |
0 commit comments