Honor low_vram in ACE-Step load_model (fix OOM during latent caching)#911
Open
SanDiegoDude wants to merge 1 commit into
Open
Honor low_vram in ACE-Step load_model (fix OOM during latent caching)#911SanDiegoDude wants to merge 1 commit into
SanDiegoDude wants to merge 1 commit into
Conversation
…ing. Under low_vram the transformer was moved to the CPU after quantization, but load_model then unconditionally moved both the transformer and the text encoder back to the GPU. As a result low_vram provided no VRAM savings during latent caching, and caching longer audio clips OOM'd because the VAE encoder ran while the full quantized DiT and text encoder were still resident in VRAM. Keep the transformer and text encoder on the CPU when low_vram is set and rely on the existing on-demand .to(device) moves in get_prompt_embeds, get_noise_prediction and generate_single_audio. Only the VAE, which is needed for latent caching, stays on the device. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
When training ACE-Step (1.5 / 1.5 XL) with
low_vram: true, latent caching OOMs on longer audio clips even though the models are small enough to fit otherwise.Root cause is in
AceStep15Model.load_model(extensions_built_in/audio_models/ace_step/ace_step_15_model.py). Underlow_vram, the transformer is moved to the CPU after quantization, butload_modelthen unconditionally moves both the transformer and text encoder back to the GPU:So
low_vramprovides no VRAM savings during latent caching. Caching encodes each clip through the VAE while the full quantized DiT + text encoder are still resident, and a longer clip OOMs in the VAE encoder:(observed on a 24 GB card with a ~5.5 minute training clip; the ~19.5 GB resident was the model weights, not the VAE activation.)
Fix
Keep the transformer and text encoder on the CPU when
low_vramis set, and rely on the existing on-demand.to(device)moves already present inget_prompt_embeds,get_noise_prediction, andgenerate_single_audio. Only the VAE (needed for latent caching) stays resident. Non-low_vrambehavior is unchanged.Notes / scope
layer_offloadingraisesNotImplementedError).low_vramstory could also move the transformer back to CPU after sampling/generation; that's intentionally left out of this minimal fix and can be a follow-up.Test plan
low_vram: true, 24 GB GPU, dataset with clips up to ~5.5 min: latent caching now completes (peaks at a few GB instead of ~19.5 GB) and training proceeds.low_vram: falsepath is unchanged (weights load directly to device).Made with Cursor