Schema → resolve → run¶
Every jaxrens run -c config.yaml invocation flows through three
layers. Each layer has one job, and the boundaries are enforced by
the type system:
Schema — pydantic models in
jaxrens.cli.schema.*. Validates the YAML shape and ranges. Does not import JAX.Resolver — pure Python in
jaxrens.cli.resolve. Builds the runtime objects (backend instance, walker positions, move descriptors, per-replica ensemble params). Imports JAX, does not import pydantic.Core — the library itself (
jaxrens.sampling,jaxrens.state,jaxrens.backends, …). Consumes frozen dataclasses (NSConfig,MoveConfig) and JAX arrays. Imports JAX, does not import pydantic or yaml.
flowchart TB
subgraph L1["Layer 1 — wire format (YAML → pydantic)"]
direction LR
Y["config.yaml"] --> RC["RootSpec<br/>(pydantic)"]
end
subgraph L2["Layer 2 — resolver (pydantic → runtime objects)"]
direction TB
RES["resolve(root)"]
RES --> RO["ResolvedConfig<br/>(carries a batcher)"]
end
subgraph L3["Layer 3 — core (dataclass → NS state pytrees)"]
direction LR
RFC["run_from_config"]:::layer3
RMG["run_multi_gpu_from_config"]:::layer3
RN["run_ns"]:::layer3
RMGC["run_ns_multi_gpu"]:::layer3
end
RC --> RES
RO -->|"batcher = SingleRun()"| RFC --> RN
RO -->|"batcher = PmapVmapRuns(G, P)"| RMG --> RMGC
classDef layer3 fill:#e7f1fb,stroke:#666
What each layer owns¶
Concern |
Layer |
Where |
|---|---|---|
YAML key names, types, defaults |
Schema |
|
Cross-field validators (“XRENS requires composition_targets”) |
Schema |
|
Unit conversion ( |
Schema |
|
Interval-unit scaling ( |
CLI / Resolver |
|
“Build a MACE backend instance” |
Resolver |
|
“Compute initial walker energies at the right ensemble scale” |
Resolver |
|
Device-topology derivation from |
Resolver |
|
Species mapping to backend z-table |
Resolver |
|
Pick |
Core |
|
|
Core |
|
Two asymmetries worth knowing:
Schema doesn’t import JAX.
jaxrens validate --parse-only -c config.yamlruns pydantic-only. The resolver itself splits in two:validate(the default) runs only the plan phase — topology, divisibility, path existence, geometry bounds — whilevalidate --fullgoes on to build the backend and place walkers.Core doesn’t import pydantic.
run_ns(positions, types, …)takes arrays and aNSConfigdataclass. Tests intests/test_nested_sampling.pynever touch the schema layer, so the core is testable without a YAML round-trip.
The unified entry point¶
The resolver exposes one public function:
def resolve(root: RootSpec) -> ResolvedConfig: ...
Whether the YAML describes a single NS run or 16 replicas across 4
GPUs, the return type is the same — a single ResolvedConfig that
carries a batcher field describing the topology. The CLI inspects
that field to pick the right runtime dispatcher:
flowchart LR
Y["config.yaml"] --> RC["RootSpec"]
RC --> RES["resolve(root)"]
RES --> RC2["ResolvedConfig"]
RC2 -->|"batcher = SingleRun()<br/>n_total = 1"| RFC["run_from_config<br/>→ run_ns"]
RC2 -->|"batcher = PmapVmapRuns(G, P)<br/>n_total = G·P"| RMG["run_multi_gpu_from_config<br/>→ run_ns_multi_gpu"]
n_total comes from whichever YAML list implies it:
ensemble.pressure (NPT), inter_re.composition_targets (XRENS),
or inter_re.chemical_potentials (semi-grand). See
Replica topology and inter-RE for the full derivation. When n_total == 1 the
batcher is SingleRun(); otherwise it is PmapVmapRuns(G, P) with
G = max(1, len(jax.local_devices())) clamped to n_total and
P = n_total // G.
Inside the resolver¶
resolve is a thin dispatcher: it derives the topology and delegates
to one of two private branches (_resolve_single_replica or
_resolve_multi_replica). Both branches do the same three jobs —
derive the runtime topology, lay out per-walker initial state, and
price the initial energies on the right ensemble scale — they just
differ in where the parallelism lives.
Both paths walk the same per-iteration setup: look up the iteration’s
pressure, build the base Hamiltonian (model + soft-core term, if
configured), add EnsembleTerm(pressure=P) to it (the rejection-mode
ceiling check
inside _sample_per_walker_positions needs ensemble-corrected
energies), then dispatch the right _resolve_init mode helper. Mode
helpers return structural init only (positions / cells / types /
restart state); finalize is always the caller’s responsibility.
The paths then diverge:
Single-replica. After
_validate_cells,_resolve_single_replicacalls_finalise_initial_energies_and_countsimmediately on its single-replica arrays withbatcher=SingleRun().Multi-replica. The structural-init step runs once per replica in a tight Python loop (cheap, no JIT compiles), stacks the resulting
(K, …)arrays into(n_total, K, …), then reshapes to(G, P, K, …). Before finalize the resolver adds a second ensemble term — onebase.with_terms(EnsembleTerm(pressure=0.0))shared by all replicas; the per-replica pressure flows in through theensemble_params={"pressure": p}kwarg on the vmap axis. Then the same_finalise_initial_energies_and_countshelper is called once withbatcher=PmapVmapRuns(G, P).
The helper body is identical between paths — only the batcher and
the per-replica pressures argument differ.
Structural init — _resolve_init¶
Before showing the full resolve flow, here is _resolve_init
(resolve.py:604) in isolation. Both branches call it the same way
— the only difference is how many times it runs (once for
single-replica, n_total times in the multi-replica loop, each with
its own seed and per-replica EnsembleTerm). The four
modes are mutually exclusive (the init spec must set exactly one
of the four discriminator fields) and all converge on
_validate_cells; none of them prices energies — that is the
caller’s job after _resolve_init returns.
%%{init: {"layout": "elk"}}%%
flowchart LR
subgraph INIT["_resolve_init"]
direction LR
IN["init_spec, n_live, seed,<br>energy_backend, cell_cfg"]
MODE{"init spec field set"}
MA["A: start_species<br>_resolve_init_species<br>(sample cell + positions from priors)"]
MB["B: start_config_file<br>_resolve_init_config_file<br>(load founder, replicate to n_live)"]
MC["C: start_walker_set<br>_resolve_init_walker_set<br>((n_live, N, 3) verbatim)"]
MD["D: restart_file<br>_resolve_init_restart<br>(checkpoint → RestartBundle)"]
VAL["_validate_cells<br>(volume/atom + aspect-ratio bounds)"]
OUT["ResolvedInit(<br>positions, cells, types,<br>symbol_map, restart_state,<br>energies=None, counts=None)"]
IN --> MODE
MODE -- A --> MA --> VAL
MODE -- B --> MB --> VAL
MODE -- C --> MC --> VAL
MODE -- D --> MD --> VAL
VAL --> OUT
end
classDef pyBox fill:#f5f5f5,stroke:#888,color:#222
classDef decision fill:#eef5ff,stroke:#1565c0,color:#222
classDef initFrame fill:#e0f2f1,stroke:#00897b,stroke-width:2px,color:#004d40
IN:::pyBox
OUT:::pyBox
MA:::pyBox
MB:::pyBox
MC:::pyBox
MD:::pyBox
VAL:::pyBox
MODE:::decision
class INIT initFrame
The energy_backend argument is the only place the caller’s
ensemble term leaks in — rejection-mode initialization uses it for
the ceiling check inside _sample_per_walker_positions. Grid-mode
ignores it. The four mode helpers return structural init only
(energies=None, counts=None); pricing them is the next
subroutine, _finalise_initial_energies_and_counts.
Initial-energy pricing — _finalise_initial_energies_and_counts¶
The second subroutine called from both branches (resolve.py:333).
It is the resolver’s only JIT-compiled work and the only place
initial energies are priced. The batcher argument is the seam
through which multi-GPU dispatch enters the resolver:
SingleRun() → plain jax.jit; PmapVmapRuns(G, P) →
jax.jit(jax.shard_map(jax.vmap(...))). Both branches pass the backend’s
ladder / offset so the chosen init_bucket matches what
burn-in and the NS step will compile against (same JIT cache slot).
%%{init: {"layout": "elk"}}%%
flowchart LR
subgraph FIN["_finalise_initial_energies_and_counts"]
direction LR
FN["backend, positions, types, cells,<br>batcher, ladder, offset,<br>pressures=None"]
HAS{"backend has<br>max_neighbors_for?"}
CNT["counts = batcher.wrap_for_batch(<br>vmap(max_neighbors_for))(positions, cells)"]
BUCK["init_bucket =<br>_choose_starting_bucket(counts, ladder, offset)"]
EN["energies = batcher.wrap_for_batch(<br>vmap(backend(…, init_bucket)))<br>(positions, cells [, ensemble_params])"]
EN0["energies = batcher.wrap_for_batch(<br>vmap(backend(…, 0)))<br>(positions, cells [, ensemble_params])"]
OUTF["(energies, counts)"]
FN --> HAS
HAS -- yes --> CNT --> BUCK --> EN --> OUTF
HAS -- no --> EN0 --> OUTF
end
classDef pyBox fill:#f5f5f5,stroke:#888,color:#222
classDef decision fill:#eef5ff,stroke:#1565c0,color:#222
classDef finFrame fill:#fff7e0,stroke:#a07000,stroke-width:2px,color:#5a4000
FN:::pyBox
OUTF:::pyBox
CNT:::pyBox
BUCK:::pyBox
EN:::pyBox
EN0:::pyBox
HAS:::decision
class FIN finFrame
pressures is only passed in by the multi-replica branch, where
it is a (G, P) array — each replica’s NPT scalar — fed into the
ensemble_params kwarg on the vmap axis. The single-replica
branch’s per-call pressure is already baked into its
init_backend (one base.with_terms(EnsembleTerm(P))), so the
kwarg is None.
The full resolve flow¶
In the diagram below, the teal boxes (_resolve_init(...))
and the amber boxes (_finalise_initial_energies_and_counts)
are placeholders for the two mini-diagrams above. The matching
colors are deliberate — the call site in the main flow links
visually to the subroutine that drew that color.
%%{init: {"layout": "elk"}}%%
flowchart TB
%% --- resolve(root) prelude (resolve.py:1432) ---
RS["RootSpec<br>(validated pydantic)"]
SCALE["_apply_interval_units(root)<br>(idempotent — CLI already scaled)"]
DRA["_derive_replica_axes(root)<br>→ (n_total, n_gpu, n_per_gpu, params_per_run)"]
GUARD{"init.restart_file set<br>AND n_total > 1?"}
GE["raise ValueError"]
BR{"n_total == 1?"}
RS --> SCALE --> DRA --> GUARD
GUARD -- yes --> GE
GUARD -- no --> BR
%% --- single-replica branch (resolve.py:918) ---
subgraph S["_resolve_single_replica"]
direction TB
S1["base_backend = Hamiltonian(root.backend.build_backend())<br>(+ SoftCoreTerm if configured)"]
S2["init_backend =<br>base.with_terms(EnsembleTerm(P)) if P else base<br>(P from ensemble_params)"]
subgraph S3box["_resolve_init"]
S3in["root.init, n_live,<br>seed=root.run.seed,<br>init_backend, cell_cfg"]
end
subgraph S4box["_finalise_initial_energies_and_counts"]
S4in["init_backend, positions, types, cells,<br>batcher=SingleRun(),<br>ladder, offset"]
end
S5["return ResolvedConfig(<br>batcher=SingleRun(),<br>ensemble_params_per_run=(eparams,))"]
S1 --> S2 --> S3in --> S4in --> S5
end
%% --- multi-replica branch (resolve.py:1181) ---
subgraph M["_resolve_multi_replica"]
direction TB
M1["batcher = PmapVmapRuns(n_gpu, n_per_gpu)"]
M2["base_backend = Hamiltonian(root.backend.build_backend())<br>(+ SoftCoreTerm; once, outside the loop)"]
M3(["for r in range(n_total)"])
M3a["P_r = params_per_run[r].get('pressure')<br>per_run_backend =<br>base.with_terms(EnsembleTerm(P_r)) if P_r else base"]
subgraph M3box["_resolve_init"]
M3bin["root.init, n_live,<br>seed=root.run.seed + r,<br>per_run_backend, cell_cfg"]
end
M4["jnp.stack per-replica init along axis 0<br>→ (n_total, K, …)"]
M5["reshape → (G, P, K, …)"]
M6["finalize_backend =<br>base.with_terms(EnsembleTerm(0.0)) if any_pressure else base"]
subgraph M7box["_finalise_initial_energies_and_counts"]
M7in["finalize_backend,<br>(G,P,K,N,3) positions, types, (G,P,K,3,3) cells,<br>batcher=PmapVmapRuns,<br>ladder, offset, pressures=(G,P)"]
end
M8["reshape (G,P,K,…) back to (n_total, K, …)<br>(downstream dispatcher input)"]
M9["return ResolvedConfig(<br>batcher=PmapVmapRuns(G,P),<br>ensemble_params_per_run=tuple(params_per_run))"]
M1 --> M2 --> M3
M3 --> M3a --> M3bin
M3bin -.->|"replica r built;<br>loop continues"| M3
M3 -->|"all n_total replicas built"| M4 --> M5 --> M6 --> M7in --> M8 --> M9
end
BR -- yes --> S1
BR -- no --> M1
classDef pyBox fill:#f5f5f5,stroke:#888,color:#222
classDef initFrame fill:#e0f2f1,stroke:#00897b,stroke-width:2px,color:#004d40
classDef finFrame fill:#fff7e0,stroke:#a07000,stroke-width:2px,color:#5a4000
classDef decision fill:#eef5ff,stroke:#1565c0,color:#222
S1:::pyBox
S2:::pyBox
S3in:::pyBox
S4in:::pyBox
S5:::pyBox
M1:::pyBox
M2:::pyBox
M3a:::pyBox
M3bin:::pyBox
M4:::pyBox
M5:::pyBox
M6:::pyBox
M7in:::pyBox
M8:::pyBox
M9:::pyBox
GUARD:::decision
BR:::decision
class S3box initFrame
class M3box initFrame
class S4box finFrame
class M7box finFrame
Reading the diagram:
The prelude (
_apply_interval_units→_derive_replica_axes→ restart guard → topology branch) is the first ~30 lines ofresolve(). After that the two branches are entirely separate.Inner step boxes are gray — same as every other resolver step. The two subroutines that have their own mini-diagrams above are shown as colored wrappers around the gray call-args box: teal frame for
_resolve_init, amber frame for_finalise_initial_energies_and_counts. The wrapper’s name matches the mini-diagram heading so the reader can drill in._resolve_single_replicais linear: build backend → add ensemble term → init (teal wrapper) → finalize (amber wrapper) → return._resolve_multi_replicahas the per-replica Python loop on the inside (build_backendruns once outside it; theEnsembleTermand_resolve_init(teal wrapper) run n_total times); then the stack-reshape-finalize (amber wrapper)-reshape chain produces the final(n_total, K, …)arrays.The amber
_finalise_…wrapper is the only JIT-compiled work in the resolver. Everything else is plain Python shuffling pydantic specs into dataclasses.
Topology derivation¶
_derive_replica_axes reads three replica-axis hints from the
RootSpec — ensemble.pressure length, inter_re.composition_targets,
inter_re.chemical_potentials — checks they agree, looks up
jax.local_devices() to pick n_gpu, and demands
n_total % n_gpu == 0. The output is the (n_gpu, n_per_gpu) shape
that the rest of the runtime (shard_map(vmap(...)), AdaptationManager,
InterREManager) inherits. Single-replica path skips most of this —
its batcher is SingleRun() and there is no replica axis.
Interval-unit scaling¶
Every “do this every N iterations” knob in the config — how often to
write a frame, flush the log, check termination, attempt a replica
swap, re-tune the step size — is counted in NS iterations by default.
But a single NS iteration replaces just n_cull of the n_live
walkers, so the natural cadence for most of these is one walker
sweep (n_live culled walkers, i.e. n_live / n_cull iterations —
roughly “every walker touched once”), not one iteration. The catch is
that the number of iterations per sweep depends on n_live and
n_cull, so an interval tuned for n_live=500 is off by 4× at
n_live=2000, and by 10× once n_cull goes from 1 to 10.
interval_units removes that coupling. It is a single top-level key
with two modes:
absolute(default) — interval fields are raw NS iteration counts. What you write is what the runtime sees.per_walker— interval fields are walker-sweeps. The resolver multiplies each byrun.n_live / run.n_cull, so the same YAML keeps the same physical cadence (the same prior-mass compression per interval) no matter whatn_liveandn_cullyou run at.
run:
n_live: 1000
interval_units: per_walker # everything below is in sweeps now
output:
info_interval: 1 # → log every 1000 iterations
traj_interval: 10 # → dump a frame every 10 sweeps = 10 000 iters
snapshot_interval: 0.001 # → 0.001 × 1000 = every 1 iteration
With n_cull: 10 added to run:, the same YAML resolves to a tenth of
these iteration counts (info_interval: 1 → every 100 iterations, each
culling 10 walkers), so every interval still spans 1000 dead points.
The resolver applies this in _apply_interval_units(root), which
scales these fields (and leaves an unset None, e.g. an omitted
run.max_iterations, untouched):
Section |
Fields |
|---|---|
|
|
|
|
|
|
|
|
|
|
Two practical notes:
Rounding. Each scaled value is rounded to the nearest int and clamped to
>= 1, so a fractional sweep likesnapshot_interval: 0.001resolves to a real iteration count and never collapses to 0. This is why the interval fields acceptint | floatin the schema.Restart. Because the unit only changes how the YAML is read, a restart config may switch
interval_unitsfreely — the restart validator scales both sides to absolute iterations before comparing (see Restart, resume, and the output-dir lifecycle).
Implementation detail: the CLI calls _apply_interval_units early —
in _cmd_run, right after _load_and_validate — and then flips
root.interval_units to "absolute". The resolver’s own call at the
top of resolve() therefore becomes a no-op second pass (factor=1).
Direct callers of resolve (tests, scripts) that bypass the CLI still
get correct scaling automatically.
The four init modes (reference)¶
_resolve_init is the router shown in the mini-diagram above. The
init spec must set exactly one of:
Mode |
YAML key |
Helper |
What it does |
|---|---|---|---|
A |
|
|
Parse species string (“Si16”), sample cell + positions from priors |
B |
|
|
Load a single founder structure, replicate to |
C |
|
|
Load a pre-computed |
D |
|
|
Resume from an NS checkpoint; carries |
_validate_cells enforces volume-per-atom and aspect-ratio bounds —
fail fast on a bad input rather than later in the NS loop with a
misleading “walker produced invalid cell” message. Pricing the
energies is the caller’s job, not the mode helper’s:
_resolve_single_replica does it on the single-replica arrays it
just built; _resolve_multi_replica does it once on the stacked
(G, P, K, …) pytree after the per-replica loop finishes. Mode
helpers therefore see exactly one concern (place the walkers) and
never have to know which path called them.
Mode D (restart) is incompatible with multi-replica topologies — the
resolver raises a ValueError when restart_file is set alongside a
replica-axis list. Restart is single-NS only by design; the
checkpoint carries one trajectory, not N.
Why the consolidated finalize matters¶
The mini-diagram earlier shows what _finalise_initial_energies_and_counts
does. This section is the why — the three optimisations the
helper earns by being the single shared entry point for both
branches:
Bucket-aware compile. For backends with bucketed kernel dispatch (MACE, NeuralIL — see Backends and ensembles), the helper first computes per-walker neighbor counts via
backend.max_neighbors_for(geometry-only, no energy compile), then picksinit_bucket = _choose_starting_bucket(counts, ladder, offset)— the same bucket the NS step’s bucket-escalation logic would land on. Both resolution paths now passladder = backend.max_neighbors_listandoffset = backend.max_neighbors_offset. The initial-energy compile therefore lands in the same JIT cache slot the burn-in and the NS step will hit, instead of wasting a compile atmax_neighbors=0. Backends withoutmax_neighbors_for(LJ, toy, jax-md) passmax_neighbors=0straight through; the bucket arg is inert for them.batcher.wrap_for_batch(per_replica_fn)dispatch. The same helper body works for all topologies because thebatcherargument choosesjax.jit/jax.jit(vmap)/jax.jit(shard_map(vmap))underneath. Single-replica path passesSingleRun(); the multi-replica path passes the samePmapVmapRuns(G, P)instance it stores onResolvedConfig.batcher— so the resolver, burn-in, and NS step all dispatch through one shared batcher instance.Per-replica pressure under one ensemble term. The multi-replica path adds a single
EnsembleTerm(pressure=0.0)to the base Hamiltonian and threads each replica’s pressure through the per-callensemble_params={"pressure": p}kwarg, vmapped over the replica axis. Avoiding N separateEnsembleTerm(pressure=p)Hamiltonians keeps theshard_mapcall signature uniform — pressure is just another array on the vmap axis.
The end result is that for an 8-replica NeuralIL run on a 4-GPU
node, the resolver compiles the energy function once at shape
(4, 2, n_live, n_atoms, 3) at the same max_neighbors bucket
burn-in will use — instead of once per replica at the wrong bucket.
That’s where the resolver’s ~10× speedup on heavy-backend configs
comes from.
The unified ResolvedConfig¶
ResolvedConfig is a single frozen dataclass for both single- and
multi-replica runs. The shape depends on the batcher:
Field |
|
|
|---|---|---|
|
|
same |
|
length-1 tuple |
length- |
|
|
|
|
|
|
|
|
|
base_backend is always a
Hamiltonian holding the bare
model (base_backend.model, e.g. the raw MACE / LJ instance) plus the
soft-core term when backend.softcore_repulsion is set — but never an
ensemble term. The runtime adds an EnsembleTerm if needed; the
resolver does the same locally only to compute initial energies on the
right scale, then discards that Hamiltonian. This means a multi-replica
run can serve 8 different pressures from one EnsembleTerm(pressure=0.0)
instance, with each replica’s pressure flowing in through
ensemble_params at call time — no per-replica backend rebuild.
The CLI dispatches on isinstance(resolved.batcher, SingleRun):
single → run_from_config, multi → run_multi_gpu_from_config.
That’s the only place the two paths diverge after the resolver.
Concrete trace¶
Take the MACE pressure-RENS config at
experiments/mace_srtio3/config.yaml:
ensemble:
type: npt
pressure: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
pressure_units: gpa
inter_re:
flavor: pressure
re_interval: 5
Step by step:
Load & validate:
cli/cli.py::_load_and_validatereads the YAML and callsRootSpec.model_validate. pydantic runs all validators; errors surface here with line-accurate messages (and “did you mean” suggestions for typos).Interval-unit scaling (CLI):
_cmd_runcalls_apply_interval_units(root)and flipsinterval_unitsto"absolute", so the logged “Parsed configuration” block already shows resolved iteration counts.Unit conversion:
NPTEnsembleSpec._pressure_list()returns[1.0, …, 8.0]. When called viato_ensemble_params(i)withpressure_units="gpa", each scalar is multiplied by_GPA_TO_EVA3(schema-layer concern).Resolve:
_cmd_runcallsresolve(root). The resolver computesn_total = 8from the pressure list, readslen(jax.local_devices()) = 4on a--gres=gpu:4SLURM allocation, returns(n_gpu=4, n_per_gpu=2), and dispatches to_resolve_multi_replica. Divisibility is checked here.Per-replica structural init: for each of 8 replicas,
_resolve_initbuilds positions / cells / types only. A per-replicabase.with_terms(EnsembleTerm(pressure=P_r))is constructed for the rejection-mode ceiling check inside_sample_per_walker_positions, but no initial energies are computed yet. Per-replica arrays are stacked along axis 0 into(n_total, K, …).Consolidated finalize:
_resolve_multi_replicareshapes to(G, P, K, …), adds oneEnsembleTerm(pressure=0.0)to the base Hamiltonian, and calls_finalise_initial_energies_and_countswithbatcher=PmapVmapRuns(G, P), the per-replica pressures fed throughensemble_params={"pressure": P_r}on the vmap axis, andladder/offsetfrom the backend config. One compile across all 4 GPUs at the bucket the NS step will use.Runtime handoff:
ResolvedConfigis returned to_cmd_run, which inspectsresolved.batcherand callscli/run.py::run_multi_gpu_from_config(thePmapVmapRunsbranch). From here on, no schema, no resolver — just JAX arrays and dataclasses flowing throughrun_ns_multi_gpuwith itsshard_map(vmap(ns_step))dispatch.
For a scalar-pressure version of the same config, steps 4–7 collapse
to: n_total = 1, batcher is SingleRun(), resolver calls
_resolve_single_replica, CLI calls run_from_config. The
ResolvedConfig type is identical; only the array shapes and the
batcher differ.
Why this structure¶
Three properties the three-layer split buys you:
Early, single-point validation. Everything you can check without running JAX is checked in
jaxrens validate --parse-only. You don’t lose 10 minutes of GPU time to a typo liken_liv: 500— the schema’sextra="forbid"rejects it instantly, and the CLI formats the error with a “did you mean” suggestion.Independent evolution of the YAML surface and the core. Add a new YAML shortcut in the schema without touching the core; rename a
NSConfigfield in the core without breaking YAML compatibility (the resolver adapts).Programmatic entry point. Nothing forces you through the YAML layer. Build a
RootSpecby hand in Python, callresolve, thenrun_from_config/run_multi_gpu_from_configdirectly — exactly whattests/test_cli_multi_run.pydoes.
Where this lives in the code¶
Layer |
File(s) |
|---|---|
Schema |
|
Resolver |
|
Single-replica runtime entry |
|
Multi-replica runtime entry |
|
CLI dispatch |
|
Library core |
|