Add low-memory relay mode for T2I inference#44
Open
laj52 wants to merge 2 commits into
Open
Conversation
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.
Draft PR Notes: T2I Relay Memory Mode
Summary
This adds an opt-in
memory_mode=relaypath for text-to-image inference with KV-cache. The default remainsmemory_mode=parallel.Relay lowers peak GPU memory by loading the UND tower for prefix/KV prefill, offloading it, loading the GEN tower for denoising, discarding Lance weights, and then loading the VAE for decode. The generated output remains bit-identical to
parallelon the same hardware with the same seed and settings.API
MEMORY_MODE=parallel: default, fastest, existing behavior.MEMORY_MODE=relay: low-memory T2I path. RequiresTASK_NAME=t2iandUSE_KVCACHE=true.RELAY_MEMORY_LOG=true: optional CUDA allocator phase summaries.No automatic memory policy is introduced in this PR.
Validation Evidence
RunPod A40, PyTorch 2.8.0+cu128, CUDA 12.8.
Prompt:
A cat holds a poster with rainbow text "STOP"Settings:
task=t2i,num_frames=1,validation_num_timesteps=30,validation_timestep_shift=3.5,validation_data_seed=42,cfg_text_scale=4.0,use_KVcache=true.Additional local smoke: relay T2I 256 completed on an RTX 3060 Ti 8GB without observed thrashing or VRAM swapping beyond the intentional relay transfers. Cross-hardware hashes are not expected to match because CUDA kernels and GPU architectures can produce small numeric differences.
Limitations
parallel.Reviewer Reproduction