Repository navigation
Conversation
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. |
|
@codex review |
|
@codex security review |
🛡️ Codex Security Review · Automatically triggeredSecurity 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 51b7257c0b
ℹ️ 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".
| scheme = quantize_transformer( | ||
| pipe if attr == "transformer" else _DenoiserView(pipe, attr), | ||
| target, |
There was a problem hiding this comment.
Move pipeline weights to CUDA before quantizing
For every eligible resident pipeline, from_pretrained leaves the pipeline on CPU, so this call applies the CUDA-oriented torchao conversion to CPU weights. If conversion succeeds, the later resident branch in apply_memory_plan calls pipe.to(placement) (diffusion_memory.py:970-971), even though this change itself excludes offload because torchao tensor subclasses do not survive Module.to(). Thus supported official pipelines either decline conversion and silently remain BF16 or fail during placement instead of reaching the advertised fast path; the transformer must be placed/converted on the target device without subsequently moving its quantized weights.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reproducible; measured rather than argued, because the premise is right and the consequence is not.
The premise holds: unlike the GGUF path, which quantises after _assemble_pipe has already called pipe.to(device), the pipeline branch leaves the pipe on the CPU, so quantize_ runs on CPU weights and apply_memory_plan's resident branch moves them afterwards.
Both steps work. On an RTX 6000 Ada (sm_89), torch 2.12.1+cu130, torchao 0.17.0, driving the repo's own select_transformer_quant_scheme and quantize_transformer:
- CPU-side
quantize_engages for both auto/fp8 and int8;transformer_is_quantisedis true before any move. module.to(torch.device("cuda"), None)(the exact per-component callDiffusionPipeline.to(device)makes, dtype None) keeps the subclass:Float8TensorandLinearActivationQuantizedTensorland on cuda:0 and the forward returns finite bf16.- Quantise-on-CPU-then-move against move-then-quantise on identical weights: max|diff| 0.0 for both schemes, at relative error 0.038 (fp8) and 0.013 (int8) against dense. Bit-identical, so the ordering changes nothing.
diffusers 0.40.0's DiffusionPipeline.to reaches module.to(device, dtype) with dtype None for a non-bnb, non-group-offloaded component, so no cast is involved and there is no torchao guard on that path. What torchao tensors do not survive is the per-forward hook movement in enable_model_cpu_offload/group offload, which is a different mechanism and is exactly why offloaded plans are still excluded here.
Left the code as-is and recorded the measurement in a comment at the quant block in 90bff0a, since the ordering difference against the GGUF path is real and worth stating.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90bff0a707
ℹ️ 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".
| label: "BF16", | ||
| approxSizeGb, | ||
| keywords: ["bf16", "safetensors", "full precision"], | ||
| denseQuantable: true, |
There was a problem hiding this comment.
Route dense-quant rows using their quantized footprint
Marking these BF16 pipelines as dense-quantable changes their requested runtime precision, but fitsArtifactBudget and curatedArtifactFitsDevice still compare the unchanged BF16 approxSizeGb against the GPU budget and do not receive the host capability or requested precision. For example, the catalog check still routes a 24 GB host's Z-Image-Turbo group click to the bnb-4bit artifact because the official row is priced at 30 GB, even though this change specifically replans that pipeline using its much smaller quantized steady footprint. Consequently the default picker path avoids the new fast pipeline on the cards where quantization is needed to make it resident; thread the dense-quant runtime estimate into routing and fit badges.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The mechanism is described correctly, but this is a product decision rather than a defect, and not one this PR changed: fitsArtifactBudget, curatedArtifactFitsDevice and pickDefaultArtifact are byte-for-byte as on main here. Routing has always been sized on the stored artifact, and the conservative route loads and works; nothing produces a wrong result.
Three things argue against threading a quantised estimate into it as part of this change:
Routing decides what to DOWNLOAD, not just what to place. Sending a 24 GB card to Z-Image-Turbo's official row is a 30 GB pull to run a ~15 GB model, against 8 GB for the bnb-4bit row. Better quality for much more download is a call for the maintainer, not a bug fix.
The fit badge would start promising a fit that can still evaporate. Conversion declines for reasons the picker cannot see: the family deny list (_FAMILY_SCHEME_DENY), a failed smoke probe, or dense_quant_blocker. On a decline the loader restores the bf16 plan by design, so the row would have said fits on a card where the load then offloads or fails. The peak is bf16 regardless, which the PR description already flags.
The frontend cannot compute the number. The steady size comes from estimate_dense_quant: the family component table times a per-scheme factor. Reproducing that in the catalog is exactly the second source of truth the earlier label items were about.
So: not changed here, and flagged to the maintainer as a follow-up worth deciding on its own, where the download-size tradeoff and a backend-supplied estimate can be weighed properly.
|
This makes compatible official BF16 image pipelines run FP8 or INT8 by default, so the same prompt and seed can change fine detail for people who never touched the Precision control. Could you confirm what a user sees before they hit that change, and how they get the released BF16 weights back other than setting Precision to Off? |
…family refuses it
…ry bf16 blocker in the picker
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0fb525e618
ℹ️ 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".
| return combined_info | ||
|
|
||
|
|
||
| @functools.lru_cache(maxsize = 1) |
There was a problem hiding this comment.
Recompute capability after smoke-probe verdicts change
Remove this process-lifetime cache or invalidate it when _SMOKE_CACHE changes. On the normal first /api/system poll, dense_quant_host_capable() treats every unprobed scheme as usable, so this caches true; if the first real load subsequently proves every scheme unusable and records failures in _SMOKE_CACHE, later polls never re-read those verdicts and the picker continues labeling pipelines “Fast” even though every load falls back to BF16.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed, and it was a regression I introduced in the refactor. I had removed the lru_cache for exactly this reason a few rounds ago and put it back when the function was rewritten. Removed again in 2294ee4.
The reasoning is the one you give: dense_quant_host_capable counts an UNPROBED scheme as usable, so a cold backend answers yes and the first real load can then record a kernel failure in _SMOKE_CACHE. Pinning that optimistic answer for the process lifetime is the worst of both.
Measured before removing it, since caching was the only argument for keeping it: 6.9 us per call on this host. A capability read plus dict lookups, no probe and no allocation, so a polled status route pays nothing worth memoising.
The test that asserted the decorator was present now asserts it is absent, and there is a new one that a verdict recorded after the first poll reaches the next.
| card = _smoke_cache_device_key(str(getattr(target, "device", "cuda"))) | ||
| for floor, schemes in _AUTO_LADDER: | ||
| if cap >= floor: | ||
| return any(_SMOKE_CACHE.get((scheme, card), True) for scheme in schemes) |
There was a problem hiding this comment.
Include compile availability in the advertised fast path
Gate this capability on the compilation prerequisite used by pipeline loading. On a CUDA host with usable torchao kernels but TORCHDYNAMO_DISABLE set, or on Windows without a working Triton toolchain, this returns true, while _pipeline_quant_uncompilable_reason() always skips the pipeline conversion because compile_eligible() returns false; the frontend therefore marks eligible pipeline rows “Fast” on a host where none can enter the advertised path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and it belongs in the bit rather than beside it. Fixed in 2294ee4: dense_quant_host_capable now returns false when compile_eligible(target, is_gguf = False, family = None) does, which is the same prerequisite _pipeline_quant_uncompilable_reason gates the conversion on.
The host half is the part that belongs here: torch_compile_runtime_available(), the device's compile support and the bf16 dtype. The per-family and per-request halves of that decision stay with the load, where the request exists. Reachable on a normal Windows CUDA install with no Triton wheel and under TORCHDYNAMO_DISABLE, both of which now report no fast path instead of advertising one no load can enter.
Covered by a test that flips compile_eligible in both directions.
| # A raw fp8/int8 checkpoint is widened to bf16 by from_pretrained, which erases the one thing | ||
| # the blocker below reads. Ideogram's loader stamps its own; recover it from the shard header | ||
| # for every family that reaches the generic path. | ||
| source_precision = stored_denoiser_precision(_base_local_dir) |
There was a problem hiding this comment.
Scan the local pipeline path before requantizing
When repo_id is a local diffusers directory containing raw FP8 or INT8 denoiser shards without a quantization_config, _prefetch_files() deliberately returns no _base_local_dir, even though from_pretrained loads from the local fetch_base. This call consequently performs no header check, sees only the BF16 tensors produced by torch_dtype=bfloat16, and requantizes the already-lossy source. Fresh evidence after the prior fix is that the new scanner is passed only _base_local_dir, while the local-repo path is available through fetch_base; scan _base_local_dir or fetch_base when it is a directory.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Right, and it lands on exactly the case that matters. Fixed in 2294ee4: the probe now takes _base_local_dir or fetch_base.
Worth stating why this was the reachable half. Non-GGUF loads are gated by _is_trusted_diffusion_repo to unsloth/* or a local path, so a hand-converted fp8 checkpoint on disk is the realistic shape, and that is precisely the load where the prefetch stages nothing and _base_local_dir is None. My first cut checked only the staged snapshot, so it covered the case that was already unlikely and missed the one that was not. My own test used _base_local_dir, which is why it passed.
stored_denoiser_precision ignores anything that is not a directory, so passing a hub id through the fallback is a no-op rather than a network call. There is now a loader test that pins the fallback with _base_local_dir = None.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2294ee4ac6
ℹ️ 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".
| # One shard settles it: a checkpoint does not mix storage precisions per file. | ||
| break |
There was a problem hiding this comment.
Scan every denoiser shard for narrow weights
For a sharded raw FP8/INT8 pipeline whose first shard contains only BF16/FP32 tensors—for example, when embeddings or norms are separated from later low-precision linear weights—this unconditional break prevents the remaining shards from being inspected. The loader then widens the checkpoint to BF16, dense_quant_blocker() sees an apparently dense source, and the pipeline requantizes already-lossy weights. Fresh evidence beyond the prior source-metadata fix is that the new scanner examines only one file per denoiser; continue through all shards (or use the shard index) before concluding the source is dense.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and the premise I wrote in that comment was wrong. I had justified the break with 'a checkpoint does not mix storage precisions per file', which the adjacent code already contradicts: _DENSE_PARAM_DTYPE_NAMES admits float32 precisely because narrow DiTs keep their norms and embedders wide. Shards are cut by size, so the first file can be entirely wide.
Fixed in e7f3914: the scan continues through every shard under each denoiser and only concludes dense when none of them carries a narrow dtype. Header reads on local files, so the cost is a stat and a JSON header per shard.
Covered by a two-shard test where the first holds a bf16 norm and the second an fp8 linear.
| if engaged and len(engaged) == len(denoisers): | ||
| transformer_quant_engaged = engaged[0] |
There was a problem hiding this comment.
Reject pipelines when compilation fails to engage
When compile_eligible() passes but the later compile_repeated_blocks() setup returns false—for example, because the loaded transformer exposes no usable repeated-block API or its wrapper installation raises—this marks the already-mutated pipeline as successfully quantized. The subsequent apply_speed_optims() path only logs that compilation did not engage, so the load succeeds with the eager torchao transformer that this change itself documents as roughly 30× slower than BF16. Fresh evidence beyond the compile-availability preflight fix is this model-specific post-conversion failure path; do not commit the quantized pipeline as usable unless compilation actually engages, or fail the load once the dense weights can no longer be restored.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one, and the reason is that the remedy is worse than the case.
The case is already detected and reported. diffusion.py:4594 checks exactly this condition after apply_speed_optims and warns that the quantised transformer is not compiled and is ~30x slower. That check is pre-existing and covers the GGUF dense path too, which has shipped with it.
Escalating it to a failed load is the part I disagree with. By that point the conversion is in place and the dense weights are gone, so there is nothing to fall back to: the choice is a working-but-slow pipeline or no pipeline at all. Refusing there turns a load that produces correct images into a hard failure, on a path with no rollback, for a condition the user can neither predict nor configure around. Every other refusal this PR adds is made BEFORE the weights are touched, which is what makes those safe.
I also cannot get to the trigger. compile_eligible has already passed, so inductor works; _compile_repeated_blocks then returns false only when no denoiser exposes compile_repeated_blocks and there is no UNet. That method is on diffusers' ModelMixin, and every family that reaches the pipeline dense path is a DiT carrying it on the pinned 0.40. If you have a concrete model and diffusers version where a DiT lacks it, that changes the answer and I will take it.
Left as the warning, and flagged to the maintainer as the one place a different call is defensible.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7f391435a
ℹ️ 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".
| # `fetch_base` too: a LOCAL diffusers directory is loaded straight from it and the prefetch | ||
| # deliberately stages nothing, so `_base_local_dir` is None exactly where a hand-converted | ||
| # fp8 checkpoint is most likely to be. The probe ignores anything that is not a directory. | ||
| source_precision = stored_denoiser_precision(_base_local_dir or fetch_base) |
There was a problem hiding this comment.
Resolve cached remote snapshots before scanning source dtype
When a cached remote unsloth/* pipeline is loaded with local_files_only=True (the media auto-switch path), _estimate_download_bytes deliberately returns no files, _prefetch_files therefore returns no _base_local_dir, and a model cached in the active root also gets no snapshot from _assert_base_repo_accessible; this expression consequently passes the Hub ID in fetch_base to a scanner that only handles directories. A raw FP8/INT8 checkpoint without quantization_config is then widened to BF16 and requantized. Fresh evidence after the local-path fix is that the cache-only remote path still produces no filesystem path; resolve the cached snapshot before calling stored_denoiser_precision.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Leaving this one, and saying why rather than just declining it.
The mechanism is right: on that path fetch_base is a Hub id, stored_denoiser_precision only handles directories, so the scan is a no-op. But the population it would protect is empty as far as I can find. The subject has to be an unsloth/* PIPELINE repo storing raw fp8 or int8 with no quantization_config. Unsloth's published quantised artifacts are -unsloth-bnb-4bit, which _module_quantised_marker already catches by config, or GGUF, which is a different kind entirely. The one raw-fp8 image checkpoint in the catalog is Ideogram 4, which has its own loader, stamps its own source precision, and is marked non-denseQuantable in the picker.
The failure mode also matters: with no directory the probe returns None, which is exactly the behaviour before any of this existed. It is an unclosed hole, not a regression.
Against that, resolving a cached snapshot means pulling hub cache resolution into the quantisation path for a case with no named instance, and getting it wrong there fails loads that work today.
So: a real boundary, deliberately left, and recorded in the PR description rather than hidden. Name an unsloth/* pipeline repo that actually ships raw fp8 without a quantization_config and I will take it, since the fix itself is small; I am declining the shape, not the idea.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7f391435a
ℹ️ 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".
| from core.inference.diffusion_transformer_quant import dense_quant_host_capable | ||
|
|
||
| import torch |
There was a problem hiding this comment.
Keep the system poll from importing the ML stack
On a cold backend, the first /api/system request now imports both torch here and torchao through dense_quant_host_capable() → torchao_unavailable_reason(). The background warm deliberately leaves optional GPU consumers such as torchao cold, while this endpoint is polled during startup and is designed to avoid heavyweight ML imports; a slow or broken torchao import can therefore stall system discovery—and potentially the process via the GIL—just to compute a picker label. Derive the bit from already-loaded/cached state or populate it outside the polled request path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Genuine, and the file already argues your case: _await_hardware_detection goes out of its way not to kick detection because it would 'import torch on every such host', and /api/health publishes torch_warm_in_progress because 'the warm thread's import torch holds the GIL'. I put a torchao import on the polled route and missed that.
Measured on this host, cold process: import torch 0.79s, from torchao.quantization import quantize_ 0.73s. Both hold the GIL, and /api/system is polled throughout startup.
Fixed in 3a0cc0b by taking your second option. The route reader answers from already-loaded state only: it checks sys.modules for torch and torchao and otherwise returns the last resolved value, so a poll on a cold backend imports nothing. Verified by AST that the reader contains no import statement and references only sys, the cached value and the refresh helper.
The resolution moved to _post_warm_background_work, which runs after join_background_warm() and is already where optional stack work belongs (MLX autorepair sits there for the same reason). The warm has torch up by then, so the only new cost is torchao's 0.73s, off the critical path. A request that finds both modules already loaded still refreshes, so a kernel verdict recorded by a load reaches the picker on the next poll and the answer keeps sharpening.
False before the warm resolves is honest rather than wrong: the picker renders it as no fast label, which is how it already treats an unknown VRAM budget until system info arrives.
Tests: the reader must contain both sys.modules guards and must not name the importing probe, and something off the polled path must resolve it, so the label cannot be quietly stranded.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a0cc0b6bc
ℹ️ 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".
| ) | ||
| # This in-memory rewrite needs no cache-space or hosted-checkpoint checks. | ||
| estimate = ( | ||
| estimate_dense_quant(fam, preview_scheme, base_repo = base) |
There was a problem hiding this comment.
Size pipeline replans from the loaded variant
When an offloaded pipeline is a local or unrecognized variant of a multi-size family, this estimate falls back to the family's default dimensions instead of the pipeline actually loaded. For example, a local FLUX.2-klein 9B pipeline is estimated using the 4B family entry, so a 24 GB card can switch from the valid BF16 offload plan to a supposedly resident quantized plan whose real 9B transformer and encoder do not fit, causing placement or generation to OOM. Preserve the measured BF16 plan's component size or derive the quantized footprint from the assembled denoiser when the base is not an exact size-table key.
Useful? React with 👍 / 👎.
| the same way it treats an unknown VRAM budget until system info arrives.""" | ||
| if "torch" in sys.modules and "torchao" in sys.modules: | ||
| return _refresh_dense_quant_capability() | ||
| return bool(_dense_quant_capability) |
There was a problem hiding this comment.
Repoll the capability after warmup
When the UI first calls /api/system before the post-warm worker finishes, this serializes the unresolved capability as false. I checked useGpuInfoSource and fetchSystemInfo: the GPU hook fetches only once without force, and the module-level cachedSystem makes later consumers reuse that snapshot unless an optional polling surface such as the floating monitor is opened. Consequently a capable host normally remains classified as merely accelerated and never displays the new Fast labels after the worker computes true; later smoke-cache verdict changes are likewise not propagated. Return an unknown state that the client retries, or explicitly publish/force a refresh when warmup finishes.
Useful? React with 👍 / 👎.
| # Off the polled path on purpose: /api/system must not import torchao itself (see | ||
| # _dense_quant_supported), and the warm above has already paid for torch. | ||
| try: | ||
| _refresh_dense_quant_capability() |
There was a problem hiding this comment.
Honor the torch-warm disable switch
When UNSLOTH_STUDIO_DISABLE_TORCH_WARM=1, start_background_warm() returns without creating a worker and join_background_warm() therefore returns immediately, but the unconditionally started post-warm thread still reaches this call. _probe_dense_quant_supported() then imports torch and, on CUDA, can import torchao, so the documented kill switch no longer keeps the ML stack cold and startup pays the import cost it explicitly disabled. Only run this refresh when the warm actually started, or when the required modules were loaded independently.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and my comment claimed the opposite: I wrote that the warm above had already paid for torch, which is false exactly when the switch is set. Fixed in 8fbdbfd.
The refresh is now gated on "torch" in sys.modules, so with UNSLOTH_STUDIO_DISABLE_TORCH_WARM=1 the post-warm worker reaches it, finds the stack cold and does nothing. Guarded with an if rather than an early return, since a return there would have skipped _start_linked_folder_auto_sync further down; there is a test asserting both the guard and that the rest of the worker still runs.
| pipe is not None | ||
| and kind == "pipeline" | ||
| and transformer_quant_engaged is None | ||
| and normalize_transformer_quant(transformer_quant) is not None |
There was a problem hiding this comment.
Preserve the ControlNet path on automatic pipeline loads
On a dense-quant-capable CUDA host, loading an official FLUX.1 or Qwen Image pipeline with the default precision reaches this condition and automatically converts its transformer. The committed status then calls diffusion_controlnet.supports_controlnet(), which returns false for every torchao transformer, causing the Images page to clear and hide the ControlNet controls. Before this change these official pipeline rows stayed BF16 and were the supported ControlNet route, and ControlNet is selected only after a model is resident, so the load request has no signal with which to avoid the conversion. Keep a discoverable BF16/reload path for ControlNet-capable families or make the quantized pipeline support ControlNet rather than silently removing the feature by default.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8fbdbfd51c
ℹ️ 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 _has_active_lora(loras): | ||
| # PEFT must wrap dense Linears before torchao converts their base layers. | ||
| baked = self._resolve_lora_set( | ||
| [(i, w) for (i, w) in loras if w != 0], |
There was a problem hiding this comment.
Reject unsupported LoRA prototype quant schemes
When a pipeline is loaded with an active LoRA and explicit nvfp4/mxfp8 (or Auto falls through to MXFP8 on Blackwell), this branch attaches and marks the adapter as baked without checking the selected scheme. diffusion_lora.supports_lora() explicitly blocks both prototype schemes (diffusion_lora.py:424-455), so the load can nevertheless succeed with an unsupported adapter topology and then report supports_lora: false, hiding the LoRA controls while the adapter remains active. Resolve and validate the scheme before attaching adapters, or fall back to a supported scheme/dense pipeline.
Useful? React with 👍 / 👎.
|
Two things from reading the pipeline branch against the loader on main.
Neither needs to block this PR. I will stack a follow-up on this branch that settles the scheme at plan time the way the video loader does, drops the dense transformer shards from the plan, seeds the hosted checkpoint into |
|
This makes compatible official BF16 image pipelines run FP8 or INT8 by default, so output detail can change for people who never touched Precision, and I do not see an answer yet to what a user is shown before that switch takes effect. Could you confirm that, and whether Precision set to Off is the only way back to the released BF16 weights, before I review? |
Summary
Official BF16 image models can now use Studio's FP8 or INT8 fast path on supported GPUs.
The model files are still BF16. Studio loads those files, converts the transformer to FP8 or INT8 in memory, and then runs the converted model. Previously only GGUF picks could reach this path, so official pipeline picks always ran as BF16 and the picker pointed users at the slower row.
What changed
Image loading
Dense transformer quantisation now supports both
ggufandpipelineloads.For a compatible BF16 pipeline, Studio now:
If an automatic conversion declines without changing any weights, Studio keeps the BF16 pipeline. If the user explicitly requested a precision that cannot be used, the load fails with an explanation instead of silently using BF16. A partial in-place conversion is not safe to continue or undo, so that case also fails the load.
The pipeline is still on the CPU when it is converted, unlike the GGUF path which converts after placement. Both orders produce bit-identical output; the later
pipe.to(device)is a one-shot move, which torchao tensor subclasses survive. Only the per-forward offload hooks do not, which is why offloaded plans stay dense.A quantised transformer must be compilable
An uncompiled torchao transformer is far slower than the BF16 weights it replaces, so a load that cannot compile keeps its dense weights. That covers Speed set to Eager and any process that cannot run inductor, which includes a normal Windows CUDA install with no Triton wheel. Without this, automatic precision would have made the default pick on those hosts much slower rather than faster.
Refusals happen before the eviction
assert_precision_availabledecides everything that is knowable from the request alone: the load kind, a UNet family such as SDXL, a memory mode that forces offload, Speed set to Eager, a process that cannot compile, and a scheme this GPU or family rules out. It runs before the arbiter evicts the resident model and before anything is downloaded, so a refusal that was certain from the start no longer costs the user their loaded model and a multi-GB download first.Safety checks
A pipeline is not quantised when:
Ideogram now records the original precision of widened weights so Studio does not quantise them a second time. Pipelines with multiple denoisers, including Ideogram's conditional and unconditional transformers, use one precision across every branch.
The existing GGUF download and fallback behavior is unchanged.
Picker labels
The backend reports one bit,
dense_quant_supported: whether an automatic request could engage a dense scheme on every visible card. It is derived from the auto ladder, the resolved torchao import and any kernel-probe verdict the load path has already paid for, and it never runs the probe itself, so a polled status route stays cheap.On a capable host, eligible official image pipelines gain a
Fastqualifier. Their chip stays the precision the artifact is stored at, exactly as on a host without the fast path.The row deliberately does not name the precision that will run. That answer also depends on the request, on the family deny list and on a per-card kernel probe, and reproducing it in the picker means mirroring the loader's selector across the API boundary.
resolvedalready reports the precision that actually ran, which is the honest place for it.The picker, download plan and load request do share one rule: which artifacts may receive a precision request at all. A precision selected on one row is therefore not sent to an incompatible row after the user changes models. Unknown repository ids still defer to the backend.
MiniMax H3 now says
Fastrather thanFast FP8, for the same reason.Before and after
FastBF16 (official)BF16User impact
On supported GPUs, compatible official DiT image models now use FP8 or INT8 by default.
Nothing changes for unsupported hosts, SDXL, single-file checkpoints, already quantised artifacts, Ideogram 4, the video loader, or Precision set to Off.
Verification
Coverage includes pipeline conversion, BF16 fallback, explicit refusals, the compile guard, the pre-eviction preflight, offload, LoRA ordering, partial conversion failures, multi-denoiser pipelines, excluded artifact types, memory re-planning against the quantised size, GPU capability reporting, and picker labels.
Results on this branch:
studio/backenddiffusion, routes, transformer-quant and capability suites: 603 passed.The pipeline-quant ordering claim above was measured rather than argued, on an RTX 6000 Ada (sm_89) with torch 2.12.1+cu130 and torchao 0.17.0: converting on CPU and then moving gives output bit-identical to moving and then converting, for both FP8 and INT8.
No GPU was used for the unit tests. Device selection and transformer conversion are stubbed there, so they verify decisions, ordering, status reporting and failure behavior rather than a real torchao conversion.
Known tradeoffs
Fastidentifies the accelerated code path on this host. It is not a measured speed ratio, except for MiniMax H3's existing comparison with its GGUF sibling.local_files_onlyresolves no snapshot directory, so the source-precision header scan is skipped there. It returns no verdict rather than a wrong one, which is the behavior without the scan; the shape it would protect is anunsloth/*pipeline shipping raw FP8 without aquantization_config, and no such repo is known.