mstar.model.waypoint.components.dit#
The Waypoint-1.5 DiT: 24 blocks, the 4+1 pass driver, and the world clock.
Five forwards per generated frame: four frozen Euler denoise passes over
config.scheduler_sigmas, then one committing pass at sigma=0 that writes
the ring. Two clocks are threaded separately: f_pos (buckets, slots,
visibility) and t_pos = f_pos * config.ts_mult (RoPE time); conflating
them is silent drift at any fps where ts_mult != 1.
Classes
|
Conv2d patchify -> 24 blocks -> adaLN head -> unpatchify, plus the 4+1 per-frame driver. |
|
One DiT block: adaLN-modulated causal frame attention, optional controller fusion, adaLN-modulated MLP. |
|
The four position streams for one frame, per row of the step batch. |
- class mstar.model.waypoint.components.dit.WaypointDiT(config)[source]#
Bases:
ModuleConv2d patchify -> 24 blocks -> adaLN head -> unpatchify, plus the 4+1 per-frame driver.
Built on the meta device and materialized by
weight_loaderin a fixed order:with torch.device("meta"): dit = WaypointDiT(config) dit.cast_serving_dtypes() # bf16 + fp32 islands, on meta dit.to_empty(device=device) # un-ties cond_proj dit.retie_cond_proj() # MUST follow to_empty load_weights_into(dit, ...)
The KV ring is derived state owned by an engine resource, bound after materialization – not part of this module.
- Parameters:
config (WaypointConfig)
- append_frame(latent, frame_pos, *, mouse, button, scroll)[source]#
Prime the world state from a real (VAE-encoded) frame: the committing pass alone, one forward.
latentis already the settled x0, so there is nothing to solve and nothing to clone. Returned unchanged for the caller to decode.
- cast_serving_dtypes()[source]#
bf16 everywhere, then the fp32 islands back to fp32.
Called on the meta module before
to_empty(device)so storage is allocated directly in the serving dtype..to(dtype)on meta preserves thecond_projaliasing (to_emptydoes not), so no retie is needed here.- Return type:
- compile_regions(**compile_kwargs)[source]#
Compile the denoise and cache passes, one region each. Idempotent.
materialize_runtime_tablesmust run first: the derived token grid, RoPE tables and conditioner LUT live outside the module tree, and a first touch inside afullgraph=Trueregion is at best a specialization and at worst a graph break.- Return type:
- forward(x, sigma, frame_pos, *, mouse, button, scroll, commit, cond_idx)[source]#
One pass over one latent frame; returns the rectified-flow velocity.
x[B, N, C, H, W](N == 1),sigma[B, N],frame_pos[B]int64 ring clock. Returns[B, N, C, H, W].commitsays whether this pass keeps its K/V (False for the four denoise passes, True for the fifth);cond_idxselects the cached modulation row and must matchsigma.
- generate_frame(noise, frame_pos, *, mouse, button, scroll)[source]#
Denoise one frame from
noise[B, N, C, H, W]and commit it.Five forwards: 4 frozen + 1 committing, all sharing one
frame_pos. The caller owns the ring clock and advances it once per committed frame.
- materialize_runtime_tables(device)[source]#
Create every derived table after weight loading and before compile.
- Parameters:
- Return type:
- retie_cond_proj()[source]#
Alias blocks 1..23’s six
cond_projmatrices onto block 0’s.Public, and separate from
__init__, becauseto_empty(device)destroys the tying (Module._applyhas no cross-module memo, so each block would get 24 independent copies).bias_inis deliberately NOT tied – it is genuinely per-layer.- Return type:
- class mstar.model.waypoint.components.dit.WaypointDiTBlock(config, layer_idx)[source]#
Bases:
ModuleOne DiT block: adaLN-modulated causal frame attention, optional controller fusion, adaLN-modulated MLP.
The six modulation tensors come from this block’s
cond_head, whosebias_inis per-layer and whosecond_projmatrices alias block 0’s.- Parameters:
config (WaypointConfig)
layer_idx (int)
- forward(x, frame_pos, rope_angles, cond, ctrl_emb, v1, *, commit, cond_idx)[source]#
x[B, N*T, D],cond/ctrl_emb[B, N, D](per frame) ->(x, v1).v1is layer 0’s pre-lerp V, threaded down the stack;cond_idxis thescheduler_sigmasslot for the cond_head cache. Onlyf_posreaches this far – RoPE angles are built once at the root.
- class mstar.model.waypoint.components.dit.WaypointPosIds(f_pos, t_pos, y_pos, x_pos)[source]#
Bases:
NamedTupleThe four position streams for one frame, per row of the step batch.
f_posis the[B]int64 ring clock (the KV resource’supserttakes it);t_posis the[B, T]RoPE time coordinatef_pos * ts_mult;y_pos/x_posare[B, T]token-grid coordinates,row = i // widthandcol = i % width.