Repository navigation
Add SM89 Qwen3-VL official FP8 path (RTX 4090) - #110
Closed
heiheiha798 wants to merge 3 commits into
Closed
heiheiha798 wants to merge 3 commits into
heiheiha798 wants to merge 3 commits into
Conversation
Contributor
Author
|
Superseded by a combined 8B + 2B PR (config-driven SM89 path + 2B offline FP8 quantizer). Closing this 8B-only PR; the replacement contains these same commits plus 2B support. New PR link to follow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Brings up Qwen3-VL-8B on Ada RTX 4090 (sm_89) using the official
Qwen3-VL-8B-Instruct-FP8checkpoint. This is the SM89 counterpart to theSM120/NVFP4 path (#107/#109), but it intentionally uses the checkpoint's
native block-scaled FP8 language weights instead of NVFP4 (NVFP4 is a
Blackwell-only path). The vision tower, geometry, scatter, DeepStack and
interleaved-MRoPE are reused from the SM120 Qwen3-VL work; this branch adds
the Ada FP8 language stack and a native sm_89 block-128 GEMM.
The core lever is a native Ada FP8 e4m3 block-128 scaled GEMM that reads
the FP8 weight directly (no dequant-to-bf16 scratch), cutting per-linear
weight traffic ~5x while keeping the per-token activation scale. This is the
fix for the SM89 prefill bottleneck (weight-dequant memory bandwidth); the
CUTLASS Ada blockwise route was a dead end at these shapes.
What's in it
fp8_block128_gemm_mma_sm89.cu):plain Ada
mma.sync.aligned.m16n8k32.row.col.f32.e4m3.e4m3.f32(no.kind::f8f6f4, which is sm_120a-only), DeepSeek block-128 scaling foldedin the mainloop (BLOCK_K pinned to 128). Adapted from the SM120
fp8_smallM_handtunedcp.async pipeline + m16n8k32 tiling. Shape-tuneddispatcher over the Qwen3-VL-8B linear shapes.
qwen3_vl_fp8_sm89.py): block-scaled M=1 FP8 GEMVdecode + native block-128 FP8 GEMM prefill; BF16 attention (FA2), BF16
residual/norms, per-token/per-128 FP8 activation quant fused into
RMSNorm / residual-add-RMSNorm / SiLU-mul; CUDA-graph decode (per cache
position).
lm_headstays BF16 by default (cuBLASLt);use_fp8_lm_headis an explicit experimental mode.
qwen3_vl_fp8_sm89_multimodal.py): single-imageprefill as a captured CUDA-graph replay (vision + S>1 FP8 blockscaled
language + final norm), lm_head eager after replay; multi-image / video use
the eager prefill. Decode graphs keyed by
(cache_pos, rope_pos)so MRoPEcontinuation never reuses a stale rotary position across prompts.
_qwen3_vl_fp8_weights.py): keeps the officialweight(e4m3) +weight_scale_inv(128x128 block) layout, fuses q/k/vand gate/up, optional host-side
lm_headFP8 quant.== (8,9)check, required-symbolpresence check (rebuild hint), an explicit config check that the checkpoint
is the official 8B text stack (
36/32/8/128/4096/12288), and runtimeK%128/N%128guards on the new GEMM + block-128 quant entries.docs/qwen3_vl_fp8_sm89.md, a smoke benchmark(
scripts/smoke_qwen3_vl_fp8_sm89.py), prefill-GEMM micro-benchmarks, andCPU-friendly import/invariant/geometry tests.
Additive on the shared module front: the new GEMM is gated behind
ENABLE_SM89_BLOCK_FP8_GEMM(only compiled forGPU_ARCH=89); theblock-128 quant helpers are added to the existing quant TU; the SM120 paths
are untouched.
Performance & correctness (RTX 4090, sm_89)
Environment: NVIDIA GeForce RTX 4090, official
Qwen3-VL-8B-Instruct-FP8,workload
FlashRT.png+ prompt"Describe this image in one sentence."(6256 vision patches, 1581 language tokens — same workload as the SM120
report).
785 (matches the SM120 report's image token).
(
2168).The same workload is faster on the SM120/NVFP4 path because it uses Blackwell
NVFP4 language kernels; this branch targets the best Ada-compatible dtype
path (official FP8 weights, BF16 attention/residual/lm_head).
Build & usage
CPU-friendly tests:
pytest tests/test_qwen3_vl_fp8_sm89.py tests/test_qwen3_vl_smoke.py.See
docs/qwen3_vl_fp8_sm89.mdfor the full architecture / dtype map / limits.Notes (scope)
lm_headstays BF16 by default;use_fp8_lm_headcan match single-steplogits but multi-token generation can diverge, so it stays experimental.
the eager path.
host-side sequence length).
sizes fail fast rather than silently mis-sizing the KV cache.
validation lives in the local smoke script (numbers above); CI covers
import / loader-invariant / geometry-cache equivalence.