Skip to content

Commit f9f6b54

Browse files
Merge pull request #12 from HectorMozo3110/main
docs: improve module index descriptions and update architecture overview
2 parents 21dd761 + 084cde4 commit f9f6b54

14 files changed

Lines changed: 1743 additions & 49 deletions

File tree

docs/architecture.rst

Lines changed: 328 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,334 @@
11
Architecture
22
============
33

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.
67

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.
711

8-
.. warning::
12+
Main Architecture Diagram
13+
-------------------------
914

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.

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"myst_parser",
1818
"sphinx.ext.mathjax",
1919
"sphinxcontrib.programoutput",
20-
"sphinx.ext.intersphinx",
20+
"sphinx.ext.intersphinx",
21+
"sphinx.ext.graphviz",
2122
]
2223

2324
intersphinx_mapping = {

docs/examples/ex_full_hypercausal_Pennylane_demo.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _ex-full-hypercausal-pennylane-demo:
2+
13
====================================================
24
Full Hypercausal System Demo (PennyLane + SPSA + KL)
35
====================================================
@@ -46,6 +48,16 @@ This demo wires the high-level components of **QML-HCS** as follows:
4648
- **Callbacks:** ``MemoryLogger`` (telemetry) and ``DepthScheduler`` (progressive circuit depth).
4749
- **Optimizers:** base **SPSA** (derivative-free) wrapped by a **KL-bounded trust-region** controller.
4850

51+
.. note::
52+
This demonstration combines both abstraction levels introduced in the core
53+
and hypercausal modules. The ``HCNode`` manages the direct backend–policy
54+
interaction for each causal step, while the ``HCModel`` wraps this node to
55+
enable complete sequence execution and optimizer integration.
56+
57+
Readers can refer to the conceptual discussion in
58+
:ref:`HCNode vs HCModel <core-hcnode-hcmodel-note>`
59+
for details on their complementary roles within the QML-HCS framework.
60+
4961
Data & Non-Stationary Drift
5062
===========================
5163
We use a fixed seed input vector ``x0 ∈ ℝ^{qubits}`` and inject a **sinusoidal drift**

docs/getting_started.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ You can verify installation by running:
9696

9797
.. code-block:: bash
9898
99-
python -c "import qmlhcs; print(qmlhcs.__version__)"
99+
python -c "import qmlhc; print(qmlhc.__version__)"
100100
101101
This method is ideal for end-users or production deployments where the source code is not being modified, but the full library functionality and API features remain available for direct use.
102102

@@ -329,7 +329,6 @@ The QML-HCS repository follows a clean modular layout:
329329
│ └── examples.rst
330330
331331
├── pyproject.toml # Build metadata (PEP 621)
332-
├── Makefile # Build, test, and docs automation
333332
└── README.md # Project overview and installation guide
334333
335334
@@ -456,7 +455,7 @@ To view a detailed coverage report directly in your browser, run:
456455
25 files skipped due to complete coverage.
457456
Required test coverage of 75.0% reached. Total coverage: 92.03%
458457
53 passed in 0.32s
459-
(.venv) (base) mozoh@pop-os:~/Desktop/P1/qml-hcs$
458+
460459
461460
A 100% test success and a coverage above 90% confirm that the QMLHC package is correctly installed and all major modules are functioning as expected.
462461

0 commit comments

Comments
 (0)