Skip to content

LTX-2.5 in 10 GB of host RAM: stage weights from memory-mapped shards - #78

Merged
TroyHernandez merged 2 commits into
mainfrom
feat/ltx25-disk-stream
Oct 29, 2026
Merged

TroyHernandez merged 2 commits into
mainfrom
feat/ltx25-disk-stream

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

LTX-2.5 now runs on machines with about 10 GB of usable host RAM. stage_from = "disk" on ltx23_load_pipeline() and load_gemma4_nf4() loads no weights up front and reads every staged tensor from a private memory map of the artifact shards.

Changes

  • R/mmap_reader.R (new): .mmap_reader() maps safetensors shards with torch_from_file(shared = FALSE), copies the bytes to the target device, then torch_view_copy to the dtype. R torch has no zero-copy view(dtype), and the R safetensors writer leaves data unaligned. Offsets past 2^31 go through torch_as_strided(storage_offset = <double>). CPU reads clone.
  • Lazy loaders (ltx23_load_group, ltx23_load_transformer_nf4, load_gemma4_nf4) record source keys and skip reads. Disk-backed staging pairs read through handle$read_to.
  • ltx23_memory_profile() and recommend("ltx25") return stage_from: "disk" below 18 GB of host RAM on GPU tiers. serve(model = "ltx25") uses it.

Measured

8 GB card simulated on the 16 GB card, 10 GB cgroup cap (page cache counted), 768x512x121:

  • text phase 1.5 GB anon, render at most 4.6 GB anon
  • warm render 127 s (8.3 s/step) vs 82 s with host copies
  • latents bit-identical to host mode

Full tinytest suite: 1708 passed, 0 failed.

Not yet tested: a real 10 GB machine, a SATA disk, serve() live in disk mode.

…hards

stage_from = "disk" on ltx23_load_pipeline() and load_gemma4_nf4()
loads no weights and reads each staged tensor (Gemma 4 layers,
connectors, transformer resident and streamed blocks, VAEs, vocoder)
from a private memory map of the artifact shards when its phase needs
it. .mmap_reader copies a tensor's bytes to the device and reinterprets
the dtype there (torch_view_copy), so unaligned shard data works and no
anonymous host memory holds weights.

Measured on a simulated 8 GB card under a 10 GB memory cap that counts
page cache, 768x512x121: text phase 1.5 GB anon, render at most 4.6 GB
anon, warm render 127 s (82 s with host copies), latents bit-identical.
ltx23_memory_profile() and recommend("ltx25") return stage_from
("disk" below 18 GB available), and serve(model = "ltx25") stages from
disk where a split text phase would be needed.
@TroyHernandez
TroyHernandez merged commit c7f8f79 into main Oct 29, 2026
2 checks passed
@TroyHernandez
TroyHernandez deleted the feat/ltx25-disk-stream branch October 29, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant