techfreakworm commited on
Commit
f92f481
Β·
unverified Β·
1 Parent(s): b2004e8

docs: PLAN states the exact pins, the local Apple-silicon path, and corrects what the code and the measurements overtook

Browse files

Β§5.1 now lists every requirement as the one version requirements.txt pins
(transformers 5.23.0 with its companions, the torch trio, bitsandbytes,
kernels, gradio, numpy, ...), says why `spaces` is absent (the platform
installs it; the Space reports 0.51.3), names the fallback (transformers 5.22.2
with the same companions), and says which lines have no real-weights evidence
yet: the CUDA-only ones, the int8 load under 5.23.0 in particular. Β§3.5 no
longer calls 5.15.1 the floor.

Corrected in place, each with the date and the source:

- status: ten of eleven modes verified on real weights locally; none re-run
on the Space; "all eleven generate at 287ba9c" was colour static;
- the tier: `auto` never promoted; the code now defaults to xlarge; the
quota arithmetic (180-510 s reservations, x2 documented not measured) and
the "drop under 42 GiB" argument; VRAM was the constraint on `large`;
- disk: "82.2 GB of 150" is a pre-pack reading; the bar read 40.6G packed;
packing happens at launch, not at the module-scope .to("cuda");
- there is a precision switch (LTX25_QUANTIZATION), a device module, a local
runner and a local-only memory preflight; preflight has no RAM check;
- the decoder: until today the diffusion decode ran only with stage 2; now
LTX25_DECODER=auto uses it wherever it can run, so NATTEN is fetched at a
worker's first video run; three modes skip stage 2, not eight;
- the enhancer costs a 180 s reservation and a ~29 s cold load; its prefetch
failed on every boot of the deployed build;
- the shot list is gone from the UI; mode 11 exports video with the user's
audio; modes 10/11 use their own audio levels; the LoRA range-read is not
built; stage 6.5, not 7, is the gate; 2.3 adapters warn.

Files changed (1) hide show
  1. docs/PLAN.md +270 -58
docs/PLAN.md CHANGED
@@ -1,7 +1,10 @@
1
  # LTX-2.5 Studio β€” Design Plan
2
 
3
- **Status:** implemented; not yet run on a GPU. The matrix in
4
- [`docs/TEST_PLAN.md`](TEST_PLAN.md) is what proves it works.
 
 
 
5
  **Branch:** `soma/ltx25-studio` Β· **Remote:** `git@github.com:techfreakworm/ltx2.5-studio.git`
6
  **Target:** private Hugging Face Space `techfreakworm/LTX2.5-Studio` (gradio SDK, ZeroGPU).
7
 
@@ -9,8 +12,11 @@
9
  > GPU" was true when written. Since then: **all eleven modes ran on hinode**
10
  > (704Γ—480Γ—121 baseline, stage 2 at 1408Γ—960, duration head f=97, LoRA both
11
  > directions, mel round-trip β€” [`OPERATOR_HANDOFF.md`](OPERATOR_HANDOFF.md) Β§2)
12
- > and **all eleven generate on the live ZeroGPU Space** at sha `287ba9c`,
13
- > 256Γ—256Γ—9 ([`SPACE_MODE_MATRIX.md`](SPACE_MODE_MATRIX.md)). The line above is
 
 
 
14
  > kept because this document records how the build was *decided*; where the
15
  > project *stands* is the handoff's job. Where a decision below was overtaken β€”
16
  > the bf16 default (Β§2.6), the ~68 GB ceiling (Β§2), the explicit `size=`
@@ -70,8 +76,8 @@ a build we cannot reproduce or pin.
70
  hand-maintained block of *custom-node deps we discovered are required but aren't auto-installed
71
  by their respective nodes* (`gguf`, `imageio_ffmpeg`, `opencv-python`, `matplotlib`,
72
  `scikit-image`, `onnxruntime`, `yt-dlp`). That comment block is the evidence: the dependency
73
- surface was discovered by breakage, not by design. Diffusers replaces all of it with ~16 pinned
74
- direct deps and zero custom-node surface.
75
 
76
  **Decisive coupling to Β§2.** The `*-comfy-int8-convrot` quantised weights are **ComfyUI-only**
77
  β€” the model card says so. Choosing A or C means those 36.9 GB of int8 weights are unusable to
@@ -183,6 +189,15 @@ second is now settled rather than uncertain: it does not fit (Β§2.5).
183
  > died with the number (`SPACE_GENERATION_FINDING.md` Β§6). The disk row's
184
  > verdict stood for bf16 β€” and was then routed around: the deployed Space ships
185
  > **int8** (`ZEROGPU_DISK.md` Option B) and fits at **82.2 GB of 150 [OK]**.
 
 
 
 
 
 
 
 
 
186
 
187
  ### 2.1 Trap A β€” duplicate shard sets
188
 
@@ -228,7 +243,7 @@ Measured from the Hub's own byte counts, not estimated. The `GB` column is decim
228
  | `transformer/` | 37.9762 | index | the model (4 live shards + config + index) |
229
  | `text_encoder/` | 23.9195 | index | `Gemma4UnifiedForConditionalGeneration` (Β§10 OQ-4) |
230
  | `connectors/` | 6.3445 | index | text β†’ transformer conditioning; also a LoRA target |
231
- | `vae/` | 1.4522 | index | video VAE (conv-decoder fallback β€” Β§7.4) |
232
  | `latent_upsampler/` | 0.9957 | **subfolder** | stage-2 spatial upscale |
233
  | `diffusion_decoder/` | 0.8343 | index | **the native 2.5 decoder** β€” Β§7.4 |
234
  | `temporal_latent_upsampler/` | 0.2619 | **subfolder** | stage-2 temporal upscale |
@@ -403,6 +418,14 @@ So bf16 ships and `size="xlarge"` is **declared explicitly** rather than being s
403
  > ceiling, "uncertain but documented") is falsified besides
404
  > (`SPACE_GENERATION_FINDING.md` Β§6). The Β§6.2.1-class route list at the end of
405
  > this section omitted the route actually taken.
 
 
 
 
 
 
 
 
406
 
407
  **⚠️ There is no precision switch, and the reason is a correction rather than a decision.**
408
  `LTX25_TRANSFORMER_PRECISION` and `LTX25_TEXT_ENCODER_PRECISION` existed, resolved cleanly, and
@@ -420,6 +443,12 @@ of quantised tensors was unknown β€” was false; see above.** The lever is gone b
420
  option*; it
421
  is not a *configured* one, and the difference is now visible in the code rather than implied.
422
 
 
 
 
 
 
 
423
  The routes actually available under disk pressure are persistent storage, a public Space, or
424
  smaller checkpoints β€” see Β§6.2.1.
425
 
@@ -428,7 +457,9 @@ smaller checkpoints β€” see Β§6.2.1.
428
  variant needing *different files* cannot be fetched on demand into that cache. If a future
429
  precision setting changes the file list, the Space must be rebuilt with a new `preload_from_hub`
430
  block. Setting the variable alone changes how the existing weights are loaded -- nothing more. This is **technical risk #1** (Β§10), and it is to be settled by
431
- measurement on the Space, not by argument.
 
 
432
 
433
  ### 2.7 Output retention β€” 20 GB, evicted oldest-first
434
 
@@ -504,10 +535,20 @@ discards the input entirely.
504
  | 10 | audio β†’ audio | condition | `audio_latents` + `noise_scale`, export only audio | ⚠️ same |
505
  | 11 | audio β†’ video | condition | `audio_latents` + `noise_scale`, export only video | ⚠️ pays audio encode on top |
506
 
507
- **Mandatory mitigation for modes 8–11:** run at the **minimum legal resolution**, **skip the
 
 
 
 
 
 
 
 
 
508
  stage-2 spatial upscale**, export only the requested track. The UI must say in words that
509
  audio-only modes still render video internally β€” a user who does not know that will read the
510
- runtime as a bug.
 
511
 
512
  ### 3.4 Multishot β€” **downgraded to honest**
513
 
@@ -520,6 +561,11 @@ button that implies support we cannot back.
520
 
521
  (Superseding an earlier draft of this plan that called it a first-class affordance. It is not.)
522
 
 
 
 
 
 
523
  ### 3.5 Prompt enhancement: **ships, as a real toggle, default off**
524
 
525
  > ⚠️ **This section is a correction.** It read "unavailable by default; we ship no dead
@@ -549,9 +595,13 @@ download β€” and if it never goes to CUDA, it is never packed at all.
549
  **βœ… And the download is 2.49 GB.** `google/gemma-4-E2B-it-qat-mobile-transformers` is the
550
  quantisation-aware-trained build: public, ungated, one `model.safetensors`, **2.490 GB**
551
  against **10.279 GB** for the bf16 `google/gemma-4-E2B-it`. Its `config.json` carries
552
- `quantization_config.quant_method == "gemma"`, which `transformers >= 5.15.1` β€” already the
553
- floor in `requirements.txt` β€” registers as `GemmaQuantizer`; the unpacking layers it installs
554
- are plain torch with no CUDA or kernel dependency, which is what lets it run on the CPU.
 
 
 
 
555
  ⚠️ It has **no** top-level `architectures` key, so `AutoModel*` cannot dispatch on it and
556
  `Gemma4ForConditionalGeneration` must be named explicitly. `LTX25_PROMPT_ENHANCER_REPO`
557
  selects the repo; the bf16 build is one environment variable away.
@@ -605,10 +655,17 @@ and diffusion decoder to CUDA inside the worker for exactly this reason. The enh
605
  speed: ~1-2 s of billed wall against ~85 s for a real generation, **under 5% overhead** where
606
  the CPU placement was +3500%.
607
 
 
 
 
 
 
608
  **What that costs, and what now pays for it.** Enhancement is inside the reservation, so
609
  `zerogpu.estimate_duration` adds `ENHANCE_DURATION_SECONDS` when the toggle is set β€” an
610
  enhanced run killed at the reservation boundary would be a self-inflicted wound β€” and the UI
611
- caption gives up "costs no quota" to be honest about "no longer costs nine minutes".
 
 
612
 
613
  **And the download is prefetched, because it would otherwise be billed.** Without it the
614
  first enhanced call in each container spends the 88 s Hub fetch *inside* the metered window:
@@ -626,6 +683,13 @@ reservation increment is sized for the download rather than for the decode.
626
  enhancement β€” it lands while `demo.launch()` is packing, which is the window
627
  `ZEROGPU_DISK_CAP_GB` is measured against.
628
 
 
 
 
 
 
 
 
629
  The settings, unchanged from what this section banked in advance and now imported from
630
  upstream rather than restated: `prompt_max_new_tokens=600`, **greedy decoding**
631
  (`do_sample=False, no_repeat_ngram_size=5`), `prompt_enhancement_seed` **inert under greedy
@@ -883,6 +947,10 @@ shape. No torch, no diffusers, no `safetensors` package. Three reasons, in order
883
  download. A user who pastes a repo-id for a 2B-architecture adapter gets a specific rejection in
884
  about a second instead of after a 300 MB download. Stage 1 comes free from `Content-Length`.
885
 
 
 
 
 
886
  **Upload route:** the bytes are already local, so the same parser runs against the file. Both
887
  routes converge on one code path, which is what Β§4.3 asks for.
888
 
@@ -895,7 +963,7 @@ import diffusers or peft**, because it is the only one that touches a real model
895
 
896
  Binding on all code in the repo.
897
 
898
- ### 5.1 Pin every dependency, with upper bounds β€” and know what NOT to pin
899
 
900
  Evidence from the predecessor: `spaces>=0.30.0` and `torch>=2.4.0` β€” floors with **no ceiling**
901
  β€” alongside exactly one hard pin, `torchaudio==2.10.0`, carrying this comment:
@@ -906,40 +974,62 @@ Evidence from the predecessor: `spaces>=0.30.0` and `torch>=2.4.0` β€” floors wi
906
  That comment is a post-mortem, applied to one line while ~50 stayed unbounded.
907
 
908
  **But the inverse mistake is also real, and the 2.3 repo made it.** Its own `AGENTS.md:19` says
909
- **do not pin `spaces`** β€” the platform pins its own version (live Spaces report 0.49.3 / 0.50.0 /
910
- 0.50.4 while PyPI is 0.51.1) and a conflicting pin breaks pip resolution at build time. Its
 
911
  `requirements.txt:2` then pins `spaces>=0.30.0` anyway. We follow the rule the repo wrote and
912
- did not keep: **no `spaces` line in `requirements.txt`**, and the import is guarded in code
913
- (`try: import spaces / except ImportError: spaces = None`) so local dev works.
914
-
915
- The full pin set:
 
 
 
 
 
 
 
 
 
 
 
 
 
916
 
917
  | package | pin | why |
918
  |---|---|---|
919
- | `torch` | `==2.11.0` | ZeroGPU supports exactly 2.8.0 / 2.9.1 / 2.10.0 / **2.11.0**; ceiling is 2.11.0. CUDA 12.8, sm_120 needs cu128+ |
920
  | `torchvision` | `==0.26.0` | **trap:** `torchvision 0.28.0` hard-declares `torch==2.13.0`, so a floating torchvision silently upgrades torch past the ceiling |
921
  | `torchaudio` | `==2.11.0` | must match torch exactly (the ABI break above) |
922
- | `gradio` | `>=6.24.0,<7` | **5.x is END OF LIFE** (last stable 5.50.0, 2025-11-21) |
923
  | `diffusers` | `@ git+…@ac56fa2f…` | Β§1.3 |
924
- | `transformers` | `>=5.15.1,<6` | |
925
- | `accelerate` | `>=1.14.0,<2` | |
926
- | `peft` | `>=0.20.0,<0.21` | LoRA backend |
927
- | `safetensors` | `>=0.8.0,<0.9` | |
928
- | `huggingface_hub` | `>=1.28.0,<2` | |
929
- | `hf_xet` | `>=1.6.0,<2` | |
930
- | `imageio` | `>=2.37.4,<3` | |
931
- | `imageio-ffmpeg` | `>=0.6.0,<0.7` | |
932
- | `av` | `>=18.1.0,<19` | PyAV β€” required by CRF re-compression (Β§5.7) |
933
- | `numpy` | `>=2.5.2,<3` | **numpy 2.** Do NOT pin `<2`: 1.26.4 is 2 years EOL and nothing in the stack caps it |
934
- | `pillow` | `>=12.3.0,<13` | |
935
- | `spaces` | **absent, deliberately** | platform-pinned; see above |
 
 
 
 
 
 
 
 
936
 
937
  **gradio 6 breaking changes that hit us:** `gr.Video` subtitle-tuple return removed;
938
  `show_download_button` / `show_share_button` β†’ `buttons=[...]`; `gr.Audio` `show_controls` β†’
939
  `show_recording_waveform`; `min_length` / `max_length` β†’ event-listener validators.
940
 
941
- **Python 3.12 is required, not preferred:** numpy 2.5.2 needs β‰₯3.12 and `av` 18 needs β‰₯3.11. The
942
- default 3.10.13 image silently resolves both *downward* rather than failing.
 
943
 
944
  ### 5.2 One central model-file indirection
945
 
@@ -953,6 +1043,14 @@ happens again, the message should tell the operator which URL to go look at.
953
  Pinning a **revision** per repo is part of this module's job β€” a repo whose content can change
954
  under us is not pinned just because its name is stable.
955
 
 
 
 
 
 
 
 
 
956
  **New requirement: `model_files.py` emits the download allow-list as data.** It must be able to
957
  produce the exact list of **37 paths** (Β§2.3), so that:
958
 
@@ -1044,7 +1142,7 @@ loaded components, using literals only as fallbacks. Same discipline. Β§5.7 exte
1044
  |---|---|---|
1045
  | `height % 32 == 0`, `width % 32 == 0` | enforced upstream (raises) in all generation pipelines *and* the latent-upsample pipeline | validate before the call, snap in the UI, **show** the snapped value |
1046
  | `num_frames % 8 == 1` | **not** hard-raised upstream. Falls out of `latent_num_frames = (num_frames - 1) // vae.temporal_compression_ratio + 1`, which **silently floors** a bad value | we raise. **The `8` is `vae.temporal_compression_ratio`** β€” see below |
1047
- | audio/video length agreement | audio and video lengths are computed independently, and a supplied `audio_latents` **overrides** the duration-derived audio length (Β§5.7) | validate they agree; raise rather than emit a desynced file |
1048
 
1049
  **The `num_frames` modulus is a parameter, not a literal.** Hardcoding `8` would violate Β§5.4.
1050
  Resolution:
@@ -1078,6 +1176,13 @@ This is the fail-loudly principle applied to the resource budget. It turns an an
1078
  `"Workload evicted, storage limit exceeded (150G)"` into a diagnosable message that names the
1079
  fix. It also runs the Β§1.3 diffusers-version assertion. Test case.
1080
 
 
 
 
 
 
 
 
1081
  **The startup report** (`pipelines.startup_report`) prints, before anything expensive:
1082
 
1083
  ```
@@ -1098,6 +1203,14 @@ LTX-2.5 Studio starting
1098
  > `quantised transformer, text_encoder as int8 | peak RSS 0.91 -> 87.13 GiB`
1099
  > β€” captured in `SPACE_GENERATION_FINDING.md` Β§5 and `OPERATOR_HANDOFF.md` Β§5.
1100
  > The load-bearing line survives unchanged: the live Space reads `37/37 files`.
 
 
 
 
 
 
 
 
1101
 
1102
  The **cache count is the load-bearing line**: `36/37`, with the first missing file named, makes
1103
  "preload worked" and "preload silently did nothing" two different sentences. When a GPU run fails
@@ -1136,7 +1249,7 @@ Recorded for completeness β€” **but see Β§8.4: we do not use accelerate's offloa
1136
  | 1 | **ZeroGPU quota attribution rides a contextvar** (`gradio.context.LocalContext.request`). It does **not** cross a plain `threading.Thread` β€” without it every user is bucketed as Space-anonymous and you get *"Space app has reached its GPU limit"* at **0 minutes used** | any thread we spawn must carry `contextvars.copy_context()`; better, do not spawn plain threads across the GPU boundary |
1137
  | 2 | The `duration=` callable must accept **the exact same positional signature** as the decorated function, trailing kwargs included | otherwise TypeError at schedule time; test the signature match |
1138
  | 3 | **Hidden 1.5Γ— duration multiplier on `large`** (`duration_factor`): `duration=60` is scheduled as 90 s. On `xlarge` the factor is skipped but the request is **doubled** instead | never reason about wall-clock quota from the `duration=` number alone |
1139
- | 4 | Default duration is 60 s. The **max is a server-side, tier-dependent, unpublished cap** | **discover it, never hardcode it.** Empirically ~120 s is the safe ceiling; the official Lightricks LTX Space ships `@spaces.GPU(duration=75, size="xlarge")` |
1140
  | 5 | **Do NOT auto-retry a ZeroGPU timeout** using the captured Gradio request: the `X-IP-Token` ages past TTL during attempt 1, so attempt 2 always 401s with *"Expired ZeroGPU proxy token"* β€” **masquerading as the root cause** | surface the original timeout; never retry behind the user's back |
1141
  | 6 | `preload_from_hub` is **capped at 10 entries**, and preloaded files are owned by the *build* user and **read-only to runtime uid 1000** β€” a later lazy `hf_hub_download` fails with `Permission denied (os error 13)` unless the cache is mirrored | Β§6.2 |
1142
  | 7 | Accumulated generations filled the 2.3 Space's disk and it went unhealthy | Β§2.7 β€” sweep on startup and after each run |
@@ -1151,14 +1264,20 @@ Recorded for completeness β€” **but see Β§8.4: we do not use accelerate's offloa
1151
  | **SDK** | `sdk: gradio`, `sdk_version: 6.24.0` β€” **a custom Dockerfile forfeits ZeroGPU entirely** |
1152
  | **Python** | `python_version: "3.12"` β€” required, not optional (Β§5.1) |
1153
  | **Hardware** | ZeroGPU. `suggested_hardware: zero-a10g` is the **legacy id string the Spaces API still reports β€” it is NOT an A10G** (Β§8.1) |
1154
- | **Size** | `size="xlarge"` declared explicitly (Β§8.5) |
1155
- | **Weights** | README frontmatter `preload_from_hub:` |
1156
  | **Secret** | `HF_TOKEN` β€” required; `Lightricks/LTX-2.5-Diffusers` is gated |
1157
  | **Git** | GitHub `git@github.com:techfreakworm/ltx2.5-studio.git`; Space and GitHub stay in sync |
1158
 
1159
  > **On the Size row (annotated 2026-08-25):** never declared in practice β€”
1160
  > every deploy has run `auto`, and the live Space was promoted to `xlarge` by
1161
  > inference. Β§8.6's annotation carries the detail.
 
 
 
 
 
 
1162
 
1163
  Naming precedent: `techfreakworm/LTX2.3-Studio`, `wan-studio` (private), `SAM3-cutout-studio`
1164
  (private).
@@ -1210,6 +1329,8 @@ gcTimeout : 172800 s = 48 hours
1210
  There is **no persistent storage**, so the full **72.186 GB** is refetched on
1211
  every cold start β€” restart, rebuild, or 48 hours idle. `startup_duration_timeout:
1212
  1h` covers it. **This is accepted for the development phase**, not endorsed.
 
 
1213
 
1214
  Two routes back to preloading, either of which restores it:
1215
 
@@ -1299,12 +1420,19 @@ bug in the allow-list, not as normal operation.
1299
  `LTX-2.3-22b-IC-LoRA-*` are each gated on their own acceptance and the token does not have
1300
  them. This is **not** a blocker: Β§4.5 shows the ungated community LoRAs are a *better* R3
1301
  fixture anyway, because they are what users actually upload. Recorded so nobody is surprised
1302
- when an official IC-LoRA 403s.
1303
 
1304
  **Local reality check:** the gate being open does not mean we can generate locally. The 22B
1305
  model does not run on macOS. Real generations happen on the Space, under the quota discipline
1306
  in [`docs/TEST_PLAN.md`](TEST_PLAN.md).
1307
 
 
 
 
 
 
 
 
1308
  ---
1309
 
1310
  ## 7. Architecture
@@ -1314,12 +1442,17 @@ in [`docs/TEST_PLAN.md`](TEST_PLAN.md).
1314
  ```
1315
  app.py # entrypoint. `import spaces` FIRST (Β§8.2), then build + launch.
1316
  ltx25_studio/
1317
- config.py # device/dtype selection, paths, retention cap (Β§2.7), env overrides
1318
- model_files.py # Β§5.2 β€” THE single source of truth: repo ids, revisions, subfolders,
1319
- # filenames, sizes, AND the dtype/quantization switch (Β§2.6)
 
 
 
1320
  errors.py # typed exception hierarchy; every error carries an actionable detail
1321
- preflight.py # Β§5.6 β€” RAM/disk headroom vs the model_files requirement;
1322
- # Β§1.3 β€” the diffusers-version fail-fast assertion
 
 
1323
  zerogpu.py # Β§8 β€” the `spaces` shim, the static @spaces.GPU policy, the
1324
  # duration callable, contextvar propagation, and the
1325
  # "never return CUDA tensors" boundary
@@ -1330,6 +1463,7 @@ ltx25_studio/
1330
  # conversion (Β§5.7 #1); uint8/PIL normalisation (Β§5.7 #7)
1331
  audio.py # waveform <-> mel <-> audio_vae latents; params from config (Β§5.4);
1332
  # vocoder decode
 
1333
  modes.py # Β§3.3 registry: 11 UI modes as data over the 4 real workflows
1334
  generate.py # Β§7.4 stage graph. OWNS the never-empty invariant (Β§5.3) and the
1335
  # per-run output directory
@@ -1339,14 +1473,25 @@ ltx25_studio/
1339
  outputs.py # mux video+audio, single-track export, 20 GB oldest-first eviction
1340
  lora/
1341
  inspect.py # header-only safetensors parse; metadata + convention detection
1342
- validate.py # validator stages 1-6 (Β§4.3)
1343
  apply.py # load_lora_weights, stage-7 attach assertion, both-component fusing
 
 
 
1344
  ui/
1345
  blocks.py # Gradio Blocks assembly
1346
  components.py # reusable widgets (condition list, LoRA picker, constraint hints)
1347
  handlers.py # thin adapters: UI event -> one call -> UI update. No logic.
 
 
 
1348
  ```
1349
 
 
 
 
 
 
1350
  ### 7.2 Layering rules
1351
 
1352
  - **Dependencies point inward.** `ui/` may import anything; `generate.py` must not import `ui/`.
@@ -1389,6 +1534,16 @@ would know why.
1389
 
1390
  **Decision: classic pipelines, with the diffusion decode added as an explicit stage.**
1391
 
 
 
 
 
 
 
 
 
 
 
1392
  ```
1393
  stage 1 LTX2ConditionPipeline(..., sigmas=DISTILLED_SIGMA_VALUES,
1394
  output_type="latent")
@@ -1466,6 +1621,11 @@ decisions; none is a knob we can turn.
1466
  > 150 [OK]**, prune freed 65.25 GB, all eleven modes generating at sha
1467
  > `287ba9c`. The finding itself stands: bf16 on `storage: None` remains
1468
  > structurally infeasible β€” which is exactly why the live Space is not bf16.
 
 
 
 
 
1469
 
1470
  **The base is always the superset class**, `LTX2ConditionPipeline`. Deriving
1471
  superset β†’ subset can only drop `audio_scheduler`, which the subset does not
@@ -1494,7 +1654,8 @@ integration is the wrong trade.
1494
 
1495
  The modular path is recorded here as **the canonical alternative**: if we move to it, the decode
1496
  block is swappable exactly as the docstring describes, and `vae/` (1.452 GB) stays in the subset
1497
- as the conv-VAE fallback either way.
 
1498
 
1499
  ---
1500
 
@@ -1519,6 +1680,11 @@ of several.
1519
  **VRAM is not our constraint.** 67.2 GiB of weights against `xlarge`'s ~95 GiB leaves ~28 GiB
1520
  for activations. The constraints are CPU RAM and transient disk (Β§2).
1521
 
 
 
 
 
 
1522
  ### 8.2 Import order is load-bearing
1523
 
1524
  ```python
@@ -1547,6 +1713,13 @@ normal GPU-box practice:
1547
 
1548
  HF's guidance, quoted: **models must be placed on cuda at the root module level.**
1549
 
 
 
 
 
 
 
 
1550
  ##### ⚠️ The snapshot is freed after packing β€” but only if the mmap survives
1551
 
1552
  Read from `spaces` 0.51.1 (`zero/torch/patching.py:395`) rather than inferred:
@@ -1582,8 +1755,15 @@ coexist for the whole packing window β€” which is the peak in Β§2.5, the authori
1582
  Steady state afterwards is fine at ~72 GB. **It is the peak that evicts us, not
1583
  the residency.**
1584
 
 
 
 
 
 
1585
  **Corollary: do NOT lazy-load models inside the decorated function.** HF documents that
1586
- placements are optimised for startup; lazy loading defeats the packer entirely.
 
 
1587
 
1588
  ##### Considered and rejected: deferring the second workflow
1589
 
@@ -1659,17 +1839,32 @@ the cost is visible in the source rather than being a surprise in the quota dash
1659
  > GiB**. Β§8.6's original instruction β€” *declare the size explicitly rather than
1660
  > being silently promoted* β€” was right on the first try and was talked out of by
1661
  > a threshold reading. Trace: [`MIG_ALLOCATOR_SIGHTINGS.md`](MIG_ALLOCATOR_SIGHTINGS.md) Β§1.
 
 
 
 
 
1662
 
1663
  **Quota arithmetic:** PRO gives 2400 s/day. At `duration=75` on `xlarge` (2Γ—), each run is
1664
  charged ~150 s β†’ **~16 runs/day**. Dropping under 42.00 GiB via quantization would return us to
1665
  `large` at 1Γ— β€” that is the entire quota argument for Β§2.6's fallback, and it is worth
1666
  approximately double the runs.
1667
 
 
 
 
 
 
 
 
 
 
1668
  Two further traps from Β§5.8: the hidden **1.5Γ— `duration_factor` on `large`** (so `duration=60`
1669
  schedules as 90 s; `xlarge` skips the factor but doubles the request instead), and the fact that
1670
  the **maximum duration is a server-side, tier-dependent, unpublished cap** β€” discover it, never
1671
  hardcode it. ~120 s is the empirical safe ceiling; the official Lightricks LTX Space ships
1672
- `@spaces.GPU(duration=75, size="xlarge")`.
 
1673
 
1674
  ### 8.6.1 Where Β§8 actually executes β€” and why the decorator is unconditional
1675
 
@@ -1711,6 +1906,16 @@ arithmetic entirely. Device strategy is selected in `config.py`, the `spaces` im
1711
  and the local path is expected to be **capability-limited rather than identical**. Do not assume
1712
  a code path that works on ZeroGPU works on MPS, or vice versa.
1713
 
 
 
 
 
 
 
 
 
 
 
1714
  ---
1715
 
1716
  ## 9. Testing strategy
@@ -2099,7 +2304,9 @@ run must be green with zero weights on disk.
2099
  Ranked by how much silent wrongness they prevent:
2100
 
2101
  1. **A LoRA for the wrong architecture is rejected** β€” specifically at stage 7 if it survives
2102
- stages 1–6 (Β§4.3).
 
 
2103
  2. **A generation that produces no file raises** β€” never returns an empty path, and there is no
2104
  newest-file fallback (Β§5.3).
2105
  3. **`denormalize=False` on the diffusion decode** β€” the double-denormalization corruption
@@ -2123,7 +2330,7 @@ register.
2123
  | # | Question | Resolution |
2124
  |---|---|---|
2125
  | **OQ-1** | Pin a diffusers release, or `main`? | **RESOLVED: pin the exact SHA** `ac56fa2f…` (Β§1.3). A SHA is more pinned than a range, not less. Plus a startup version assertion, because 0.39.0 fails *late*. |
2126
- | **OQ-2** | Does `diffusion_decoder` have a consumer? | **Moot** β€” the SHA provides it. Both `diffusion_decoder` (0.834) and `duration_head` (0.004) stay in the subset; duration prediction ships. |
2127
  | **OQ-3** | Is `num_frames % 8 == 1` enforced? | **RESOLVED: no.** Upstream silently floors. We raise; the modulus is a **parameter with an `8` fallback** for pre-load validation, plus a load-time tripwire (Β§5.5). |
2128
  | **OQ-4** | Gemma-3 or Gemma-4? | **CLOSED ON EVIDENCE: Gemma-4.** `model_index.json` says `text_encoder: ['transformers', 'Gemma4UnifiedForConditionalGeneration']`. The diffusers annotation is a union (`Gemma3ForConditionalGeneration \| Gemma4UnifiedForConditionalGeneration`); the *weights* resolve it. So CRF provably takes the `gemma4` branch β†’ **18**. **Still derive family and CRF at runtime; hardcode neither** (Β§5.7 #8). |
2129
  | **OQ-5** | Audio length from duration or latent shape? | **RESOLVED: latent shape wins.** Upstream computes it from duration, then overrides from `audio_latents.shape` when supplied. The desync is real and directional (Β§5.7 #11). |
@@ -2136,10 +2343,10 @@ register.
2136
  | **1** | ~~bf16 fits ZeroGPU's transient disk~~ β€” **SETTLED: it does not.** | **Not a risk any more, a finding.** The snapshot **IS** freed after packing (verified, `spaces` 0.51.1) β€” and the unlink runs *strictly after* `_pack()`, so the 144.37 GB peak precedes it, and with an 8–12 GB image the total is **152–156 GB against a 150 GB cap**. See Β§2.5 for the authoritative arithmetic. The ~68 GB RAM ceiling remains a community cgroup observation, separate and still open. | **No longer settled by measurement β€” it is settled.** The routes are persistent storage, a public Space with `preload_from_hub` (Β§6.2), or smaller checkpoints. All three are operator decisions, none is a knob we can turn. **ZeroGPU is parked; hinode is the critical path.** |
2137
  | 2 | ~~the packer handles quantised tensor subclasses~~ β€” **RESOLVED: it does, for bitsandbytes** | `spaces/zero/torch/bitsandbytes.py` no-ops for bnb β‰₯ 0.46.0, wired in at `patching.py:328/355/445`. **No equivalent module exists for torchao** β€” bnb is supported, torchao is not, and that decides the library. *Verified, `spaces` 0.51.1.* | Not a risk. Recorded because the asymmetry is invisible from outside. See `docs/ZEROGPU_DISK.md`. |
2138
  | 3 | ~~`preload_from_hub` 10-entry cap~~ | **RETIRED.** We are one repo β†’ one entry with comma-separated filenames. Fits comfortably (Β§6.2). | β€” |
2139
- | 4 | Max `@spaces.GPU` duration on our tier | server-side, tier-dependent, **unpublished** | discover empirically; never hardcode (Β§5.8 #4) |
2140
- | 5 | Multishot via prompt structure produces usable results | no API support, and the enhancer system prompts actively discourage scene cuts (Β§3.4) | presented to users as unverified technique, not a feature |
2141
- | **7** | ~~The diffusion decoder fetches NATTEN from the Hub at generation time~~ β€” **ANSWERED: once per process.** | βœ… **Measured on hinode**: two stage-2 generations in one process, **exactly one** kernel fetch. So a worker needs outbound network at its **first** stage-2 use, not on every press of Generate. | **Still a real dependency** β€” each cold worker pays it once, and `get_kernel("shi-labs/natten", version=1)` is hardcoded inside diffusers so we cannot pin it by revision. Lazy construction keeps it off the startup path for the eight modes that never reach stage 2. |
2142
- | 6 | An LTX-**2.3** LoRA attaches cleanly to the **2.5 distilled** transformer | the model card says most 2.3 LoRAs run on 2.5 unchanged, but our R3 fixture is a 2.3 LoRA and our transformer is 2.5-distilled; the official 2.5 LoRA targets the **DEV** transformer, so it is not a valid control | **TEST_PLAN R3** β€” stage 7 asserts attachment count > 0 against real weights |
2143
  | **8** | **`temporal_latent_upsampler` has no documented role** β€” we download 0.2619 GB and `preflight` carries a dedicated error path for it | It is the **same class** as the spatial one (`LTX2LatentUpsamplerModel`), differing only by `spatial_upsample`/`temporal_upsample` and `use_rational_resampler`. But upstream's component table lists **only** `latent_upsampler/` as belonging to the two-stage recipe, and neither documented recipe nor `LTX25AutoBlocks` mentions the temporal one. *Read off the model card at revision `871165de…` and the configs themselves, not inferred* | **Deliberately not wired.** Inventing a role for it in a graph upstream does not describe is worse than 0.26 GB of unused download. If it proves to be dead weight the allow-list can drop it β€” but on evidence, not on tidiness |
2144
 
2145
  > **Risk 1, re-read on 2026-08-25 β€” three of its clauses aged, differently.**
@@ -2151,6 +2358,10 @@ register.
2151
  > all eleven modes at sha `287ba9c` via the route the "how it gets settled"
2152
  > column did not list β€” int8 runtime quantization (`ZEROGPU_DISK.md` Option B),
2153
  > fitting at 82.2/150 [OK].
 
 
 
 
2154
 
2155
  ### βœ… Blocker cleared
2156
 
@@ -2158,7 +2369,8 @@ register.
2158
  `model_index.json`. Weights work is unblocked.
2159
 
2160
  Remaining access note, **not** a blocker: the Lightricks *LoRA* repos are separately gated and
2161
- still shut. Β§4.5 shows the ungated community LoRAs make a better R3 fixture anyway.
 
2162
 
2163
  ---
2164
 
 
1
  # LTX-2.5 Studio β€” Design Plan
2
 
3
+ **Status (2026-11-16):** implemented. After the 2026-11-16 fixes, ten of the eleven modes are
4
+ verified on real weights on a Mac (Apple silicon); none has been re-run on the Space, which still
5
+ runs the 2026-08-26 build. What has been verified, and how, is in
6
+ [`SPACE_MODE_MATRIX.md`](SPACE_MODE_MATRIX.md) Β§10. *(Originally: "implemented; not yet run on a
7
+ GPU. The matrix in `docs/TEST_PLAN.md` is what proves it works.")*
8
  **Branch:** `soma/ltx25-studio` Β· **Remote:** `git@github.com:techfreakworm/ltx2.5-studio.git`
9
  **Target:** private Hugging Face Space `techfreakworm/LTX2.5-Studio` (gradio SDK, ZeroGPU).
10
 
 
12
  > GPU" was true when written. Since then: **all eleven modes ran on hinode**
13
  > (704Γ—480Γ—121 baseline, stage 2 at 1408Γ—960, duration head f=97, LoRA both
14
  > directions, mel round-trip β€” [`OPERATOR_HANDOFF.md`](OPERATOR_HANDOFF.md) Β§2)
15
+ > and **all eleven execute on the live ZeroGPU Space** at sha `287ba9c`,
16
+ > 256Γ—256Γ—9 ([`SPACE_MODE_MATRIX.md`](SPACE_MODE_MATRIX.md)). *(Corrected
17
+ > 2026-11-16: this said "generate". Every Space output up to `ff142d9` was colour
18
+ > static, because the int8 build quantised the conditioning path; fixed at
19
+ > `eb1aa9f`.)* The line above is
20
  > kept because this document records how the build was *decided*; where the
21
  > project *stands* is the handoff's job. Where a decision below was overtaken β€”
22
  > the bf16 default (Β§2.6), the ~68 GB ceiling (Β§2), the explicit `size=`
 
76
  hand-maintained block of *custom-node deps we discovered are required but aren't auto-installed
77
  by their respective nodes* (`gguf`, `imageio_ffmpeg`, `opencv-python`, `matplotlib`,
78
  `scikit-image`, `onnxruntime`, `yt-dlp`). That comment block is the evidence: the dependency
79
+ surface was discovered by breakage, not by design. Diffusers replaces all of it with 19 direct
80
+ deps, each pinned to one version (Β§5.1), and zero custom-node surface.
81
 
82
  **Decisive coupling to Β§2.** The `*-comfy-int8-convrot` quantised weights are **ComfyUI-only**
83
  β€” the model card says so. Choosing A or C means those 36.9 GB of int8 weights are unusable to
 
189
  > died with the number (`SPACE_GENERATION_FINDING.md` Β§6). The disk row's
190
  > verdict stood for bf16 β€” and was then routed around: the deployed Space ships
191
  > **int8** (`ZEROGPU_DISK.md` Option B) and fits at **82.2 GB of 150 [OK]**.
192
+ >
193
+ > β›” **Corrected 2026-11-16, two rows.** (1) "82.2 GB of 150 [OK]" is a reading
194
+ > taken *before* ZeroGPU packs (packed term 0.0). On the 2026-11-13 boot the
195
+ > platform's progress bar read `40.6G` packed; the disk peak has never been measured.
196
+ > (2) The VRAM row assumed `xlarge`. Until 2026-08-26 the Space ran on the
197
+ > 47.375 GiB `large` partition (`auto` never promotes, Β§2.6), where stage 2 at
198
+ > 704Γ—480Γ—49 β€” 55.906 GiB reserved β€” could not fit: on `large`, VRAM *was* the
199
+ > problem. On `xlarge` (94.971 GiB, now the code's default) that is the largest
200
+ > peak measured, with ~39 GiB to spare.
201
 
202
  ### 2.1 Trap A β€” duplicate shard sets
203
 
 
243
  | `transformer/` | 37.9762 | index | the model (4 live shards + config + index) |
244
  | `text_encoder/` | 23.9195 | index | `Gemma4UnifiedForConditionalGeneration` (Β§10 OQ-4) |
245
  | `connectors/` | 6.3445 | index | text β†’ transformer conditioning; also a LoRA target |
246
+ | `vae/` | 1.4522 | index | video VAE: encodes conditions, and decodes wherever the diffusion decoder cannot run (Β§7.4) |
247
  | `latent_upsampler/` | 0.9957 | **subfolder** | stage-2 spatial upscale |
248
  | `diffusion_decoder/` | 0.8343 | index | **the native 2.5 decoder** β€” Β§7.4 |
249
  | `temporal_latent_upsampler/` | 0.2619 | **subfolder** | stage-2 temporal upscale |
 
418
  > ceiling, "uncertain but documented") is falsified besides
419
  > (`SPACE_GENERATION_FINDING.md` Β§6). The Β§6.2.1-class route list at the end of
420
  > this section omitted the route actually taken.
421
+ >
422
+ > β›” **Corrected 2026-11-16.** "ZeroGPU promoted to `xlarge` by inference" is wrong:
423
+ > `auto` never promotes (the block above this section's table), so the Space ran
424
+ > on `large` until `LTX25_ZEROGPU_SIZE=xlarge` was set as a Space variable on
425
+ > 2026-08-26. The code now defaults to `xlarge` (`config.DEFAULT_ZEROGPU_SIZE`),
426
+ > so `size="xlarge"` is declared explicitly after all β€” by default, not by a
427
+ > variable. "Packed ~51.1 GB": the platform's progress bar read `40.6G` on the
428
+ > 2026-11-13 boot. "82.2/150 [OK]" is a reading taken before packing.
429
 
430
  **⚠️ There is no precision switch, and the reason is a correction rather than a decision.**
431
  `LTX25_TRANSFORMER_PRECISION` and `LTX25_TEXT_ENCODER_PRECISION` existed, resolved cleanly, and
 
443
  option*; it
444
  is not a *configured* one, and the difference is now visible in the code rather than implied.
445
 
446
+ > β›” **Corrected 2026-11-16: there is a precision switch now, and it is wired.**
447
+ > `LTX25_QUANTIZATION` = `auto` (the default: int8 on ZeroGPU, bf16 everywhere else) |
448
+ > `bf16` | `int8`, resolved in `config.py` and `device.py`; int8 is bitsandbytes
449
+ > (pinned, Β§5.1) and is refused at startup off CUDA. The two removed variables stay
450
+ > removed.
451
+
452
  The routes actually available under disk pressure are persistent storage, a public Space, or
453
  smaller checkpoints β€” see Β§6.2.1.
454
 
 
457
  variant needing *different files* cannot be fetched on demand into that cache. If a future
458
  precision setting changes the file list, the Space must be rebuilt with a new `preload_from_hub`
459
  block. Setting the variable alone changes how the existing weights are loaded -- nothing more. This is **technical risk #1** (Β§10), and it is to be settled by
460
+ measurement on the Space, not by argument. *(2026-11-16: moot as built. int8 is applied at
461
+ load time to the same files, so changing `LTX25_QUANTIZATION` needs no new download and no
462
+ rebuild.)*
463
 
464
  ### 2.7 Output retention β€” 20 GB, evicted oldest-first
465
 
 
535
  | 10 | audio β†’ audio | condition | `audio_latents` + `noise_scale`, export only audio | ⚠️ same |
536
  | 11 | audio β†’ video | condition | `audio_latents` + `noise_scale`, export only video | ⚠️ pays audio encode on top |
537
 
538
+ > β›” **Corrected 2026-11-16, rows 4, 10 and 11.** One `noise_scale` also set the *video's*
539
+ > starting noise in the condition pipeline, which washed out audio β†’ video (measured on real
540
+ > weights). Now (`audio_conditioning.py`): **11** holds the supplied audio fixed while the
541
+ > picture is generated to it, and exports **video with that audio** (`exports=("audio",
542
+ > "video")`); **10** changes the supplied audio by one of the model's own levels (0.42, 0.73,
543
+ > 0.91, or 1.0, which ignores it). Row **4**'s mechanism was replaced on 2026-11-16 as well
544
+ > (`modes.py`, `video_conditioning="variation"`).
545
+ <!-- follow-up pass: describe row 4's new lever once the mode-04 change has been verified on real weights. -->
546
+
547
+ **Mandatory mitigation for modes 8–10:** run at the **minimum legal resolution**, **skip the
548
  stage-2 spatial upscale**, export only the requested track. The UI must say in words that
549
  audio-only modes still render video internally β€” a user who does not know that will read the
550
+ runtime as a bug. *(Corrected 2026-11-16: this said 8–11. Mode 11 returns video, so it gets
551
+ none of these mitigations, `modes.py`.)*
552
 
553
  ### 3.4 Multishot β€” **downgraded to honest**
554
 
 
561
 
562
  (Superseding an earlier draft of this plan that called it a first-class affordance. It is not.)
563
 
564
+ > β›” **Corrected 2026-11-16: the UI no longer offers a shot list.** Its rows fed the
565
+ > prompt-segment *text* to the pipeline as frames, which fails in the worker; it never worked
566
+ > on real weights. The API keeps its `conditions` slot, and rows that carry text instead of
567
+ > media are refused before a GPU is reserved (`generate.scope_request_to_mode`).
568
+
569
  ### 3.5 Prompt enhancement: **ships, as a real toggle, default off**
570
 
571
  > ⚠️ **This section is a correction.** It read "unavailable by default; we ship no dead
 
595
  **βœ… And the download is 2.49 GB.** `google/gemma-4-E2B-it-qat-mobile-transformers` is the
596
  quantisation-aware-trained build: public, ungated, one `model.safetensors`, **2.490 GB**
597
  against **10.279 GB** for the bf16 `google/gemma-4-E2B-it`. Its `config.json` carries
598
+ `quantization_config.quant_method == "gemma"`, which `transformers` registers as
599
+ `GemmaQuantizer` from 5.15.1 on; the unpacking layers it installs are plain torch with no CUDA
600
+ or kernel dependency, which is what lets it run on the CPU. *(Corrected 2026-11-16: this said
601
+ 5.15.1 was "already the floor in `requirements.txt`". The file now pins `transformers==5.23.0`
602
+ exactly (Β§5.1), whose loader refuses one per-layer scale table of this checkpoint, so
603
+ `enhance.py` reads that one weight back from the cached checkpoint and refuses any other
604
+ mismatch.)*
605
  ⚠️ It has **no** top-level `architectures` key, so `AutoModel*` cannot dispatch on it and
606
  `Gemma4ForConditionalGeneration` must be named explicitly. `LTX25_PROMPT_ENHANCER_REPO`
607
  selects the repo; the bf16 build is one environment variable away.
 
655
  speed: ~1-2 s of billed wall against ~85 s for a real generation, **under 5% overhead** where
656
  the CPU placement was +3500%.
657
 
658
+ > β›” **Corrected 2026-11-16: "~1-2 s" is the decode alone.** Loading the enhancer in a fresh
659
+ > worker takes about 29 s, and the reservation grows by `ENHANCE_DURATION_SECONDS` = **180 s**
660
+ > for every enhanced run, because the estimator cannot know whether the worker is warm
661
+ > (`zerogpu.py`). The pre-check needs that reservation Γ— 2 of quota free on `xlarge`.
662
+
663
  **What that costs, and what now pays for it.** Enhancement is inside the reservation, so
664
  `zerogpu.estimate_duration` adds `ENHANCE_DURATION_SECONDS` when the toggle is set β€” an
665
  enhanced run killed at the reservation boundary would be a self-inflicted wound β€” and the UI
666
+ caption gives up "costs no quota" to be honest about "no longer costs nine minutes". *(It then
667
+ said "a second or two of quota", which was also wrong. Since 2026-11-16 it says the run
668
+ reserves 180 s more and usually uses a few seconds.)*
669
 
670
  **And the download is prefetched, because it would otherwise be billed.** Without it the
671
  first enhanced call in each container spends the 88 s Hub fetch *inside* the metered window:
 
683
  enhancement β€” it lands while `demo.launch()` is packing, which is the window
684
  `ZEROGPU_DISK_CAP_GB` is measured against.
685
 
686
+ > β›” **Corrected 2026-11-16: on the deployed build the prefetch failed on every boot**
687
+ > (`AttributeError: 'tqdm' object has no attribute '_progress'`, in the 2026-11-13 log): the
688
+ > UI's `gr.Progress(track_tqdm=True)` patched tqdm process-wide and broke the prefetch's
689
+ > progress bars. The degraded path was the normal one, so the first enhanced run in each
690
+ > container paid the download inside its reservation. The UI no longer installs that patch
691
+ > (`ui/blocks.py`); a prefetch that works on the Space is not verified yet.
692
+
693
  The settings, unchanged from what this section banked in advance and now imported from
694
  upstream rather than restated: `prompt_max_new_tokens=600`, **greedy decoding**
695
  (`do_sample=False, no_repeat_ngram_size=5`), `prompt_enhancement_seed` **inert under greedy
 
947
  download. A user who pastes a repo-id for a 2B-architecture adapter gets a specific rejection in
948
  about a second instead of after a 300 MB download. Stage 1 comes free from `Content-Length`.
949
 
950
+ > β›” **Corrected 2026-11-16: the range-read is not built.** `lora/fetch.py` checks the size from
951
+ > the listing, then downloads, then validates: a wrongly-built adapter costs one bounded,
952
+ > cached download (its docstring says so).
953
+
954
  **Upload route:** the bytes are already local, so the same parser runs against the file. Both
955
  routes converge on one code path, which is what Β§4.3 asks for.
956
 
 
963
 
964
  Binding on all code in the repo.
965
 
966
+ ### 5.1 Pin every dependency to one exact version β€” and know what NOT to pin
967
 
968
  Evidence from the predecessor: `spaces>=0.30.0` and `torch>=2.4.0` β€” floors with **no ceiling**
969
  β€” alongside exactly one hard pin, `torchaudio==2.10.0`, carrying this comment:
 
974
  That comment is a post-mortem, applied to one line while ~50 stayed unbounded.
975
 
976
  **But the inverse mistake is also real, and the 2.3 repo made it.** Its own `AGENTS.md:19` says
977
+ **do not pin `spaces`** β€” the platform installs its own version, and a conflicting pin breaks pip
978
+ resolution at build time (in August, live Spaces reported 0.49.3 / 0.50.0 / 0.50.4 while PyPI had
979
+ 0.51.1; this Space reports 0.51.3 on 2026-11-16, and PyPI has had 0.52.0 since 2026-11-13). Its
980
  `requirements.txt:2` then pins `spaces>=0.30.0` anyway. We follow the rule the repo wrote and
981
+ did not keep: **no `spaces` line in `requirements.txt`**. `app.py` guards the import
982
+ (`try: import spaces`, and on `ImportError` the local stub `zerogpu.local_spaces_stub()`, whose
983
+ `GPU` returns the function unchanged), so local dev works without it.
984
+
985
+ > **Corrected 2026-11-16: every line is now ONE exact version, not a range.** This section used
986
+ > to give each dependency a floor and a ceiling. A range is resolved again on every Space
987
+ > rebuild, so the image gets whatever is newest that day instead of what was tested; on
988
+ > 2026-11-16 a fresh resolution gave transformers 5.23.0, on which the pinned prompt enhancer
989
+ > did not load. `requirements.txt` now pins the versions the real-weights runs of 2026-11-16
990
+ > used, and `tests/test_requirements_exact.py` fails on any range (its only exemption is a line
991
+ > marked `# platform-provided`). Those runs were on Apple silicon with PyTorch 2.15.0, so the
992
+ > CUDA-only lines below β€” the torch trio as the Space installs it, `bitsandbytes`, `kernels` β€”
993
+ > have no real-weights evidence under these pins until the Space runs. In particular the
994
+ > bitsandbytes int8 load of the transformer and the text encoder under transformers 5.23.0 has
995
+ > not run yet.
996
+
997
+ The full pin set, as `requirements.txt` has it:
998
 
999
  | package | pin | why |
1000
  |---|---|---|
1001
+ | `torch` | `==2.11.0` | ZeroGPU supports exactly 2.8.0 / 2.9.1 / 2.10.0 / **2.11.0**; ceiling is 2.11.0. CUDA 12.8, sm_120 needs cu128+. Not for local Apple-silicon runs: 2.11 computes attention wrongly on MPS (README, "Run it locally") |
1002
  | `torchvision` | `==0.26.0` | **trap:** `torchvision 0.28.0` hard-declares `torch==2.13.0`, so a floating torchvision silently upgrades torch past the ceiling |
1003
  | `torchaudio` | `==2.11.0` | must match torch exactly (the ABI break above) |
 
1004
  | `diffusers` | `@ git+…@ac56fa2f…` | Β§1.3 |
1005
+ | `transformers` | `==5.23.0` | the version the 12B text encoder and the pipelines ran with on real weights. Its loader refuses one per-layer scale table of the prompt enhancer's checkpoint, so `enhance.py` reads that one weight back from the cached checkpoint and refuses any other mismatch |
1006
+ | `tokenizers` | `==0.23.3` | pinned beside transformers because it decides whether transformers imports at all |
1007
+ | `accelerate` | `==1.15.0` | |
1008
+ | `peft` | `==0.20.0` | LoRA backend |
1009
+ | `safetensors` | `==0.8.0` | |
1010
+ | `huggingface_hub` | `==1.33.0` | |
1011
+ | `hf_xet` | `==1.8.0` | |
1012
+ | `kernels` | `==0.16.2` | fetches the NATTEN kernel the diffusion decoder needs; CUDA only |
1013
+ | `bitsandbytes` | `==0.50.2` | the int8 route on ZeroGPU. Must stay above 0.46.0, below which the packer tries to move quantised tensors itself |
1014
+ | `gradio` | `==6.24.0` | must equal the README's `sdk_version` (a drift test asserts it). **5.x is END OF LIFE** (last stable 5.50.0, 2025-11-21) |
1015
+ | `imageio` | `==2.38.1` | |
1016
+ | `imageio-ffmpeg` | `==0.6.0` | |
1017
+ | `av` | `==18.1.0` | PyAV β€” required by CRF re-compression (Β§5.7) |
1018
+ | `numpy` | `==2.5.5` | **numpy 2.** Do NOT go back to 1.x: 1.26.4 is 2 years EOL and nothing in the stack caps it |
1019
+ | `pillow` | `==12.3.0` | |
1020
+ | `spaces` | **absent, deliberately** | the platform installs it; see above |
1021
+
1022
+ **The named fallback.** If the int8 load misbehaves on the Space, the fallback is
1023
+ `transformers==5.22.2` with exactly the same companion pins (the header of `requirements.txt`
1024
+ says so). On 5.22.2 the enhancer's checkpoint loads as stored and nothing is read back.
1025
 
1026
  **gradio 6 breaking changes that hit us:** `gr.Video` subtitle-tuple return removed;
1027
  `show_download_button` / `show_share_button` β†’ `buttons=[...]`; `gr.Audio` `show_controls` β†’
1028
  `show_recording_waveform`; `min_length` / `max_length` β†’ event-listener validators.
1029
 
1030
+ **Python 3.12 is required, not preferred:** numpy 2.5.5 needs β‰₯3.12 and `av` 18.1.0 needs β‰₯3.11
1031
+ (their `Requires-Python`). The default 3.10.13 image resolved both *downward* when the pins were
1032
+ ranges; with exact pins it fails the build instead.
1033
 
1034
  ### 5.2 One central model-file indirection
1035
 
 
1043
  Pinning a **revision** per repo is part of this module's job β€” a repo whose content can change
1044
  under us is not pinned just because its name is stable.
1045
 
1046
+ > **Corrected 2026-11-16: two things live elsewhere.** The quantization choice is
1047
+ > `LTX25_QUANTIZATION`, resolved in `config.py`/`device.py` and applied in `pipelines.py`, not
1048
+ > here. The prompt enhancer is outside this module by design (Β§3.5) and is pinned on its own
1049
+ > (`enhance.ENHANCER_REVISION`). The diffusion decoder has its own revision here (`aba1b702`,
1050
+ > the vendor's corrected upload of 2026-10-08); every other component stays at `871165de`.
1051
+ > One revision is still not ours to pin: the NATTEN kernel the diffusion decoder fetches
1052
+ > (`version=1`, hard-coded upstream).
1053
+
1054
  **New requirement: `model_files.py` emits the download allow-list as data.** It must be able to
1055
  produce the exact list of **37 paths** (Β§2.3), so that:
1056
 
 
1142
  |---|---|---|
1143
  | `height % 32 == 0`, `width % 32 == 0` | enforced upstream (raises) in all generation pipelines *and* the latent-upsample pipeline | validate before the call, snap in the UI, **show** the snapped value |
1144
  | `num_frames % 8 == 1` | **not** hard-raised upstream. Falls out of `latent_num_frames = (num_frames - 1) // vae.temporal_compression_ratio + 1`, which **silently floors** a bad value | we raise. **The `8` is `vae.temporal_compression_ratio`** β€” see below |
1145
+ | audio/video length agreement | audio and video lengths are computed independently, and a supplied `audio_latents` **overrides** the duration-derived audio length (Β§5.7) | validate they agree; raise rather than emit a desynced file. *(As built, 2026-11-16: in a mode that takes audio, a set length longer than the audio is refused before a GPU is reserved, and audio longer than the video is trimmed with a note, never padded; automatic length there means "match my audio", taken from the file, because the duration head reads only the text. `generate.py`)* |
1146
 
1147
  **The `num_frames` modulus is a parameter, not a literal.** Hardcoding `8` would violate Β§5.4.
1148
  Resolution:
 
1176
  `"Workload evicted, storage limit exceeded (150G)"` into a diagnosable message that names the
1177
  fix. It also runs the Β§1.3 diffusers-version assertion. Test case.
1178
 
1179
+ > β›” **Corrected 2026-11-16: only half of this exists.** `preflight.py` checks the diffusers
1180
+ > version and that the weights are complete, and the startup report logs the disk floor; it
1181
+ > measures no free RAM, on the Space or anywhere (its docstring still promises it). A memory
1182
+ > preflight exists for **local** runs only: `memory.py` checks committed memory plus what the
1183
+ > next load or the denoise will add against a limit (`LTX25_MEMORY_LIMIT_GB`, 90 GB on macOS by
1184
+ > default) and refuses with the numbers.
1185
+
1186
  **The startup report** (`pipelines.startup_report`) prints, before anything expensive:
1187
 
1188
  ```
 
1203
  > `quantised transformer, text_encoder as int8 | peak RSS 0.91 -> 87.13 GiB`
1204
  > β€” captured in `SPACE_GENERATION_FINDING.md` Β§5 and `OPERATOR_HANDOFF.md` Β§5.
1205
  > The load-bearing line survives unchanged: the live Space reads `37/37 files`.
1206
+ >
1207
+ > β›” **Stale again (corrected 2026-11-16).** The report was rewritten: it no longer prints
1208
+ > `dtype : bf16 (fixed; …)`, which was false under int8, but `device`, `precision` and
1209
+ > `runner` lines resolved from the configuration; `packed copy : not measured yet, ZeroGPU
1210
+ > writes it at launch after this report`; and `zerogpu size : requested xlarge; reservation
1211
+ > 180 s per run (x1.5 with stage 2, +60 s with LoRAs, +180 s with prompt enhancement)`. The old
1212
+ > `zerogpu size : not yet known (reported after packing)` was never followed by a report. The
1213
+ > new report has not run on the Space yet.
1214
 
1215
  The **cache count is the load-bearing line**: `36/37`, with the first missing file named, makes
1216
  "preload worked" and "preload silently did nothing" two different sentences. When a GPU run fails
 
1249
  | 1 | **ZeroGPU quota attribution rides a contextvar** (`gradio.context.LocalContext.request`). It does **not** cross a plain `threading.Thread` β€” without it every user is bucketed as Space-anonymous and you get *"Space app has reached its GPU limit"* at **0 minutes used** | any thread we spawn must carry `contextvars.copy_context()`; better, do not spawn plain threads across the GPU boundary |
1250
  | 2 | The `duration=` callable must accept **the exact same positional signature** as the decorated function, trailing kwargs included | otherwise TypeError at schedule time; test the signature match |
1251
  | 3 | **Hidden 1.5Γ— duration multiplier on `large`** (`duration_factor`): `duration=60` is scheduled as 90 s. On `xlarge` the factor is skipped but the request is **doubled** instead | never reason about wall-clock quota from the `duration=` number alone |
1252
+ | 4 | Default duration is 60 s. The **max is a server-side, tier-dependent, unpublished cap** | **discover it, never hardcode it.** Empirically ~120 s is the safe ceiling; the official Lightricks LTX Space ships `@spaces.GPU(duration=75, size="xlarge")`. *(Corrected 2026-11-16: this app's base reservation is now 180 s, `LTX25_GPU_DURATION_SECONDS`, and `zerogpu.estimate_duration` can ask for up to 510 s: Γ—1.5 with stage 2, +60 s with LoRAs, +180 s with the enhancer. The server's maximum is still not known.)* |
1253
  | 5 | **Do NOT auto-retry a ZeroGPU timeout** using the captured Gradio request: the `X-IP-Token` ages past TTL during attempt 1, so attempt 2 always 401s with *"Expired ZeroGPU proxy token"* β€” **masquerading as the root cause** | surface the original timeout; never retry behind the user's back |
1254
  | 6 | `preload_from_hub` is **capped at 10 entries**, and preloaded files are owned by the *build* user and **read-only to runtime uid 1000** β€” a later lazy `hf_hub_download` fails with `Permission denied (os error 13)` unless the cache is mirrored | Β§6.2 |
1255
  | 7 | Accumulated generations filled the 2.3 Space's disk and it went unhealthy | Β§2.7 β€” sweep on startup and after each run |
 
1264
  | **SDK** | `sdk: gradio`, `sdk_version: 6.24.0` β€” **a custom Dockerfile forfeits ZeroGPU entirely** |
1265
  | **Python** | `python_version: "3.12"` β€” required, not optional (Β§5.1) |
1266
  | **Hardware** | ZeroGPU. `suggested_hardware: zero-a10g` is the **legacy id string the Spaces API still reports β€” it is NOT an A10G** (Β§8.1) |
1267
+ | **Size** | `size="xlarge"` declared explicitly (Β§8.6): `LTX25_ZEROGPU_SIZE` defaults to `xlarge` |
1268
+ | **Weights** | downloaded at startup by `preflight.ensure_weights()` (Β§6.2). `preload_from_hub:` is disabled: it cannot fetch a gated repo for a private Space |
1269
  | **Secret** | `HF_TOKEN` β€” required; `Lightricks/LTX-2.5-Diffusers` is gated |
1270
  | **Git** | GitHub `git@github.com:techfreakworm/ltx2.5-studio.git`; Space and GitHub stay in sync |
1271
 
1272
  > **On the Size row (annotated 2026-08-25):** never declared in practice β€”
1273
  > every deploy has run `auto`, and the live Space was promoted to `xlarge` by
1274
  > inference. Β§8.6's annotation carries the detail.
1275
+ >
1276
+ > β›” **Corrected 2026-11-16:** not "by inference" β€” `auto` never promotes, so the Space
1277
+ > ran on the 47.375 GiB `large` partition until `LTX25_ZEROGPU_SIZE=xlarge` was set as a
1278
+ > Space variable on 2026-08-26 (Β§8.6). The code now defaults to `xlarge`, so the row holds
1279
+ > as written even without the variable. The Weights row is corrected in place: the
1280
+ > download moved to startup when `preload_from_hub` failed on the private Space.
1281
 
1282
  Naming precedent: `techfreakworm/LTX2.3-Studio`, `wan-studio` (private), `SAM3-cutout-studio`
1283
  (private).
 
1329
  There is **no persistent storage**, so the full **72.186 GB** is refetched on
1330
  every cold start β€” restart, rebuild, or 48 hours idle. `startup_duration_timeout:
1331
  1h` covers it. **This is accepted for the development phase**, not endorsed.
1332
+ *(Still so on 2026-11-16: storage None, `gcTimeout` 48 h. The cold start of 2026-11-13 took
1333
+ 13 min 59 s to serving, about 11.5 min of it this download.)*
1334
 
1335
  Two routes back to preloading, either of which restores it:
1336
 
 
1420
  `LTX-2.3-22b-IC-LoRA-*` are each gated on their own acceptance and the token does not have
1421
  them. This is **not** a blocker: Β§4.5 shows the ungated community LoRAs are a *better* R3
1422
  fixture anyway, because they are what users actually upload. Recorded so nobody is surprised
1423
+ when an official IC-LoRA 403s. *(Checked in August; not re-checked since.)*
1424
 
1425
  **Local reality check:** the gate being open does not mean we can generate locally. The 22B
1426
  model does not run on macOS. Real generations happen on the Space, under the quota discipline
1427
  in [`docs/TEST_PLAN.md`](TEST_PLAN.md).
1428
 
1429
+ > β›” **Corrected 2026-11-16: it runs on Apple silicon now.** With a separate PyTorch 2.15
1430
+ > environment, the Q8_0 GGUF transformer and staged residency (the text encoder and the
1431
+ > transformer are never resident together), ten of the eleven modes are verified on real
1432
+ > weights on a 128 GB Mac ([`SPACE_MODE_MATRIX.md`](SPACE_MODE_MATRIX.md) Β§10.2; how to run it:
1433
+ > the README). Upscale Γ—2, the diffusion decoder and int8 still need CUDA, so they are checked
1434
+ > on the Space only.
1435
+
1436
  ---
1437
 
1438
  ## 7. Architecture
 
1442
  ```
1443
  app.py # entrypoint. `import spaces` FIRST (Β§8.2), then build + launch.
1444
  ltx25_studio/
1445
+ config.py # every LTX25_* setting, resolved and validated: GPU size, duration,
1446
+ # quantization, device, retention cap (Β§2.7), paths
1447
+ device.py # LTX25_DEVICE (cuda/mps/cpu), dtype and int8 per device, the MPS
1448
+ # numerics self-test, RoPE on the CPU for MPS
1449
+ model_files.py # Β§5.2 β€” THE single source of truth: repo ids, revisions (one per
1450
+ # component where they differ), subfolders, filenames, sizes
1451
  errors.py # typed exception hierarchy; every error carries an actionable detail
1452
+ preflight.py # weights complete (or the local runner's files present);
1453
+ # Β§1.3 β€” the diffusers-version fail-fast assertion. No RAM check
1454
+ memory.py # local runs: committed memory + the next step vs a limit (Β§5.6)
1455
+ local_runtime.py # local runs on mps/cpu: GGUF transformer, staged residency
1456
  zerogpu.py # Β§8 β€” the `spaces` shim, the static @spaces.GPU policy, the
1457
  # duration callable, contextvar propagation, and the
1458
  # "never return CUDA tensors" boundary
 
1463
  # conversion (Β§5.7 #1); uint8/PIL normalisation (Β§5.7 #7)
1464
  audio.py # waveform <-> mel <-> audio_vae latents; params from config (Β§5.4);
1465
  # vocoder decode
1466
+ audio_conditioning.py # supplied audio held fixed or varied by a level, on its own schedule
1467
  modes.py # Β§3.3 registry: 11 UI modes as data over the 4 real workflows
1468
  generate.py # Β§7.4 stage graph. OWNS the never-empty invariant (Β§5.3) and the
1469
  # per-run output directory
 
1473
  outputs.py # mux video+audio, single-track export, 20 GB oldest-first eviction
1474
  lora/
1475
  inspect.py # header-only safetensors parse; metadata + convention detection
1476
+ validate.py # validator stages 1-6.5 (Β§4.3)
1477
  apply.py # load_lora_weights, stage-7 attach assertion, both-component fusing
1478
+ fetch.py, keys.py, manifest.py, staging.py
1479
+ # Hub fetch + bounded cache, where each key lands (diffusers'
1480
+ # renames), the shape manifest stage 6.5 checks, staged adapters
1481
  ui/
1482
  blocks.py # Gradio Blocks assembly
1483
  components.py # reusable widgets (condition list, LoRA picker, constraint hints)
1484
  handlers.py # thin adapters: UI event -> one call -> UI update. No logic.
1485
+ fields.py, render.py, chrome.py, showcase.py, uploads.py
1486
+ # field specs, user-facing strings, styling, examples and samples,
1487
+ # app-owned copies of uploaded LoRA files
1488
  ```
1489
 
1490
+ *(Corrected 2026-11-16 in place: `device.py`, `memory.py`, `local_runtime.py`,
1491
+ `audio_conditioning.py` and the extra `lora/` and `ui/` modules were missing; device selection
1492
+ moved out of `config.py`, the quantization switch is not in `model_files.py`, and `preflight.py`
1493
+ has no RAM check.)*
1494
+
1495
  ### 7.2 Layering rules
1496
 
1497
  - **Dependencies point inward.** `ui/` may import anything; `generate.py` must not import `ui/`.
 
1534
 
1535
  **Decision: classic pipelines, with the diffusion decode added as an explicit stage.**
1536
 
1537
+ > β›” **Corrected 2026-11-16: as built until today, only half of this happened.** The diffusion
1538
+ > decode was wired into the stage-2 branch alone, and stage 2 is off by default, so every
1539
+ > default run decoded with the convolutional VAE β€” exactly the silent loss described above.
1540
+ > Now the decoder is a per-run choice, `LTX25_DECODER` (`auto` by default): `auto` decodes with
1541
+ > the diffusion decoder where it can run β€” CUDA, its kernel available, a video large enough
1542
+ > for it β€” and with the conv VAE otherwise, and the run says which. Modes that discard their
1543
+ > video always use the conv VAE. The decoder's weights are pinned to the vendor's corrected
1544
+ > upload (`aba1b702`, Β§5.2). None of this has run on the Space yet; off CUDA (a Mac) every
1545
+ > run decodes with the conv VAE.
1546
+
1547
  ```
1548
  stage 1 LTX2ConditionPipeline(..., sigmas=DISTILLED_SIGMA_VALUES,
1549
  output_type="latent")
 
1621
  > 150 [OK]**, prune freed 65.25 GB, all eleven modes generating at sha
1622
  > `287ba9c`. The finding itself stands: bf16 on `storage: None` remains
1623
  > structurally infeasible β€” which is exactly why the live Space is not bf16.
1624
+ >
1625
+ > β›” *Corrected 2026-11-16:* "82.2 GB of 150 [OK]" is a reading taken before packing (the
1626
+ > platform's progress bar read `40.6G` packed on the 2026-11-13 boot; the disk peak was never
1627
+ > measured), and at
1628
+ > `287ba9c` the eleven modes *executed*: every output up to `ff142d9` was colour static.
1629
 
1630
  **The base is always the superset class**, `LTX2ConditionPipeline`. Deriving
1631
  superset β†’ subset can only drop `audio_scheduler`, which the subset does not
 
1654
 
1655
  The modular path is recorded here as **the canonical alternative**: if we move to it, the decode
1656
  block is swappable exactly as the docstring describes, and `vae/` (1.452 GB) stays in the subset
1657
+ as the conv-VAE fallback either way. *(Corrected 2026-11-16: until today the conv VAE was not a
1658
+ fallback but the decoder of every default run; see the correction under "Decision" above.)*
1659
 
1660
  ---
1661
 
 
1680
  **VRAM is not our constraint.** 67.2 GiB of weights against `xlarge`'s ~95 GiB leaves ~28 GiB
1681
  for activations. The constraints are CPU RAM and transient disk (Β§2).
1682
 
1683
+ > β›” **Corrected 2026-11-16:** only on `xlarge`, and the Space did not get `xlarge` until
1684
+ > 2026-08-26 (`auto` never promotes, Β§8.6). On the measured 47.375 GiB `large` partition,
1685
+ > stage 2 at 704Γ—480Γ—49 (55.906 GiB reserved) could not fit. On `xlarge` (94.971 GiB, now the
1686
+ > code's default) the largest peak measured leaves ~39 GiB.
1687
+
1688
  ### 8.2 Import order is load-bearing
1689
 
1690
  ```python
 
1713
 
1714
  HF's guidance, quoted: **models must be placed on cuda at the root module level.**
1715
 
1716
+ > β›” **Corrected 2026-11-16: step 2's timing is wrong, and Β§3.5 has it right.** The module-scope
1717
+ > `.to("cuda")` registers the tensors; the packing itself runs once, at `demo.launch()`
1718
+ > (`torch.pack()` in `spaces/zero/__init__.py`). The 2026-11-13 boot log shows it: a disk
1719
+ > reading labelled "after packing" with `packed 0.0`, then the platform's own progress bar
1720
+ > packing `40.6G`, then "Cleaned 65.25GB of tensor files … after packing" 29 s later. The
1721
+ > startup report was relabelled accordingly (Β§5.6).
1722
+
1723
  ##### ⚠️ The snapshot is freed after packing β€” but only if the mmap survives
1724
 
1725
  Read from `spaces` 0.51.1 (`zero/torch/patching.py:395`) rather than inferred:
 
1755
  Steady state afterwards is fine at ~72 GB. **It is the peak that evicts us, not
1756
  the residency.**
1757
 
1758
+ > *Observed 2026-11-13, recorded 2026-11-16:* under int8, 1344 transformer and 331 text-encoder
1759
+ > parameters are materialised into anonymous memory (the app logs a warning for them), and the
1760
+ > boot still cleaned 65.25 GB. So precondition 1 does not hold per tensor; most likely a blob is
1761
+ > unlinked while any of its tensors is still mapped. Not verified beyond that one log.
1762
+
1763
  **Corollary: do NOT lazy-load models inside the decorated function.** HF documents that
1764
+ placements are optimised for startup; lazy loading defeats the packer entirely. *(As built,
1765
+ two exceptions are deliberate: the stage-2 parts and the prompt enhancer load lazily inside the
1766
+ worker, to keep them out of the packing window, and pay a per-worker load instead (Β§3.5).)*
1767
 
1768
  ##### Considered and rejected: deferring the second workflow
1769
 
 
1839
  > GiB**. Β§8.6's original instruction β€” *declare the size explicitly rather than
1840
  > being silently promoted* β€” was right on the first try and was talked out of by
1841
  > a threshold reading. Trace: [`MIG_ALLOCATOR_SIGHTINGS.md`](MIG_ALLOCATOR_SIGHTINGS.md) Β§1.
1842
+ >
1843
+ > βœ… **And since 2026-11-16 it is the code's default:** `LTX25_ZEROGPU_SIZE` defaults to
1844
+ > `xlarge` (`config.DEFAULT_ZEROGPU_SIZE`), so a Space that loses the variable still asks for
1845
+ > the full GPU. The int8 packed size the 2026-08-25 annotation estimated at ~51.1 GB was
1846
+ > `40.6G` on the platform's own progress bar (2026-11-13 boot).
1847
 
1848
  **Quota arithmetic:** PRO gives 2400 s/day. At `duration=75` on `xlarge` (2Γ—), each run is
1849
  charged ~150 s β†’ **~16 runs/day**. Dropping under 42.00 GiB via quantization would return us to
1850
  `large` at 1Γ— β€” that is the entire quota argument for Β§2.6's fallback, and it is worth
1851
  approximately double the runs.
1852
 
1853
+ > β›” **Corrected 2026-11-16: both halves of that paragraph are wrong.** (1) The tier follows the
1854
+ > `size` passed, not the packed size: the Space is quantised *and* explicitly `xlarge`, so
1855
+ > dropping under 42.00 GiB would buy nothing. (2) The reservation is not 75 s. It is
1856
+ > `zerogpu.estimate_duration`: the base `LTX25_GPU_DURATION_SECONDS` (180 s by default and on
1857
+ > the Space), Γ— 1.5 with stage 2, + 60 s with LoRAs, + 180 s with prompt enhancement, so 180 to
1858
+ > 510 s. Billing is the GPU time actually used Γ— 2 on `xlarge` (Hugging Face's documented rate;
1859
+ > not measurable here, no quota endpoint answers), so a runs-per-day figure depends on what each
1860
+ > run uses and is not stated here. To start, a run needs its reservation Γ— 2 of quota free.
1861
+
1862
  Two further traps from Β§5.8: the hidden **1.5Γ— `duration_factor` on `large`** (so `duration=60`
1863
  schedules as 90 s; `xlarge` skips the factor but doubles the request instead), and the fact that
1864
  the **maximum duration is a server-side, tier-dependent, unpublished cap** β€” discover it, never
1865
  hardcode it. ~120 s is the empirical safe ceiling; the official Lightricks LTX Space ships
1866
+ `@spaces.GPU(duration=75, size="xlarge")`. *(Corrected 2026-11-16: this app now asks for
1867
+ 180–510 s, see above; the server's maximum is still not known.)*
1868
 
1869
  ### 8.6.1 Where Β§8 actually executes β€” and why the decorator is unconditional
1870
 
 
1906
  and the local path is expected to be **capability-limited rather than identical**. Do not assume
1907
  a code path that works on ZeroGPU works on MPS, or vice versa.
1908
 
1909
+ > **As built, 2026-11-16.** The device is chosen in `device.py`: `LTX25_DEVICE` = `auto`
1910
+ > (CUDA where it exists, otherwise no generation device: the UI starts and Generate says how
1911
+ > to opt in) | `cuda` | `mps` | `cpu`. On `mps`/`cpu` real weights go to `local_runtime.py`:
1912
+ > the GGUF transformer through diffusers' own loader, staged residency (text encoder and
1913
+ > transformer never resident together), RoPE computed on the CPU in float64, a memory
1914
+ > preflight before every heavy step (`memory.py`), and an MPS numerics self-test that refuses
1915
+ > a PyTorch which computes wrongly on this GPU (2.11 does; 2.15.0 is what was verified).
1916
+ > Capability-limited as predicted: Upscale Γ—2, the diffusion decoder and bitsandbytes int8 need
1917
+ > CUDA. Verified on real weights for ten of eleven modes (`SPACE_MODE_MATRIX.md` Β§10.2).
1918
+
1919
  ---
1920
 
1921
  ## 9. Testing strategy
 
2304
  Ranked by how much silent wrongness they prevent:
2305
 
2306
  1. **A LoRA for the wrong architecture is rejected** β€” specifically at stage 7 if it survives
2307
+ stages 1–6 (Β§4.3). *(Corrected 2026-11-16: Β§4.3 is right and this line was not. Stage 6.5
2308
+ is the gate β€” per-module shape fit, now checked at Validate time against a checked-in shape
2309
+ manifest, with no weights β€” and stage 7's attach count is the second line, not the first.)*
2310
  2. **A generation that produces no file raises** β€” never returns an empty path, and there is no
2311
  newest-file fallback (Β§5.3).
2312
  3. **`denormalize=False` on the diffusion decode** β€” the double-denormalization corruption
 
2330
  | # | Question | Resolution |
2331
  |---|---|---|
2332
  | **OQ-1** | Pin a diffusers release, or `main`? | **RESOLVED: pin the exact SHA** `ac56fa2f…` (Β§1.3). A SHA is more pinned than a range, not less. Plus a startup version assertion, because 0.39.0 fails *late*. |
2333
+ | **OQ-2** | Does `diffusion_decoder` have a consumer? | **Moot** β€” the SHA provides it. Both `diffusion_decoder` (0.834) and `duration_head` (0.004) stay in the subset; duration prediction ships. *(2026-11-16: until today its only consumer was stage 2; it now decodes single-stage runs too, on CUDA, Β§7.4.)* |
2334
  | **OQ-3** | Is `num_frames % 8 == 1` enforced? | **RESOLVED: no.** Upstream silently floors. We raise; the modulus is a **parameter with an `8` fallback** for pre-load validation, plus a load-time tripwire (Β§5.5). |
2335
  | **OQ-4** | Gemma-3 or Gemma-4? | **CLOSED ON EVIDENCE: Gemma-4.** `model_index.json` says `text_encoder: ['transformers', 'Gemma4UnifiedForConditionalGeneration']`. The diffusers annotation is a union (`Gemma3ForConditionalGeneration \| Gemma4UnifiedForConditionalGeneration`); the *weights* resolve it. So CRF provably takes the `gemma4` branch β†’ **18**. **Still derive family and CRF at runtime; hardcode neither** (Β§5.7 #8). |
2336
  | **OQ-5** | Audio length from duration or latent shape? | **RESOLVED: latent shape wins.** Upstream computes it from duration, then overrides from `audio_latents.shape` when supplied. The desync is real and directional (Β§5.7 #11). |
 
2343
  | **1** | ~~bf16 fits ZeroGPU's transient disk~~ β€” **SETTLED: it does not.** | **Not a risk any more, a finding.** The snapshot **IS** freed after packing (verified, `spaces` 0.51.1) β€” and the unlink runs *strictly after* `_pack()`, so the 144.37 GB peak precedes it, and with an 8–12 GB image the total is **152–156 GB against a 150 GB cap**. See Β§2.5 for the authoritative arithmetic. The ~68 GB RAM ceiling remains a community cgroup observation, separate and still open. | **No longer settled by measurement β€” it is settled.** The routes are persistent storage, a public Space with `preload_from_hub` (Β§6.2), or smaller checkpoints. All three are operator decisions, none is a knob we can turn. **ZeroGPU is parked; hinode is the critical path.** |
2344
  | 2 | ~~the packer handles quantised tensor subclasses~~ β€” **RESOLVED: it does, for bitsandbytes** | `spaces/zero/torch/bitsandbytes.py` no-ops for bnb β‰₯ 0.46.0, wired in at `patching.py:328/355/445`. **No equivalent module exists for torchao** β€” bnb is supported, torchao is not, and that decides the library. *Verified, `spaces` 0.51.1.* | Not a risk. Recorded because the asymmetry is invisible from outside. See `docs/ZEROGPU_DISK.md`. |
2345
  | 3 | ~~`preload_from_hub` 10-entry cap~~ | **RETIRED.** We are one repo β†’ one entry with comma-separated filenames. Fits comfortably (Β§6.2). | β€” |
2346
+ | 4 | Max `@spaces.GPU` duration on our tier | server-side, tier-dependent, **unpublished** | discover empirically; never hardcode (Β§5.8 #4). *(2026-11-16: still unknown, and now load-bearing: this app asks for up to 510 s.)* |
2347
+ | 5 | Multishot via prompt structure produces usable results | no API support, and the enhancer system prompts actively discourage scene cuts (Β§3.4) | presented to users as unverified technique, not a feature. *(2026-11-16: the UI no longer offers a shot list, Β§3.4; several shots can still be written into the prompt.)* |
2348
+ | **7** | ~~The diffusion decoder fetches NATTEN from the Hub at generation time~~ β€” **ANSWERED: once per process.** | βœ… **Measured on hinode**: two stage-2 generations in one process, **exactly one** kernel fetch. So a worker needs outbound network at its **first** stage-2 use, not on every press of Generate. | **Still a real dependency** β€” each cold worker pays it once, and `get_kernel("shi-labs/natten", version=1)` is hardcoded inside diffusers so we cannot pin it by revision. Lazy construction keeps it off the startup path for the eight modes that never reach stage 2. *(Corrected 2026-11-16: three modes skip stage 2, not eight. And with `LTX25_DECODER=auto` the diffusion decoder now decodes single-stage video runs on CUDA too, so a cold worker pays the fetch at its first video run; if the decoder or its kernel cannot be built, `auto` falls back to the conv VAE and says so. Not yet seen on the Space.)* |
2349
+ | 6 | An LTX-**2.3** LoRA attaches cleanly to the **2.5 distilled** transformer | the model card says most 2.3 LoRAs run on 2.5 unchanged, but our R3 fixture is a 2.3 LoRA and our transformer is 2.5-distilled; the official 2.5 LoRA targets the **DEV** transformer, so it is not a valid control | **TEST_PLAN R3** β€” stage 7 asserts attachment count > 0 against real weights. *(2026-11-16: the validator now warns on a 2.3 adapter instead of refusing it. Two 2.5 adapters visibly change the output on real weights, locally (`SPACE_MODE_MATRIX.md` Β§10.2); a 2.3 adapter has not been run on real weights.)* |
2350
  | **8** | **`temporal_latent_upsampler` has no documented role** β€” we download 0.2619 GB and `preflight` carries a dedicated error path for it | It is the **same class** as the spatial one (`LTX2LatentUpsamplerModel`), differing only by `spatial_upsample`/`temporal_upsample` and `use_rational_resampler`. But upstream's component table lists **only** `latent_upsampler/` as belonging to the two-stage recipe, and neither documented recipe nor `LTX25AutoBlocks` mentions the temporal one. *Read off the model card at revision `871165de…` and the configs themselves, not inferred* | **Deliberately not wired.** Inventing a role for it in a graph upstream does not describe is worse than 0.26 GB of unused download. If it proves to be dead weight the allow-list can drop it β€” but on evidence, not on tidiness |
2351
 
2352
  > **Risk 1, re-read on 2026-08-25 β€” three of its clauses aged, differently.**
 
2358
  > all eleven modes at sha `287ba9c` via the route the "how it gets settled"
2359
  > column did not list β€” int8 runtime quantization (`ZEROGPU_DISK.md` Option B),
2360
  > fitting at 82.2/150 [OK].
2361
+ >
2362
+ > β›” *Corrected 2026-11-16:* at `287ba9c` the eleven modes *executed*; every output up to
2363
+ > `ff142d9` was colour static. "82.2/150 [OK]" is a reading taken before packing; the disk
2364
+ > peak has never been measured. hinode is retired.
2365
 
2366
  ### βœ… Blocker cleared
2367
 
 
2369
  `model_index.json`. Weights work is unblocked.
2370
 
2371
  Remaining access note, **not** a blocker: the Lightricks *LoRA* repos are separately gated and
2372
+ still shut. Β§4.5 shows the ungated community LoRAs make a better R3 fixture anyway. *(Checked in
2373
+ August; not re-checked since.)*
2374
 
2375
  ---
2376