Computing and data
From CPU experiments to 3D campaigns: data format, results catalog, deployment on a cloud VM or a Slurm cluster
The experiments in the report run on an ordinary CPU. The thesis plan calls for more: campaigns of tens to hundreds of 3D simulations, GPU training runs, and a record of every result. This page describes the ready-to-use infrastructure of the repository: the Python package milady and the infra/ folder. You rent a machine, run git clone, and a single command installs everything.
What has been tested The whole pipeline has run end to end on a machine without a GPU (laptop, full Docker stack, Slurm templates executed with a simulated scheduler): the suite of 68 automated tests passes (66 passed and 1 skipped when measured with PostgreSQL and MinIO; the anchor test, added since then, also passes). What could not be run: a GPU card, a real Slurm cluster, Apptainer, and a VM rented from a provider. The last section details what has been verified and what remains to be verified on site.
Getting started
Three targets share the same code, pinned dependencies, and the same data format; the VM and the cluster also use the same software image.
| Target | What for | Main command |
|---|---|---|
| A. Cloud VM with GPU, rented by the hour | 3D campaigns and training, without a computing center | sudo infra/deploy/bootstrap_vm.sh |
| B. Slurm cluster (Jean Zay, regional HPC center) | large campaigns, multi-node training | python -m milady.sweep … --scheduler slurm |
| C. Laptop, no GPU | development, tests, small grids | make setup && make smoke |
On a cloud VM. Create an Ubuntu 22.04 or 24.04 VM, preferably with the provider’s “GPU” image (NVIDIA driver preinstalled), a 100 to 200 GB disk, and a firewall that opens only SSH. Then:
ssh ubuntu@VM_IP_ADDRESS
git clone https://github.com/knoel99/milady-2027.git && cd milady-2027
sudo infra/deploy/bootstrap_vm.shThe script, which can safely be rerun, installs Docker and, if a GPU is present, the NVIDIA Container Toolkit; it generates random passwords in a .env file that is never committed; it builds the image (milady:gpu, CUDA 12.6, or milady:cpu); it starts the PostgreSQL database, the MinIO object storage, and the MLflow server; finally, it runs an end-to-end test (tiny 3D simulation, file, catalog, one training iteration, evaluation). Measured duration without a GPU, with Docker already installed: 3 minutes, including the image build. You can also pass the file infra/deploy/cloud-init.yaml when creating the VM, without logging into it, or deploy from your laptop with infra/deploy/deploy_remote.sh ubuntu@IP.
Then, from the VM:
make sweep CONFIG=infra/configs/stage2_abc3d.yaml # simulation campaign
make train CONFIG=infra/configs/train_fm3d.yaml # training (all GPUs, torchrun)
make eval CONFIG=infra/configs/train_fm3d.yaml # evaluation, results to the catalogThe web interfaces (MLflow, MinIO console, JupyterLab) listen only on the VM: you reach them through an SSH tunnel, ssh -N -L 5000:localhost:5000 -L 9001:localhost:9001 -L 8888:localhost:8888 ubuntu@IP.
On a Slurm cluster. The GPU image is converted into an Apptainer image (make image-gpu && make sif), then copied to the cluster. Each simulation of a campaign is one element of a job array (one GPU each); training launches one torchrun per node. The compute nodes of Jean Zay have no Internet access: the catalog is then an SQLite file on $WORK; the simulations are subsequently registered in the central database from their MFF files (python -m milady.catalog ingest), under the same identifiers. The models, evaluations, and jobs of the SQLite catalog are not transferred by this command. The guide README-slurm.md gives the options specific to Jean Zay, checked against the IDRIS documentation.
On a laptop. make setup creates a virtual environment with pinned versions (68 s measured), and make smoke RUN=local runs the same end-to-end test with an SQLite catalog and local files (4 s).
The processing pipeline
A campaign described in a YAML file becomes simulations, then files, then a dataset, models, and evaluations. Each step writes its record to the catalog under a unique identifier (UUID); the simulations, their files, and the models also carry the code commit (with a -dirty suffix if the working tree had been modified).

stage2_tg3d: 4 × 3 (Re, Pm) points, 64^3 grid) goes through seven modules; every stage writes its record to the catalog, fields and checkpoints go to object storage, and a simulation carries the same UUID in its file and in the catalog, so the simulations part of the catalog can be rebuilt from the files (ingest). The split of stage 5 follows train_fm3d.yaml (validation Re = 100, Pm = 1; test Re = 50, Pm = 2); the spectrum of stage 7 is illustrative. b, The same roles on three targets; on the cluster, whose nodes have no Internet access, files are copied to S3 storage and then ingested into PostgreSQL, while models and evaluations stay in the cluster’s SQLite. Diagram drawn with the schematic-figure skill; sources in figures/architecture/.| Step | Module | What is produced | Where it is recorded |
|---|---|---|---|
| 1. Campaign | YAML file in infra/configs/ |
grid of physical parameters (Re, Rm, Pm…) | campaign table (YAML of the first launch; each launch keeps a frozen copy in data/sweeps/) |
| 2. Launch | milady.sweep |
one task per grid point: locally, one process per simulation; with Docker, one container per simulation; on a cluster, a Slurm job array | simulation and job tables |
| 3. Simulation | milady.sim (3D MHD solver, PyTorch) |
fields (\mathbf{u}, \mathbf{B}) and diagnostics | MFF file; diagnostic table |
| 4. Storage | milady.storage |
file {campaign}/{uuid}/fields.h5, never modified in normal use (--force rewrites it, and its SHA-256 checksum is then updated in the catalog), on S3, MinIO, or disk |
file table (SHA-256 checksum, size) |
| 5. Dataset | milady.train.data (at the first training run, following data.auto_dataset; stored by milady.catalog) |
selection of simulations and split into training, validation, and test sets | dataset and dataset_member tables |
| 6. Training | milady.train.fm3d |
conditional flow matching on vector potentials; checkpoints | model table; MLflow (curves, hyperparameters) |
| 7. Evaluation | milady.eval |
statistical and physical metrics of the generated fields | evaluation table; v_eval_summary view |
Since the simulation carries the same UUID in the file and in the catalog, the simulation part of the catalog (simulations, files, diagnostics) can be rebuilt or merged from the files alone (parameters, code, commit, file, diagnostics; the campaign name is given with --campaign, and the compute time, resources, and campaign YAML are not restored); datasets, models, and evaluations, by contrast, exist only in the catalog. This is what makes it possible to work on a cluster without network access.
The following interactive diagram walks through the same pipeline target by target: pick a target, then click a stage to see what it does, what it writes and the exact command on that target.
The data format
Each simulation produces a file in the MFF format (MilaDy Field Format): an HDF5 file that follows exactly the convention of The Well (Ohana et al., NeurIPS 2024), the reference collection of physics simulations for machine learning, and adds metadata prefixed with milady_.
fields.h5
├── attributes: dataset_name, grid_type, n_spatial_dims, n_trajectories, simulation_parameters…
│ milady_uuid, milady_code, milady_git_commit, milady_parameters (JSON)…
├── dimensions/ time, x, y, z
├── boundary_conditions/ periodic conditions along each axis
├── scalars/ physical parameters (Re, Rm, Pm…)
├── t0_fields/ scalar fields
├── t1_fields/ u, B: (trajectories, time, x, y, z, components)
├── milady_diagnostics/ energies, dissipations, helicities, growth rates, max |∇·u|, max |∇·B|
└── milady_spectral/ Fourier coefficients of the fields (periodic domains, optional)
Following The Well makes the data readable by the reference loaders and models of the community: we checked, by replaying the HDF5 accesses of the WellDataset loader (the_well 1.2.0) without running the package itself, that a 3D MFF file is read back identically. The milady_* attributes are invisible to a The Well reader and are validated by a JSON schema. A Zarr variant, with the same hierarchy, makes it possible to read a chunk of a file on S3 without downloading it. An extension is planned for the outputs of SFEMaNS (azimuthal Fourier modes on a meridional finite-element mesh), without destructive interpolation. The validation function detects corrupted files: the 18 corruptions tested (types, shapes, non-finite values, identifiers…) are all flagged, a NaN in the middle of a trajectory only by the full check (validate --full). Full specification: docs/specs/data-format.md. Figure 2, in the section on the solver, links each part of the file to its column in the catalog.
The results catalog
The results of a thesis are relational: campaign, simulations, files, datasets, models, evaluations. They are stored in a PostgreSQL database (locally or on the VM), or in an SQLite file with the same schema on a laptop or on a cluster without network access.
| Table | Contents |
|---|---|
campaign |
name, description, full YAML configuration |
simulation |
physical parameters (indexed JSON), status, machine, GPUs and cores, duration, code commit |
file |
URI, SHA-256 checksum, size, number of snapshots |
diagnostic |
time series of the physical diagnostics |
dataset, dataset_member |
versioned datasets and their split |
model |
hyperparameters, dataset, MLflow run, checkpoint, commit |
evaluation |
metric, value, parameters, seed, number of samples |
job |
scheduler identifier (Slurm, Docker), status, logs |
The catalog is queried in SQL or from the command line. For example, the compute hours per campaign (GPU hours only if each simulation had its own GPU, as in a Slurm array; on a VM, make sweep runs up to resources.max_parallel simulations at once on the same GPU):
SELECT c.name, round(CAST(sum(s.wall_time_s * CASE WHEN s.n_gpus > 1 THEN s.n_gpus ELSE 1 END) / 3600.0 AS NUMERIC), 1) AS heures_gpu
FROM simulation s JOIN campaign c ON c.id = s.campaign_id
WHERE s.status = 'done' GROUP BY c.name ORDER BY heures_gpu DESC;and, from the command line, python -m milady.catalog sims --campaign stage2_abc3d --param Rm__gt=8 lists the simulations of a campaign above a threshold. The heavy files live in object storage with an S3 API: MinIO on the VM, or a provider’s bucket so that they survive the deletion of the VM. Training runs are tracked by MLflow, self-hosted, and linked to the catalog through the run identifier.
The solver, the campaigns, and training
Solver. milady.sim.mhd3d solves periodic 3D incompressible MHD with a pseudo-spectral method in PyTorch, on CPU or GPU: fourth-order Runge–Kutta with an integrating factor, dealiasing with the 2/3 rule, Leray projection of \mathbf{u} and of \mathbf{B}, so that both divergences remain at machine precision. It has two modes: dynamic (coupled Navier–Stokes and induction equations, ABC, Taylor–Green, or random forcing) and kinematic (imposed flow, as in experiment E3). Several trajectories advance together on the same GPU. The energy balance \mathrm{d}(E_u + E_B)/\mathrm{d}t = \text{injection} - \nu\langle|\boldsymbol\omega|^2\rangle - \eta\langle|\mathbf{j}|^2\rangle is checked by the tests. On the development CPU, one step takes 0.08 s at 64^3 in dynamic mode (2 threads); no GPU timing is given, for lack of a GPU, and the command python -m milady.sim.mhd3d bench --device cuda measures it on site.

milady.sim.mhd3d: curls taken in Fourier space, products \mathbf{u}\times\boldsymbol{\omega} + \mathbf{j}\times\mathbf{B} and \mathbf{u}\times\mathbf{B} in physical space, back to Fourier space, 2/3 dealiasing, Leray projection of the momentum term, curl of the induction term; the Lawson RK4 integrates the diffusion exactly, with four right-hand-side evaluations per step. The mode planes show 11 points per direction (actual cutoff |m| \le 21 at 64^3). b, One simulation of stage2_tg3d over time: diagnostics from t = 0, 40 snapshots over the kept window, checkpoints and resume after SIGTERM (example position). c, The MFF file follows The Well’s convention (grey) and adds milady_* attributes and groups; the identifier, parameters, commit and diagnostics have their column in the catalog.Ready-made campaigns. They prepare the tiers of the thesis plan at reduced scale: stage1_mhd2d reuses the E2 dataset (32^2, fixed \nu, 11 values of \eta), not yet the 128^2 plan on an 8 × 8 (\nu, \eta) grid; the 3D campaigns keep 20 to 40 snapshots per simulation, against about 5000 per point planned for tier 2.
| Campaign | Contents |
|---|---|
stage1_mhd2d |
forced 2D MHD from experiment E2: 11 values of \eta, 16 trajectories per value |
stage2_abc3d |
ABC kinematic dynamo at 64^3: Rm from 4 to 40 (37 simulations), magnetic eigenmodes |
stage2_tg3d |
Taylor–Green forced 3D MHD at 64^3: Re \in \{25, 50, 100, 200\} and Pm \in \{0.5 ; 1 ; 2\} (12 simulations) |
train_fm3d |
flow matching of the Taylor–Green fields conditioned on (Re, Pm), vector potentials truncated at |\mathbf{m}| \le 8, exact \mathbf{B} \to -\mathbf{B} symmetry |
Training. milady.train.fm3d carries over to 3D the choices validated by the experiments: vector potentials in the Coulomb gauge (zero divergence by construction, like variant V4 of E2), a velocity field equivariant under \mathbf{B} \to -\mathbf{B} (variant C of E1), and optional fine-tuning with an unbiased estimate of the stationarity loss. Experiment E1 showed that this fine-tuning can diverge when started from a biased model: it is launched only from an already good model, with two safeguards added for this reason (disabled by default: they stay at 0 unless set), an anchor to the starting weights (stationarity.anchor) and a gradual ramp-up of the weight \beta (stationarity.beta_warmup), and the spread of the balances must be monitored: the per-sample standard deviation of the balances is not yet computed automatically, because the evaluation records only the mean residuals. The same code runs on one GPU or on several nodes (DDP), resumes after an interruption from its last checkpoint last.pt when restarted under the same run name (--run-name, or --resume <uri>; automatically under Slurm only for a job requeued with the same ID), and logs to MLflow.
Costs
Prices change with the provider, the region, and the rental mode: the guide gives no prices, but a method.
\text{cost} \approx \sum_{\text{tasks}} \text{duration (h)} \times \text{number of GPUs} \times \text{hourly price of the instance} \;+\; \text{storage} \;+\; \text{outbound data} .
First measure a single representative simulation; its duration is recorded in the catalog and extrapolated to the whole campaign. As for memory, a state (\mathbf{u}, \mathbf{B}) in single precision takes 6 \times N^3 \times 4 bytes, i.e., about 0.4 GB at 256^3; the peak memory measured on CPU is about 15 times this state at 128^3 (717 MB), which comes to about 6 GB at 256^3 and 48 GB at 512^3: a 24 GB GPU is enough at 256^3, and an 80 GB GPU is needed at 512^3 (an estimate to be checked with nvidia-smi). Three rules reduce the bill: preemptible instances for the simulation arrays, which are independent and can be restarted; a VM deleted as soon as it is no longer in use, after a backup (make backup); and data in a bucket rather than on the VM’s disk.
What is tested, what remains to be verified
| Verified on the development machine (no GPU) | Measured duration |
|---|---|
laptop installation (make setup) and end-to-end test (make smoke RUN=local) |
68 s and 4 s |
| CPU Docker image built from scratch; PostgreSQL, MinIO, MLflow stack healthy | 2 min; 14 s |
| end-to-end test in the Docker stack: objects in MinIO, MLflow run completed, catalog populated | 10 s |
installation by bootstrap_vm.sh --cpu (Docker already present) on a fresh copy of the repository, then a rerun |
3 min; 33 s |
automated tests (make test), with PostgreSQL and MinIO |
66 passed, 1 skipped (before a 68th test was added, which also passes) |
| Slurm templates executed with a simulated scheduler, including stopping at the end of the time limit and resuming | a few seconds |
MFF file read back by replaying the HDF5 accesses of The Well’s loader; backup produced by make backup (pg_dump dumps and bucket mirror) |
— |
Still to be verified on site, at the first rental: the full GPU image and the NVIDIA Container Toolkit, the solver and training on CUDA (and on several GPUs), a real Slurm with Apptainer, the installation of Docker on a fresh Ubuntu, the providers’ S3 buckets, and the campaigns at their real size. The deployment guide (§ 11 and 12) gives the details.
Further reading
- Deployment guide: cloud VM, laptop, backup, costs, troubleshooting, security.
- Architecture: data flows, technical choices, provenance.
- Slurm and Jean Zay guide.
- MFF format and infrastructure contract.
- Code:
milady/, configurations:infra/configs/, tests:tests/.