Repository navigation
feat(working-memory): ship VAE working-memory coefficients as data - #9896
Merged
lstein merged 3 commits intoOct 18, 2026
Merged
Conversation
VAE estimators return a WorkingMemoryEstimate built from fitted and analytic terms; model_on_device accepts it as working_memory=. The AutoencoderKL coefficients and their measured points move to backend/working_memory/data, checked by a data test; reservations are unchanged.
Pfannkuchensack
requested review from
blessedcoolant,
joshistoast and
lstein
as code owners
October 17, 2026 13:30
This was referenced Oct 17, 2026
# Conflicts: # invokeai/backend/util/vae_working_memory.py # tests/app/invocations/test_flux2_working_memory.py
6 of 7 tasks
joshistoast
approved these changes
Oct 18, 2026
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
VRAM working-memory estimates are hand-fitted constants scattered across the estimators, and most recent working-memory fixes were re-fits of those constants. This PR makes estimates data-backed, starting with the AutoencoderKL family; reservations are unchanged.
invokeai/backend/working_memory/:WorkingMemoryEstimate, made of fitted terms (coefficient × scale) and analytic terms (score matrix, image buffers).EstimatorSpec.working_memory/data/, together with the measured points that bound them.max_ratio).values_from.UNMEASURED_PRICED_AS).model_on_device(working_memory=estimate)takes an estimate;working_mem_bytes=stays for plain reservations and custom nodes.Follow-ups build on this: an in-server probe that measures operations in admin calibration runs, and per-dtype VAE coefficients.
Related Issues / Discussions
None.
QA Instructions
upstream/main: a one-off scratch grid (not committed) compared old and new reservations over 1,427,600 cases, and every one was identical.device=None× 5 SDPA regimes × HIP on/off, KL vs Tiny.uv run --no-sync pytest tests/backend/working_memory tests/app/invocations/test_flux2_working_memory.py tests/app/invocations/test_vae_working_memory_backend.py tests/app/invocations/test_z_image_tiled_decode.py tests/app/invocations/test_flux_vae_decode_tiling.py tests/backend/util/test_rocm_sdpa_head_dim_guard.py tests/backend/model_manager/load/test_loaded_model.py tests/test_package_data.py: 313 passed, 4 skipped. Each new test file also passes alone.k_encode=700fails 7 points;k_decode=3450fails 2 points;shipped:conv_backend=cudnn):vae.fluxandvae.sd, 2200 / 4400 MB.miopen): 5500 / 7200 MB.Review
Resolved findings
device_working_mem_gbfloor was applied to every point, which made the lower bound vacuous below 3 GiB. The floor now applies only where an analytic term decides.values_from).SPEC.estimate).ESTIMATOR_MODULESplus a source scan.WorkingMemoryTerm.fitted()constructor, so a fitted term's bytes always equal coefficient × scale.max_ratio).Remaining limits
--dev_reload, editing aregister(...)statement raises; restart the server.Compatibility / Rollout
estimate_vae_working_memory_*functions (sd15_sdxl,sd3,cogview4,flux,flux2) now return aWorkingMemoryEstimateinstead of anint. External callers read.reservation_bytesor pass it asworking_memory=.working_mem_bytesraises aTypeErrorthat says so.working_mem_bytes=<int>is unchanged.Checklist
What's Newcopy (if doing a release after this PR)Need help on this PR? Tag
@codesmith-botwith what you need.