Repository navigation
Studio diffusion: measured activation rows for MOSS-Image and FLUX.3 Klein base; layer split prices Z-Image from its measured row - #14950
Conversation
[skip ci]
|
@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: 16097926a4
ℹ️ 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 current_selection() is not None: | ||
| # Untiled: a layer split keeps the VAE resident on the primary. Kept apart from calibrated_headroom_mib, | ||
| # which means the one-card plan was decided from these rows. | ||
| estimates["calibrated_split_headroom_mib"] = calibrated_activation.headroom(False) |
There was a problem hiding this comment.
Propagate split calibration to the generation guard
When a multi-GPU plan only fits because this new estimate replaces the flat headroom—for example, a FLUX.1 layer split—the final _LoadState.calibrated_placement in diffusion.py still checks only for calibrated_headroom_mib. As a result, ControlNet renders on such a split are not treated as conditioned: image_activation_verdict neither adds the output-sized ControlNet activation nor disables the default-resolution exemption, so a tight plan can be admitted and then overrun VRAM. Treat calibrated_split_headroom_mib as calibrated when constructing the load state as well.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Real. A split that only fits because the layer split read calibrated_split_headroom_mib was still recorded with calibrated_placement = False, so the generate guard did not charge a ControlNet or references on top, and it kept the flat default-resolution exemption the split never reserved.
Fixed in dc0e229. The new plan_is_calibrated(plan) in diffusion.py is true for:
- a plan that carries
calibrated_headroom_mib(unchanged); - a multi-GPU split (a layer split or a companion split) whose estimates carry
calibrated_split_headroom_mib.
The load state now takes its calibrated_placement from it. The one-card fallback still carries the key but was decided from the flat estimate, so it stays uncalibrated, and one-card behaviour is unchanged.
Test: test_a_split_priced_with_the_measured_row_is_a_calibrated_placement (2x T4, Z-Image, the Kaggle sizes). It checks that the measured-row split is calibrated, and that the one-card fallback and the flat-estimate decline are not. It fails on 1609792, where the split counted as uncalibrated. Auto placement, ControlNet, calibrated activation, multigpu, layer split, memory, activation factors and backend suites: 1287 passed, 1 failure that also fails on main (test_mirrored_base_still_trips_the_flux2_shape_guard, no gguf module in this environment).
…d placement for the generate guard [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". |
[skip ci]
Problem
ComfyUI prices each model's activations with
memory_usage_factor(comfyanonymous/ComfyUI d07dff4,comfy/supported_models.py): Qwen-Image 2.16.0(2168), MOSS-Image14.6(2048), and FLUX.3 (class Flux3(Flux2), 847) inherits the Flux2 formulafactor * 4 * hidden_size / 2604(820).model_base.memory_required(424-442) turns the factor into MiB of activations per latent pixel. Those three numbers are ComfyUI constants, not Studio measurements.Studio's equivalent is the per-phase activation table
_MEASURED_IMAGE_ACTIVATION_MIBindiffusion_memory.py(text encoder, denoise, untiled decode, tiled decode, 2048x2048 worst case, per speed tier). On NVIDIA,_calibrated_activationreads it when the load is planned. On main:qwen-image-2.1flux.3-kleinflux.3-klein-basemoss-imageSo the MOSS-Image and FLUX.3 Klein base load plans reserved 8 GiB of activations at 1024x1024, about 2.2x what they use.
Fix
Two measured rows. B200, bf16 (
transformer_quant=autopicked bf16 with the hub offline), 1024x1024 and 2048x2048, 4 steps, every tier (off / default / max). Each phase is the peak allocated during that phase minus the resident weights.moss-image:(1940, 528, 3666, 3662, 3750)on both tiers.flux.3-klein-base:(301, 901, 2512, 2512, 3359)on both tiers.The 1.2 margin applies on top, as for every row.
The multi-GPU layer split also reads the measured row now. Before, it took
measured_runtime_headroom_mib, elsecalibrated_headroom_mib, else the flatruntime_headroom_mib. Butcalibrated_headroom_mibis only recorded when the measured row changes the one-card plan, so on a multi-card load the split usually got the flat 8192 MiB per megapixel. The companion split already used the row as its phase headroom. On a multi-card selection,plan_diffusion_memorynow recordscalibrated_split_headroom_mib(untiled worst phase, since a split keeps the VAE resident on the primary), andrefine_plan_for_multigpuuses it before the flat figure. One-card plans are unchanged: the key is only written under a multi-card selection.This fixes a Kaggle 2x T4 report: guided Z-Image-Turbo (fp16) declined the layer split, "11931 MiB of denoiser and VAE weights with the text encoders streamed, short by about 1007 MiB after the per-card reserves and 6963 MiB of activations on cuda:0", at both 1024 and 768. Every 2-card arm then streamed one card from host RAM and was SIGKILLed. The load plan always budgets the 1024x1024 default, because the request size is unknown at load. The generate-time guard re-prices the real request, which scales with the pixel count (6963 MiB at 1024, 3916 MiB at 768). Both rows use the eager worst case on every tier, because the table's tiers may only grow with speed.
Tests
tests/test_diffusion_activation_factors.py(CPU). Each listed family resolves to its measured row, tiers only grow with speed, base >= Klein, and_calibrated_activationreturns the row on NVIDIA for the real family objects. On main 8 of 13 fail, all MOSS-Image and FLUX.3 base cases. Qwen-Image 2.1 and FLUX.3 Klein already pass on main.test_diffusion_auto_placement.py, using the Kaggle numbers on 2x T4 (Z-Image denoiser 11739 MiB, VAE 211 MiB, encoder 7672 MiB):test_diffusion_flux3.py: the two tests that pinned "base unmeasured, flat estimate" now pin the base row.test_diffusion_backend.py): main 1931 passed, 1 failed. This branch has the same single failure (test_mirrored_base_still_trips_the_flux2_shape_guard, noggufmodule in this venv, fails on both) once the two pinned flux3 tests are updated.group, encoder streamednone, everything residentThe prediction covers the measured peak with 1.57x headroom, against 2.9x for the flat estimate. The peak, 25101 + 2807 MiB = 27.3 GiB, stays inside the 42 GiB cap. Images are 4-step smoke renders, so the comparison is placement only, not speed. The same capped run at 36 GiB gives
groupon both trees (the full set does not fit there).Not covered
_calibrated_activationalready accepts Z-Image (fp16 kept by its guard, sub-quadratic SDPA confirmed). Whether one-card host-RAM streaming still gets SIGKILLed on a 31 GB host is a separate issue.