Repository navigation
LTX-2.5 in 10 GB of host RAM: stage weights from memory-mapped shards - #78
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LTX-2.5 now runs on machines with about 10 GB of usable host RAM.
stage_from = "disk"onltx23_load_pipeline()andload_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 withtorch_from_file(shared = FALSE), copies the bytes to the target device, thentorch_view_copyto the dtype. R torch has no zero-copyview(dtype), and the R safetensors writer leaves data unaligned. Offsets past 2^31 go throughtorch_as_strided(storage_offset = <double>). CPU reads clone.ltx23_load_group,ltx23_load_transformer_nf4,load_gemma4_nf4) record source keys and skip reads. Disk-backed staging pairs read throughhandle$read_to.ltx23_memory_profile()andrecommend("ltx25")returnstage_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:
Full tinytest suite: 1708 passed, 0 failed.
Not yet tested: a real 10 GB machine, a SATA disk,
serve()live in disk mode.