perf: --eager-load-params for fast steady-state streaming#1646
Closed
fszontagh wants to merge 2 commits into
Closed
perf: --eager-load-params for fast steady-state streaming#1646fszontagh wants to merge 2 commits into
fszontagh wants to merge 2 commits into
Conversation
…arams # Conflicts: # examples/common/common.cpp # src/stable-diffusion.cpp
Owner
|
Closing this as obsolete. The original issue this PR tried to address no longer applies to the current default behavior. Params storage is kept after first use in the default params backend, so later runs can reuse the loaded weights. Storage is only released for tensors with So I don't think we need a separate |
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
After #1644 centralized weight staging, params are loaded from disk to the params backend lazily on the first
prepare_paramscall. For multi-segment streaming on a large model this means the first sampling step pays the entire disk-read cost (8-15 seconds per segment on Z-Image bf16), and batch images re-pay it wheneverrunner_done()releases the params storage.This PR adds a
sd_ctx_params_t::eager_load_paramsflag (CLI:--eager-load-params) that loads every registered tensor into the params backend right after metadata validation. Default off, so the lazy behavior is preserved for users who want lower peak host RAM at model-load time.Numbers
RTX 3060 12 GB,
--offload-to-cpu --stream-layers --max-vram -1:--eager-load-paramsgenerate_imagegenerate_imageFor long-lived processes (servers, batch generation) the eager path also reduces total wallclock because images 2..N reuse the warm pinned-host cache instead of re-reading the model from disk.
Implementation
ModelManager::load_all_params_eagerly()collects all registered states and calls the existingload_tensors_to_params_backend.sd_ctx_params_t::eager_load_params,init, andto_str.examples/common.Checklist