Repository navigation
Studio diffusion: give stored-fp8 denoisers their own planner label instead of dense - #14631
Conversation
The stored-fp8 Linear keeps its codes and scales as buffers, so denoiser_quant_label and _pipe_denoisers_hold_packed (parameters only) read it as dense: refinement took the fp16 dense static seed for a build that widens every Linear per call, and its learned peaks shared the key of a widened load of the same file. Label it fp8_stored:<float dtypes>#<variant> and treat it as packed (learned peak only). Dense, torchao, GGUF and packed:int8 labels are unchanged.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 937a4c2289
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if _holds_fp8_stored(getattr(pipe, name, None)): | ||
| return True |
There was a problem hiding this comment.
Disable static seeds for mixed stored-FP8 denoisers
When a supported ComfyUI checkpoint mixes torchao-backed layers with FP8 layers that fall back to stored form—for example, E4M3 plus E5M2 with FP8 storage forced—_pipe_denoisers_hold_torchao() makes dense_mib be None, so the static_seed expression short-circuits before this new packed verdict is consulted and leaves static_seed=True. The first load can consequently be placed from a generic measured table that never included the stored layers' per-forward widening, rather than waiting for this build's learned peak, risking the same under-reservation/OOM this change is intended to prevent. Stored FP8 should disable static seeding independently of whether the denoiser also contains torchao weights.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch. In a ComfyUI file whose int8 layers run on torchao while its fp8 layers stay stored, dense_mib was None, so the static_seed expression short-circuited before the packed verdict and the first load could be seeded from the measured quant table, which never priced the stored layers' per-forward widen. Fixed: any denoiser holding stored fp8 layers now places from its learned peak alone, regardless of torchao presence. Added test_stored_fp8_beside_torchao_layers_never_takes_a_static_seed (fails before the change, passes after), with a torchao-only control that still takes its seed.
…tic seed A ComfyUI file mixing torchao-backed layers with stored fp8 layers left dense_mib None, so static_seed stayed True and the first load could be placed from a measured quant table that never priced the per-forward widen. Any stored fp8 denoiser now places from its learned peak alone. [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Follow-up to #14549. A denoiser whose single-file fp8 weights stay stored in fp8 was identified by the memory planner as a plain dense denoiser, so it borrowed the dense placement data instead of its own.
The stored-fp8 Linear (
NativeWeightOnlyLinear, fp8 scheme) keeps its codes and per-row scales as buffers (weight_q,weight_scale). The two planner helpers that decide the denoiser's format only looked at parameters:denoiser_quant_labelsaw the float biases and norms and returneddense:float16/dense:bfloat16._pipe_denoisers_hold_packedreturned False.Consequences:
refine_plan_from_loaded_weightsused the fp16 dense eager table as a static seed (measured_static_seed=True, 3072 MiB reserve on FLUX.2-klein) for a build that table never measured. The stored layer widens each Linear per call (fp32 codes, fp32 scaled, then the compute dtype: about 160 MiB for a 4096x4096 Linear against 32 MiB of resident bf16 weight).Changes
studio/backend/core/inference/diffusion_memory.py:_holds_fp8_stored(module), reading the_unsloth_fp8_storedcount both load paths already set (diffusion_single_file_converters.py,diffusion_comfy_quant.py)._pipe_denoisers_hold_packedreturns True for a stored-fp8 denoiser (any oftransformer,transformer_2,unconditional_transformer,unet). Refinement then places it the way GGUF and int8 packed denoisers are placed: from a learned peak recorded for its exact build, which includes the per-layer widen. With no learned peak yet, the flat plan stands.denoiser_quant_labelreturnsfp8_stored:<float dtypes>#<variant digest>for it. The digest is the existinggraph_varianttag, which already reads theweight_qbuffers, so E4M3 and E5M2 codes get different keys.Labels for dense, torchao, GGUF and
packed:int8denoisers are unchanged, so learned peaks already recorded for them still match. Weight byte accounting (_loaded_component_mib), offload sizing and the compile-cache graph variant already count buffers and need no change.No change to the learned-peak store's runtime stamp. Peaks a stored-fp8 run wrote under the dense key before this fix can only be higher than the dense build's own peak, and learned peaks only ever raise a reservation. So the leftover entries make dense placement more cautious, never less safe. Bumping the store version would throw away every recorded peak on every host.
Tests
New
studio/backend/tests/test_diffusion_fp8_stored_label.py(CPU only, built from the real stored-fp8 layer class):fp8_stored:for bf16 and fp16, distinct from the dense label of the same model, E4M3 vs E5M2 distinct, two-expert pipesmeasured_static_seed=False)packed:int8labels are unchanged, and an fp16 dense load still takes the 3072 MiB static seed