Repository navigation
Studio: keep bf16 for auto precision on image families that cannot compile - #11819
Conversation
Lumina-2 and HiDream-I1 declare no regional compile blocks, so an auto INT8 transformer ran eager torchao, several times slower than the bf16 weights it replaced. Auto now keeps the released weights for such a family when they fit resident, both in the pre-download seed decision and in the loader, and says why in the resolved record. Explicit schemes and families that compile are unchanged.
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. |
The pre-download seed decision asks family_compiles_regionally before load_pipeline takes its own guard, so the diffusers import there could race the background torch warm.
The planner stays resident when it cannot read the card, which proves no fit, so keeping bf16 now needs a measured budget and requirement.
- Judge the load-time decision on a pipeline plan re-priced from the bf16 resident table, so fp32 shards (Lumina-2) do not force the eager quant. - Price a hosted pre-cast text encoder in the pre-download bf16 plan. - A resident plan proves a fit only when its requirement is within the budget; unified memory plans none regardless of size. - Offline, keep a cached seed when the snapshot has no released shards. - A GGUF baking LoRAs keeps the dense build, the only path that carries them.
…m's pre-cast TE4 - The offline keep-bf16 return now requires one snapshot whose transformer/ holds every shard its index names, not any cached weight byte. - The bf16 table plan prices HiDream's hosted pre-cast Llama text_encoder_4, which the generic pre-cast scale does not probe.
- Offline, price the text encoder dense: an uncached pre-cast one loads dense. - A numbered shard without its index is not a complete transformer. - Offline, look for the released shards under the ungated mirror too. - Always re-price HiDream pipelines from the table, which counts the Llama text_encoder_4 no cached plan sees.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c33f16e1c
ℹ️ 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 ( | ||
| getattr(fam, "name", None) != HIDREAM_FAMILY_NAME | ||
| and self._resident_sized_plan( | ||
| plan, fam, base, target, kind, text_encoder_quant = text_encoder_quant | ||
| ) | ||
| is plan | ||
| ): |
There was a problem hiding this comment.
Preserve measured sizing for custom HiDream pipelines
For any local or renamed pipeline identified as HiDream through its model index or family_override, this condition bypasses _resident_sized_plan entirely and replaces the measured checkpoint footprint with the fixed official-family table. A custom HiDream configuration with a larger transformer can therefore have its real plan select offload while the table appears resident, causing auto precision to be rewritten to off and loading the released transformer under offload instead of taking the resident quantized path. Fresh evidence beyond the standalone-encoder fix is that _resident_sized_plan deliberately refuses coarse family-table sizing for local and unrecognized bases, but this HiDream exception removes that safeguard; account for the standalone encoder without discarding the measured transformer size.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this. Every HiDream-I1 checkpoint (Full, Dev, Fast and their mirrors) has the same 17B transformer the family table prices, and none ships text_encoder_4, which is exactly what the measured plan misses. A local fp8 or nf4 copy is smaller than the table, so the table errs toward keeping the quant. A larger custom HiDream transformer is hypothetical.
…'s cache root offline - The seed planner prices a pre-cast encoder only when the hosted artifact resolved for this pull; otherwise the dense encoder is staged and loaded. - The offline released-shard check reads the snapshot the loader will read: the first root, live then import-time, whose refs/main holds the manifest.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: add1e51774
ℹ️ 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".
| self._released_transformer_cached(candidate) | ||
| for candidate in dict.fromkeys( | ||
| ( | ||
| fetch_base, | ||
| base, |
There was a problem hiding this comment.
Check only the offline repo the loader will read
When local_files_only=True, accepting a complete transformer from any candidate can discard a usable cached seed even though the selected fetch_base lacks those shards. For example, if the upstream cache contains companion weights while the mirror contains the complete released transformer, the later offline mirror selection sees an empty base_files list and chooses the upstream because it has a weight; this probe instead succeeds on the mirror, returns None, and from_pretrained fails against the incomplete upstream snapshot. Fresh evidence beyond the earlier mirror report is that _run_load later selects exactly one fetch_base with prefer_ungated_mirror(..., files=base_files), so availability under another candidate cannot satisfy that load; resolve that selection first and check only its snapshot.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The probe never reaches the mirror in that case. prefer_ungated_mirror(base) with no file list is the same call _run_load makes offline (files=[] and None both mean any weight), so when the upstream holds companion weights it returns the upstream and the candidate list is only upstream ids. The mirror is checked only when the loader would also pick it. Pinned by test_an_offline_pick_checks_only_the_repo_the_load_reads (passes before and after 4c6d4bc).
| ): | ||
| return None |
There was a problem hiding this comment.
Fall back to a cached seed when bf16 cannot fit on disk
When the released bf16 weights fit GPU memory but are not cached, this return drops an already-cached pre-quantized seed without checking whether the cache volume can hold the replacement download. For Lumina-2 that can require roughly 21 GB of fp32 shards, so a nearly full cache subsequently fails the scoped download's disk preflight even though the cached seed and companions could have loaded successfully. The normal candidate resolver explicitly exempts cached prequant artifacts from its free-disk gate for this reason; apply an equivalent acquisition check before choosing bf16, or retain the cached seed when the missing released shards cannot be staged.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Intended. On a card where the released weights fit, auto now prefers them because the uncompiled quantised denoiser is several times slower; that pull goes through the existing download disk preflight, which refuses before any byte moves with an actionable message, and an explicit int8/fp8 still uses the cached seed. Keeping a slower path to avoid a possible disk shortfall is not what auto should do.
variant=None loads only the default weights, so the offline completeness check ignores .fp16 / .bf16 indexes and files. Also pins that the offline check reads only the repo the loader selects.
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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". |
…mpile (unslothai#11819) * Studio: keep bf16 for auto precision on families that cannot compile Lumina-2 and HiDream-I1 declare no regional compile blocks, so an auto INT8 transformer ran eager torchao, several times slower than the bf16 weights it replaced. Auto now keeps the released weights for such a family when they fit resident, both in the pre-download seed decision and in the loader, and says why in the resolved record. Explicit schemes and families that compile are unchanged. * Close the dynamo import window before probing the diffusers class The pre-download seed decision asks family_compiles_regionally before load_pipeline takes its own guard, so the diffusers import there could race the background torch warm. * Leave hosts without the dense quant on their existing reason * Keep the auto quant when the memory budget could not be measured The planner stays resident when it cannot read the card, which proves no fit, so keeping bf16 now needs a measured budget and requirement. * Studio: tighten the uncompilable-family auto bf16 decision - Judge the load-time decision on a pipeline plan re-priced from the bf16 resident table, so fp32 shards (Lumina-2) do not force the eager quant. - Price a hosted pre-cast text encoder in the pre-download bf16 plan. - A resident plan proves a fit only when its requirement is within the budget; unified memory plans none regardless of size. - Offline, keep a cached seed when the snapshot has no released shards. - A GGUF baking LoRAs keeps the dense build, the only path that carries them. * Studio: offline seed check needs a complete transformer, price HiDream's pre-cast TE4 - The offline keep-bf16 return now requires one snapshot whose transformer/ holds every shard its index names, not any cached weight byte. - The bf16 table plan prices HiDream's hosted pre-cast Llama text_encoder_4, which the generic pre-cast scale does not probe. * Studio: harden the offline and HiDream sizing of the auto bf16 decision - Offline, price the text encoder dense: an uncached pre-cast one loads dense. - A numbered shard without its index is not a complete transformer. - Offline, look for the released shards under the ungated mirror too. - Always re-price HiDream pipelines from the table, which counts the Llama text_encoder_4 no cached plan sees. * Studio: size the pre-cast encoder only once resolved, read the loader's cache root offline - The seed planner prices a pre-cast encoder only when the hosted artifact resolved for this pull; otherwise the dense encoder is staged and loaded. - The offline released-shard check reads the snapshot the loader will read: the first root, live then import-time, whose refs/main holds the manifest. * Studio: a dtype-variant twin is not a cached released transformer variant=None loads only the default weights, so the offline completeness check ignores .fp16 / .bf16 indexes and files. Also pins that the offline check reads only the repo the loader selects. * Studio: only canonical diffusers weight names make a cached released transformer The offline completeness check matches the default index and unsharded weight names from_pretrained(variant=None) reads, so an adapter or other auxiliary checkpoint in transformer/ no longer counts. * Studio: carry whether the pre-cast encoder resolved into the load-time decision _run_load passes _te_prequant_resolved to load_pipeline, and the load-time bf16 decision budgets the encoder dense when the hosted artifact did not resolve for this pull, matching the pre-download plan. * Studio: place kept bf16 weights by the plan that proved they fit When auto keeps an uncompilable family's released weights because the bf16-resident re-price fits, that plan now drives placement too, so Lumina-2's fp32 shard bytes no longer offload a pipeline that fits resident. * Studio: trim comments in auto precision uncompilable-family change * Studio: wrap long re-pricing docstring * Studio: skip the bf16 re-plan for families that compile regionally * Studio: judge the cached transformer by the checkpoint diffusers loads A partial safetensors index next to a complete .bin set was read as a cached release, dropping an offline prequant seed for a load that then fails on the missing safetensors shards. Diffusers prefers the safetensors index and never reads a .bin index by default. * Studio: honour an operator's pre-quant checkpoint under auto on uncompilable families The auto bf16 preference for families that cannot compile regionally returned before the seed planner and the loader looked at transformer_prequant_path, so an allowlisted local checkpoint was silently replaced by the released weights. A present, allowlisted checkpoint now skips that preference in both places. * Studio: shorten two docstrings
Summary
Lumina-2 and HiDream-I1 get an automatic INT8 transformer today (the hosted
*-FP8artifacts carry an INT8 file too), but their diffusers transformer classes carry an empty_repeated_blocks, socompile_repeated_blocksraises and the quantised transformer runs eager. Eager dynamic INT8 is several times slower than the bf16 weights it replaced, and further from them.With this change an auto precision keeps the released weights for a family whose denoiser cannot be regionally compiled, as long as they fit resident. Both places that decide agree: the pre-download seed decision (so the pull stages the bf16 shards instead of the INT8 artifact) and the loader. The resolved record says why (
source: auto,value: off).Unchanged:
int8,fp8, ...) are honoured as before_repeated_blockscounts as compilable, so nothing narrows on an older diffusers, and a diffusers that fills the list in widens this automaticallyResults
B200, speed
default, memoryfast, 1024px, family default steps and CFG (Lumina-2 50 / 4, HiDream-I1 50 / 5), prompts and seeds from the frozenimage_24set. The B200s are shared with other jobs, so the per-arm GPU and contention are in the logs; ratios inside one table come from arms on the same class of card.Consumer GPU (Colab L4, 24 GB, exclusive VM), Lumina-2 1024px:
So on an L4 this PR changes nothing, by design: the bf16 plan picks group offload there, and the "quantise to stay resident" exception keeps today's behaviour. Worth noting for a follow-up: on that card bf16 with group offload is 2.2x faster than the resident eager INT8 and exact, so the fit exception is only clearly right where the bf16 weights cannot be hosted at all (HiDream's 63 GB on a small host).
Every changed cell (14 families x 4 requests x 3 plans {measured resident, unmeasured resident, offload} x 3 kinds x 4 speeds = 2016 cells): 2004 unchanged, 12 moved, all of them
lumina-2/hidream-i1+ auto + bf16 resident, over pipeline and GGUF picks, speed eager / default / max. The two pipeline + eager cells were already declined before (speed eager refuses any quant), only the reason text moves.Tests
test_diffusion_pipeline_prequant.py: seed decision keeps the released weights when they fit, still seeds when bf16 would offload, still seeds an explicit scheme, compilable family unchanged; load path keeps auto unquantised with the reason, still quantises when bf16 would offload, honours an explicit scheme.test_diffusion_speed.py: the predicate over declared / empty / undeclared / missing classes and non-transformer denoisers.test_diffusion_dataset_api.pyfailures as main (datasetsis not installed in that venv).Screenshot
Images page, Advanced > Loaded build, after loading
Alpha-VLLM/Lumina-Image-2.0with precision left on auto (B200, bf16 fits resident on both sides). BEFORE is the merge base1ecc01a30, AFTER is0a82fd6ca. The transformer goes fromAUTO: INT8toAUTO: OFF | BF16, and the badge tooltip carries the new reason ("'lumina-2' cannot be regionally compiled ..."). The Attention row moves from cuDNN to native SDPA because the INT8 build forces speeddefaulton main, while the kept bf16 build keeps the unset speed request, same as a precision-off load on main.