Skip to content

Conversation

psychedelicious
Copy link
Collaborator

Summary

Extract logic to estimate working memory to utility functions. Then, instead of requiring the estimate to be passed as an arg to all encode calls (e.g. static method ImageToLatentsInvocation.encode()), do the estimation within the encode calls. This makes it impossible to not handle the memory estimation when doing VAE stuff.

Related Issues / Discussions

Also fixes an issue introduced in #8414 where some calls to VAE encode didn't pass estimate working memory: https://discord.com/channels/1020123559063990373/1149506274971631688/1405975664359903403

QA Instructions

I manually tested all code paths that do VAE stuff:

  • Image to Image (includes VAE encode and VAE decode) for SD1.5, SDXL, FLUX, CogView4, SD3
  • FLUX Kontext (ref images require encode)
  • FLUX Control LoRA (requires encode of control image)
  • FLUX InstantX ControlNet (requires encode of control image)
  • SD1.5/SDXL Inpainting models (creating gradient mask requires encode)

Merge Plan

n/a

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

@github-actions github-actions bot added python PRs that change python files invocations PRs that change invocations backend PRs that change backend files python-tests PRs that change python tests labels Aug 18, 2025
@psychedelicious psychedelicious force-pushed the psyche/refactor/estimate-vae-during-encode branch 3 times, most recently from 8ce9012 to 5fc38a8 Compare August 18, 2025 10:31
- Move the estimation logic to utility functions
- Estimate memory _within_ the encode and decode methods, ensuring we
_always_ estimate working memory when running a VAE
@psychedelicious psychedelicious force-pushed the psyche/refactor/estimate-vae-during-encode branch from 5fc38a8 to 9c3d4b3 Compare August 18, 2025 11:38
@psychedelicious psychedelicious enabled auto-merge (rebase) August 18, 2025 11:38
@psychedelicious psychedelicious merged commit fd4c3bd into main Aug 18, 2025
12 checks passed
@psychedelicious psychedelicious deleted the psyche/refactor/estimate-vae-during-encode branch August 18, 2025 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend PRs that change backend files invocations PRs that change invocations python PRs that change python files python-tests PRs that change python tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants