Update example to cover some common issues

This commit is contained in:
Jaret Burkett
2026-06-18 07:54:37 -06:00
parent 66f7c06742
commit ad49d4ef25
2 changed files with 35 additions and 0 deletions

View File

@@ -330,6 +330,15 @@ class ExampleModel(BaseModel):
batch max is deferred to get_noise_prediction / the pipeline,
which keeps caches small and lets any prompts share a batch.
Each per-prompt tensor MUST be 2D ``(L, D)`` -- BaseModel infers the
text batch size from the list and only treats it as one-per-prompt
when the tensors are 2D; a 3D per-prompt tensor is misread as an
already-batched ``(B, L, D)`` and training fails with a latents-vs-
text batch-size mismatch. If your conditioning has an extra axis
(e.g. N stacked encoder layers -> ``(L, N, D)``), flatten it here
(``(L, N*D)``) and restore it (``reshape(B, Lt, N, D)``) at the
model call.
You can store any number of keys (pooled embeds, image features,
...). If a key must keep its dtype when everything else is cast
(masks, token ids), list it in ``embeds.frozen_dtype_keys``.