Repository navigation
feat(working-memory): measure working memory in admin calibration runs - #9897
Draft
Pfannkuchensack wants to merge 8 commits into
Draft
Pfannkuchensack wants to merge 8 commits into
Pfannkuchensack wants to merge 8 commits into
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.
A probe records each estimated model_on_device window's device-level demand inside a calibration scope; results go to a per-device-class store under databases/working_memory. Admin endpoints start, inspect, reset and export runs; the reserved queue origin is refused for ordinary enqueues.
…n fact Environment ids now include windows, linux or other, so calibrations from different operating systems are kept apart; the OS build string moves to soft fact os_build.
6 of 7 tasks
# Conflicts: # invokeai/backend/util/vae_working_memory.py # tests/app/invocations/test_flux2_working_memory.py
This was referenced Oct 18, 2026
# Conflicts: # docs/src/content/docs/development/Architecture/model-manager.mdx # invokeai/backend/model_manager/load/load_base.py
6 of 7 tasks
# Conflicts: # invokeai/app/services/invocation_services.py
6 of 7 tasks
… tests CPU wheels on macOS and Windows have no CUDA allocator binding, so the fixture that scripts a CUDA build scripts its backend too.
This branch has not been deployed
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
Working-memory estimates can now be checked against what an operation really uses, on the machine that runs it. This PR only records measurements; no estimate changes.
invokeai/backend/working_memory/probe.py)model_on_device(working_memory=...)window records its demand next to its estimate.fdinfoon Linux, and the driver counter on MPS.invokeai/app/services/working_memory_calibration/)POST /api/v2/models/i/{key}/working_memory/calibrate.enqueue_batchrefuses for everyone.databases/working_memory/.Related Issues / Discussions
Builds on #9896.
QA Instructions
pytest -m slow tests/backend/working_memory/test_probe.pypassed on an RTX 4090 (CUDA 13.0) and an RX 9060 XT (ROCm 10, Windows): the window is valid and covers the reserved growth.cudaMallocAsync):flux_vae_encode: reserved 2200 MiB, measured 1840 MiB.flux_vae_decode: reserved 4400 MiB, measured 2912 MiB.openapi.json/schema.ts;pnpm lintandpnpm testininvokeai/frontend/apipass.Review
Resolved findings
finally, and an item that is gone counts as canceled.calibratewas not safe to retry after a lost response.os.replacefailed transiently while another process held the file.availableand the declared error codes now match what the routes do.Remaining limits
fdinfo, MPS and XPU readers follow vendor documentation, untested on hardware. They are markedverified=false.torch.cuda.empty_cache()calls and background offloads bypass the segment boundary. The torch peaks still bound the demand.Compatibility / Rollout
<db_dir>/working_memory/<device_class>.json.Checklist
What's Newcopy (if doing a release after this PR)Need help on this PR? Tag
@codesmith-botwith what you need.