Skip to content

Commit 53ce8c6

Browse files
committed
Update physics and add vla wm
Signed-off-by: guillemdb <guillem@fragile.tech>
1 parent 4d09163 commit 53ce8c6

19 files changed

Lines changed: 4880 additions & 81 deletions

File tree

README.md

Lines changed: 78 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,109 @@
11
# Fragile
22

3-
Fragile is a research codebase for the Fractal Gas optimization algorithm and the
4-
Fractal Set data structure, with a Jupyter Book that captures the theory, derivations,
3+
Fragile is a research codebase for the **Fractal Gas** optimization algorithm and the
4+
**Fractal Set** data structure, with a Jupyter Book that captures the theory, derivations,
55
and experiments.
66

7-
## What This Repo Contains
7+
## Install
88

9-
- `src/fragile/`: installable package (core implementation lives in `src/fragile/fractalai/`)
10-
- `docs/`: Jupyter Book (source in `docs/source/`, build output in `docs/_build/`)
11-
- `tests/`: pytest suites
12-
- `examples/`, `media/`, `outputs/`: notebooks, assets, generated artifacts
9+
```bash
10+
uv sync --all-extras # recommended
11+
uv pip install -e . # alternative
12+
uv tool install hatch # one-time, for hatch commands
13+
```
1314

14-
## Code Map
15+
## Dashboards
1516

16-
- `src/fragile/fractalai/core/`: companion selection, fitness, cloning, kinetics,
17-
and the Fractal Set data structure
18-
- `src/fragile/fractalai/experiments/`: simulations, dashboards, convergence studies
19-
- `src/fragile/fractalai/experiments/gauge/`: U(1) and SU(2) gauge symmetry tests
20-
- `src/fragile/fractalai/theory/`: theory utilities and analysis scripts
21-
- CLI entry point: `src/fragile/fractalai/cli.py`
17+
All dashboards launch via `uv run fragile <command>` and serve a Panel app in the browser.
2218

23-
## Install
19+
### Videogames — Atari Fractal Gas
2420

25-
- `uv sync --all-extras` (recommended)
26-
- `uv pip install -e .`
27-
- Tooling: `uv tool install hatch` (one-time, for `uv run hatch ...` commands)
21+
Explore Fractal Gas swarm dynamics on Atari environments (Breakout, Pong, etc.).
2822

29-
## Documentation (Jupyter Book)
23+
```bash
24+
uv run fragile videogames # http://localhost:5006
25+
uv run fragile videogames --port 8080 # custom port
26+
```
3027

31-
- Build: `uv run hatch run docs:build`
32-
- Build and serve: `uv run hatch run docs:docs`
28+
### Robots — DM Control Fractal Gas
3329

34-
## Development
30+
Visualize Fractal Gas on continuous-control MuJoCo tasks (cartpole, humanoid, etc.).
31+
32+
```bash
33+
uv run fragile robots # http://localhost:5007
34+
```
35+
36+
### Physics — QFT Swarm Convergence
37+
38+
Analyse lattice QFT simulations: correlator fits, mass extraction, and convergence plots.
39+
40+
```bash
41+
uv run fragile physics # http://localhost:5007
42+
uv run fragile physics --open # auto-open browser
43+
```
44+
45+
### DL — TopoEncoder Learning
46+
47+
Monitor TopoEncoder training runs: loss curves, topology metrics, atlas visualisations.
48+
49+
```bash
50+
uv run fragile dl # http://localhost:5008
51+
uv run fragile dl --outputs runs/ # custom outputs directory
52+
```
3553

36-
- Tests: `uv run hatch run test:test`
37-
- Doctests: `uv run hatch run test:doctest`
38-
- Lint/format: `uv run hatch run lint:all`
54+
## Training
3955

40-
## QFT Calibration
56+
Train the **TopoEncoder** (Attentive Atlas vs Standard VQ-VAE) directly from the CLI.
57+
All arguments after `--` are forwarded to the training script's argparse.
4158

4259
```bash
43-
python src/experiments/calibrate_fractal_gas_qft.py \
44-
--history-path outputs/fractal_gas_potential_well/20260123_164153_history.pt \
45-
--m-gev 91.1876 \
46-
--hbar-eff 1.0 \
47-
--d 3
60+
uv run fragile train -- --help # show all training options
61+
uv run fragile train -- --epochs 500 --dataset mnist # full run
62+
uv run fragile train -- --epochs 1 --dataset mnist # quick smoke test
4863
```
4964

50-
## QFT Ensemble Validation
65+
Key arguments:
5166

52-
Run multi-trial statistical validation of QFT predictions with full Standard Model gauge group (U(1) × SU(2) × SU(3)):
67+
| Flag | Default | Description |
68+
|------|---------|-------------|
69+
| `--dataset` | `mnist` | Dataset (`mnist`, `fashionmnist`, `cifar10`) |
70+
| `--epochs` | `200` | Training epochs |
71+
| `--batch-size` | `128` | Batch size |
72+
| `--latent-dim` | `64` | Latent dimension |
73+
| `--num-embeddings` | `512` | Codebook size |
74+
| `--use-atlas` | off | Enable Attentive Atlas |
75+
| `--num-charts` | `8` | Number of atlas charts |
76+
| `--output-dir` | `outputs/` | Output directory |
77+
78+
## Documentation (Jupyter Book)
5379

5480
```bash
55-
python src/experiments/run_qft_validation_ensemble.py \
56-
--n-trials 100 \
57-
--n-walkers 1000 \
58-
--n-steps 1000 \
59-
--parallel-jobs 50 \
60-
--use-viscous-coupling \
61-
--nu 0.1 \
62-
--viscous-length-scale 1.0 \
63-
--output-dir outputs/qft_ensemble
81+
uv run hatch run docs:build # build only
82+
uv run hatch run docs:docs # build and serve
6483
```
6584

66-
Quick test (runs in ~30 seconds):
85+
## Development
6786

6887
```bash
69-
python src/experiments/run_qft_validation_ensemble.py \
70-
--n-trials 5 \
71-
--n-walkers 100 \
72-
--n-steps 200 \
73-
--parallel-jobs 2 \
74-
--use-viscous-coupling \
75-
--output-dir outputs/qft_ensemble_test
88+
uv run hatch run test:test # tests
89+
uv run hatch run test:doctest # doctests
90+
uv run hatch run lint:all # lint / format
7691
```
7792

78-
Outputs:
79-
- `ensemble_report.md`: Summary with 95% confidence intervals
80-
- `ensemble_metrics.json`: Full statistics for all metrics
81-
- `plots/`: Correlation lengths, Wilson loops, phase distributions, SU(3) color alignment
93+
## Project Structure
94+
95+
```
96+
src/fragile/
97+
fractalai/ # Fractal Gas algorithm
98+
core/ # companion selection, fitness, cloning, kinetics
99+
videogames/ # Atari dashboard & environments
100+
robots/ # DM Control dashboard & environments
101+
physics/ # lattice QFT simulations & analysis dashboard
102+
learning/ # TopoEncoder, training script & dashboard
103+
docs/ # Jupyter Book (source in docs/source/)
104+
tests/ # pytest suites
105+
```
82106

83107
## License
84108

85109
MIT
86-
87-
/home/guillem/fragiletech/fragile/outputs/qft_calibrated/qft_penalty_thr0p75_pen0p9_m354_ed2p80_nu1p10_N10000_long_history.pt

src/fragile/__main__.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,96 @@ def dl(port, open_browser, outputs):
9999
)
100100

101101

102+
@run.command(
103+
context_settings={"ignore_unknown_options": True, "allow_extra_args": True},
104+
)
105+
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
106+
def train(args):
107+
"""Train the TopoEncoder (Attentive Atlas vs Standard VQ-VAE).
108+
109+
All arguments after 'train' are forwarded to the training script.
110+
Run `uv run fragile train -- --help` for all training options.
111+
"""
112+
import sys
113+
114+
from fragile.learning.topoencoder_mnist import main
115+
116+
original_argv = sys.argv
117+
sys.argv = ["fragile-train", *args]
118+
try:
119+
main()
120+
finally:
121+
sys.argv = original_argv
122+
123+
124+
@run.command(
125+
"vla-train",
126+
context_settings={"ignore_unknown_options": True, "allow_extra_args": True},
127+
)
128+
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
129+
def vla_train(args):
130+
"""Train the TopoEncoder VLA experiment (3-phase pipeline).
131+
132+
All arguments after 'vla-train' are forwarded to the training script.
133+
Run `uv run fragile vla-train -- --help` for all config options.
134+
"""
135+
import sys
136+
137+
from fragile.learning.vla.train import main
138+
139+
original_argv = sys.argv
140+
sys.argv = ["fragile-vla-train", *args]
141+
try:
142+
main()
143+
finally:
144+
sys.argv = original_argv
145+
146+
147+
@run.command(
148+
"vla-unsup",
149+
context_settings={"ignore_unknown_options": True, "allow_extra_args": True},
150+
)
151+
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
152+
def vla_unsup(args):
153+
"""Unsupervised TopoEncoder training on VLA features.
154+
155+
All arguments after 'vla-unsup' are forwarded to the training script.
156+
Run `uv run fragile vla-unsup -- --help` for all training options.
157+
"""
158+
import sys
159+
160+
from fragile.learning.vla.train_unsupervised import main
161+
162+
original_argv = sys.argv
163+
sys.argv = ["fragile-vla-unsup", *args]
164+
try:
165+
main()
166+
finally:
167+
sys.argv = original_argv
168+
169+
170+
@run.command(
171+
"vla-joint",
172+
context_settings={"ignore_unknown_options": True, "allow_extra_args": True},
173+
)
174+
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
175+
def vla_joint(args):
176+
"""Joint encoder + world model training (3-phase pipeline).
177+
178+
All arguments after 'vla-joint' are forwarded to the training script.
179+
Run `uv run fragile vla-joint -- --help` for all training options.
180+
"""
181+
import sys
182+
183+
from fragile.learning.vla.train_joint import main
184+
185+
original_argv = sys.argv
186+
sys.argv = ["fragile-vla-joint", *args]
187+
try:
188+
main()
189+
finally:
190+
sys.argv = original_argv
191+
192+
102193
if __name__ == "__main__":
103194
run()

0 commit comments

Comments
 (0)