feat(pytorch): add optimized Gluon blocked FP8 GEMM for Hopper - #4830
Open
grimoire wants to merge 11 commits into
Open
feat(pytorch): add optimized Gluon blocked FP8 GEMM for Hopper#4830grimoire wants to merge 11 commits into
grimoire wants to merge 11 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Hopper-targeted, Gluon/WGMMA-based blocked FP8 GEMM path for LMDeploy’s PyTorch backend, integrates it into the blocked-FP8 Linear provider dispatch, and adds correctness/determinism tests plus supporting tooling and environment/config updates.
Changes:
- Add a shape-specialized Gluon blocked FP8 GEMM kernel for SM90 (Hopper) with dispatch across small/mid/persistent schedules.
- Extend CUDA blocked-FP8 Linear provider selection (DeepGEMM → Gluon → Triton) and add
LMDEPLOY_BLOCKED_FP8_GEMM_BACKENDoverride. - Add Hopper/Gluon kernel correctness + determinism tests and introduce a dependency-version auditing maintenance script; update FP8 scale alignment for Hopper TMA.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/pytorch/kernel/test_blocked_fp8_gemm_gluon.py | Adds Hopper/Gluon blocked-FP8 GEMM correctness, determinism, and contract-validation tests (skipped when unsupported). |
| lmdeploy/pytorch/tools/audit_dependency_versions.py | Adds a read-only tool to inventory dependency requirements and source-level version checks. |
| lmdeploy/pytorch/nn/linear/blocked_fp8.py | Plumbs block_size/fp8_dtype into the blocked-FP8 Linear builder call. |
| lmdeploy/pytorch/kernels/cuda/blocked_gemm_fp8.py | Pads FP32 scale strides to satisfy Hopper TMA 16-byte alignment requirements. |
| lmdeploy/pytorch/kernels/cuda/blocked_fp8_gemm_gluon.py | Introduces the new Gluon blocked FP8 GEMM implementation with schedule dispatch and SM budgeting support. |
| lmdeploy/pytorch/envs.py | Adds LMDEPLOY_BLOCKED_FP8_GEMM_BACKEND env parsing for provider selection. |
| lmdeploy/pytorch/check_env/transformers.py | Replaces min/max version checks with a SpecifierSet-based Transformers version policy warning. |
| lmdeploy/pytorch/backends/cuda/op_backend.py | Switches blocked-FP8 Linear builder to the new CUDA provider-dispatch builder. |
| lmdeploy/pytorch/backends/cuda/blockedf8_modules.py | Refactors blocked-FP8 Linear implementations into a common CUDA base and adds Gluon provider + provider selection logic. |
| lmdeploy/pytorch/backends/blockedf8_modules.py | Extends the blocked-FP8 Linear builder interface to accept block_size and fp8_dtype. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Kernel design
The kernel uses three shape-specific schedules:
M <= 128: single-partition multistage kernel, with a transposed GEMM schedule forM <= 8and large K;129 <= M <= 256: non-persistent, warp-specialized pipeline;M > 256: persistent, warp-specialized kernel using two M waves and scale caching.Dispatch
The automatic provider order is:
The provider can be overridden with:
LMDEPLOY_BLOCKED_FP8_GEMM_BACKEND={auto,deepgemm,gluon,triton}Performance
Measured on an NVIDIA H200 with
N=K=4096, identical preallocated inputs, 50 ms warmup, 250 ms measurement, and five alternating trials. Values are median p50 latency.Warning
The kernel for large M follow the same design of deepgemm, but kernel for middle/small M failed to get the same prerformance.