Repository navigation
[Quantization] Add FLUX.2-dev Mistral TE online FP8 support - #5136
Conversation
Signed-off-by: diyapeng <50388704+diyapeng@users.noreply.github.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Signed-off-by: diyapeng <50388704+diyapeng@users.noreply.github.com>
|
Hi @Gaohan123 @Isotr0py @RuixiangMa @SamitHuang @ZJY0516 @david6666666 @hsliuustc0106 @princepride @wtomin @xuechendi @yenuo26 , Can someone please take look at the PR? Thanks! |
| prompt="a cup of coffee on a wooden table, morning light", | ||
| max_lpips=0.15, | ||
| num_inference_steps=10, | ||
| enable_cpu_offload=True, |
There was a problem hiding this comment.
why we use enable_cpu_offload here?
There was a problem hiding this comment.
enable_cpu_offload=True is here for VRAM, not for the FP8 quality comparison itself.
FLUX.2-dev (Mistral TE + BF16 DiT + VAE) exceeds ~80 GiB on a single H100 without offload — we hit OOM when running this case with offload disabled. That matches our docs and the TE-FP8 validation recipe:
https://github.com/vllm-project/vllm-omni/blob/main/docs/user_guide/examples/offline_inference/text_to_image.md — “FLUX.2-dev … >80 (CPU offload required)”
For this test we only quantize the text encoder ({"text_encoder": "fp8", "transformer": None, "vae": None}), so the DiT still loads in BF16 and dominates memory.
Happy to add a one-line comment on the config if that would help future readers.
There was a problem hiding this comment.
Makes sense, thanks!
|
vllm serve black-forest-labs/FLUX.2-dev curl -sS -X POST http://127.0.0.1:8091/v1/images/generations Please post the smoke test results for your online service. Also, I have a question regarding the |
| quantization={"text_encoder": "fp8", "transformer": None, "vae": None}, | ||
| task="t2i", | ||
| prompt="a cup of coffee on a wooden table, morning light", | ||
| max_lpips=0.15, |
There was a problem hiding this comment.
Was this exact 10-step case run? The PR only reports 50-step A/B results, so the 0.15 threshold isn't validated yet.
There was a problem hiding this comment.
Just did offline test with 10 steps, and put in PR description, can you help check?
Thanks for point out this, just did the online serving test again, with |
|
LGTM now. Thanks for your contribution |
…ject#5136) Signed-off-by: diyapeng <50388704+diyapeng@users.noreply.github.com> Co-authored-by: diyapeng <50388704+diyapeng@users.noreply.github.com> Signed-off-by: y_null <y_null@qq.com>
…ject#5136) Signed-off-by: diyapeng <50388704+diyapeng@users.noreply.github.com> Co-authored-by: diyapeng <50388704+diyapeng@users.noreply.github.com>
…ject#5136) Signed-off-by: diyapeng <50388704+diyapeng@users.noreply.github.com> Co-authored-by: diyapeng <50388704+diyapeng@users.noreply.github.com>
…ject#5136) Signed-off-by: diyapeng <50388704+diyapeng@users.noreply.github.com> Co-authored-by: diyapeng <50388704+diyapeng@users.noreply.github.com>
PLEASE FILL IN THE PR DESCRIPTION HERE.
RFC #1854
Purpose
Add online FP8 quantization support for the Mistral text encoder used by
black-forest-labs/FLUX.2-dev.This branch:
Mistral attention and MLP weight-bearing linear layers while leaving embeddings
and the language-model head unquantized.
text_encodermodule prefix so component quantization rulesselect the intended Mistral layers.
text-encoder-only FP8 with an unquantized BF16 transformer and VAE.
unresolved parameters to CUDA.
online text-encoder quantization to avoid the transient load-time GPU OOM.
Environment
black-forest-labs/FLUX.2-devTest Plan
Unit tests
Result: PASS,
31 passed, 14 warnings in 18.20s.Online serving smoke test
20058.804734s58.644981s11024x1024RGB3,147,861~65.5 GiBOffline A/B with 10 steps
Config:
black-forest-labs/FLUX.2-deva cup of coffee on a wooden table, morning light1024x10241042True{"text_encoder": "fp8", "transformer": null, "vae": null}45.105s~64.6 GiB0.00000051.433s63.65 GiB0.007244The measured LPIPS is
0.007244, which is below the test thresholdmax_lpips=0.15.Offline A/B with 50 steps
Baseline:
Candidate:
Each variant loaded the model once and ran 3 measured prompts (seeds 42, 43, 44).
Memory: PyTorch peaks (
max_memory_allocated/max_memory_reserved) are recorded per stage in the GPU worker, then counters reset. The text-encoder peak is taken after the prior component is offloaded, so it is not mixed with the BF16 transformer. Stage peaks are also combined for the full-request peak.Results
Offline benchmark
Component memory profile
The allocated column is the primary component-footprint metric. Reserved memory
is included as allocator context and is used for the whole-request high-water mark.
All three measured prompts produced the same component peaks.
Offline A/B (BF16 | TE-FP8)
Takeaways:
(46.53%), from 45,466.62 MB to 24,309.70 MB.
first measured request includes compile/cold-path cost in both variants.
(+32 MB) because the diffusion transformer remains unquantized BF16.
BEFORE SUBMITTING: read CONTRIBUTING.md and run the precheck-pr skill with the code agent for a self-check against project conventions.
(anything written below this line will be removed by GitHub Actions)