Repository navigation
Studio diffusion: key the CFG-batch verdict on the weight quant, not just the module layout - #15047
Conversation
…and quant scheme A torchao INT8 or FP8 dynamic load keeps nn.Linear and a bf16 .dtype, so the stored batched-vs-plain verdict of a bf16 load was reused on its quantized load without timing, and the reverse. Hash the weight tensor subclasses (with their non-tensor attributes, e.g. fp8 fast accumulate) and the engaged transformer_quant, and bump the store version so old entries are not read. A compute-bound plain verdict comes from one plain pair with no doubled call timed; keep it for the load only instead of storing it for every process.
|
@codex review |
1 similar comment
|
@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. |
|
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 |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ 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
The cross-process CFG-batch verdict store (#14849) keys the batched-vs-plain decision on a load identity that cannot tell a bf16 load from a torchao INT8 or FP8 dynamic load of the same model. A verdict timed on one is reused on the other without timing. This PR adds the weight tensor classes and the engaged
transformer_quantto the key, and bumps the store version so old entries simply miss. Every other part of the verdict store is unchanged, so a shape still takes one path in every process.Details
quantize_, layers are stillnn.Linearand the weights still reporttorch.bfloat16, so_load_identityhashed bf16, INT8-dynamic and FP8-dynamic (PerRow) to the same sha1. An INT8 or FP8 load could then be stuck on the path that was faster for bf16, or miss a gain. Pixels were within the batched tolerance either way, so this is speed only._load_identitynow also hashes each parameter's tensor class and, for torchao subclasses, their non-tensor attributes (mm_config,act_quant_kwargs,kernel_preference,dtype;block_sizeis skipped since it only follows the layer shape). This separates fp8 with and without fast accumulate too.install_cfg_batchtakestransformer_quant. The image (diffusion.py) and video (video.py) loads passtransformer_quant_engaged, the scheme the load already records, so GGUF and other non-torchao quant paths are covered as well._unsloth_attention_backend), read when the verdict is looked up.set_attention_backend()changes neither the module classes nor the config, so the load identity alone missed a backend switch.versiongoes from 1 to 2, and the reader ignores a file of another version. Old entries simply miss and are replaced on the next write.Tests
New tests in
studio/backend/tests/test_diffusion_cfg_batch.py, all 6 fail on main and pass here:test_the_verdict_key_tells_bf16_from_torchao_int8_and_fp8_loads: bf16, INT8, FP8 fast accumulate on and off all give different keys.test_the_verdict_key_includes_the_engaged_transformer_quanttest_the_same_load_gives_a_stable_verdict_key: a deep copy of each load gives the same key.test_install_keys_the_router_on_the_engaged_quanttest_the_verdict_key_follows_the_live_attention_backendtest_a_version_1_verdict_store_is_not_readpytest tests/test_diffusion_cfg_batch.py tests/test_diffusion_cfg_batch_sync.py: 48 passed, 2 skipped.tests/test_diffusion_memory_vram_budget.py -k cfg: 3 passed. CPU only. The speed effect on a real GPU of reusing a bf16 verdict on an INT8 or FP8 load was not measured.