You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace or approximate the O(N_cells × 4) lateral nutrient diffusion step (Phase 4 of engine tick loop) with a learned forward pass. This is the first simulation phase to be replaced by a BYOM adapter, establishing the pattern for future phase replacements.
Diffusion was disabled (nutrient_diffusion_enabled: false) because it was expensive. A learned model makes it cheap enough to always enable — or use as an adaptive gate that skips physics diffusion when gradients are flat.
Background
Current diffusion (in world_processes.py):
Runs every DIFFUSION_PERIOD=5 ticks
For each cell in nutrients_fast and nutrients_slow layers: 4 neighbor lookups, blend computation
O(N_cells × 4) dict operations per layer per period
Gated by NUTRIENT_DIFFUSION_ENABLED toggle
Diffusion is a smooth local operator — exactly the kind of thing convolutions learn naturally. The model predicts the delta (small perturbation), not the full next state.
See: docs/ECOSIM_PARAMETER_TELEMETRY_SPACE.md § "Concrete Use Case B"
Two Modes
Mode 1: Gating (Phase A — lower risk)
Train a lightweight predictor that estimates |delta| for each layer. If below ε, skip the physics diffusion step entirely. This gives adaptive frequency without replacing the physics.
Inputs: voxel grid snapshot at tick t (5 layers, downsampled to 8³ or 16³)
Targets: binary — "diffusion delta > ε in next period?"
Model: small MLP on pooled features, or tiny CNN
Benefit: skip diffusion during steady-state, run it after rain/decomposition blooms
Mode 2: Replacement (Phase B — full replacement)
Train a model that predicts the diffusion delta directly.
Inputs: voxel grid snapshot at tick t (5 layers as channels, 32³ spatial)
Targets: voxel grid delta over one diffusion period (t → t+5), per layer
Model: U-Net or small 3D CNN; predict delta since diffusion is a small perturbation
Benefit: O(1) forward pass vs. O(N_cells × 4) neighbor lookups
Adapter Protocol
Extend the BYOM pattern from model_adapter.py:
@runtime_checkableclassVoxelAdapter(Protocol):
"""Voxel-level model adapter for learned diffusion."""defcontext_spec(self) ->ContextSpec:
"""Declare input features (voxel layers + metadata)."""
...
definfer_diffusion_delta(
self,
voxel_grid: list[list[float]], # flattened or structuredbiome_config: dict[str, float],
) ->list[list[float]]:
"""Predict diffusion delta for each layer."""
...
defshould_skip(self, ...) ->bool:
"""Gating mode: predict whether physics diffusion can be skipped."""
...
Training Data Collection
Enable nutrient_diffusion_enabled: true in sim_config
Goal
Replace or approximate the O(N_cells × 4) lateral nutrient diffusion step (Phase 4 of engine tick loop) with a learned forward pass. This is the first simulation phase to be replaced by a BYOM adapter, establishing the pattern for future phase replacements.
Diffusion was disabled (
nutrient_diffusion_enabled: false) because it was expensive. A learned model makes it cheap enough to always enable — or use as an adaptive gate that skips physics diffusion when gradients are flat.Background
Current diffusion (in
world_processes.py):NUTRIENT_DIFFUSION_ENABLEDtoggleDiffusion is a smooth local operator — exactly the kind of thing convolutions learn naturally. The model predicts the delta (small perturbation), not the full next state.
See:
docs/ECOSIM_PARAMETER_TELEMETRY_SPACE.md§ "Concrete Use Case B"Two Modes
Mode 1: Gating (Phase A — lower risk)
Train a lightweight predictor that estimates |delta| for each layer. If below ε, skip the physics diffusion step entirely. This gives adaptive frequency without replacing the physics.
Mode 2: Replacement (Phase B — full replacement)
Train a model that predicts the diffusion delta directly.
Adapter Protocol
Extend the BYOM pattern from
model_adapter.py:Training Data Collection
nutrient_diffusion_enabled: truein sim_configModule Structure
Design Constraints
weights/motion_v0.json)Acceptance Criteria
Phase A (Gating)
VoxelAdapterprotocol defined inmodel_adapter.pyor new modulePhase B (Replacement)
LearnedDiffusionAdapterplugs into engine Phase 4Related
docs/ECOSIM_PARAMETER_TELEMETRY_SPACE.md(Phase 3)