Repository navigation
feat(turbomind): native SM75 verification attention [stacked on #5019] - #5145
Draft
richardclli wants to merge 41 commits into
Draft
richardclli wants to merge 41 commits into
richardclli wants to merge 41 commits into
Conversation
- Fixed-chain speculator base with EAGLE3 and Qwen3.5 MTP draft models, target-native speculation, and method-keyed draft weight registry - Block speculative verification: paged CuTe verification attention, SM90 GDR verify and commit kernels with persistent pipelining - Unified parameterized batch-op pipeline; executor forward split into target pass and speculative round; host batch ops moved engine-side - Scheduler: unified required admission, simplified rollback, submitted rows carry producer-set effects instead of a kind tag - Op-level pytest suites: verification attention, draft carry, speculative sampling, speculative sequence, target hidden projection, copy
…d 'mtp'
The CLI exposes qwen3_5_mtp/hy3_mtp/deepseek_mtp, but TurboMind registers the
MTP head under the C++ name "mtp" (TM_REGISTER_SPECULATIVE_MODEL("mtp", ...)).
Without normalization, --speculative-algorithm qwen3_5_mtp hit
build_draft_model's ValueError and the C++ 'unknown speculative method' check.
Add normalize_spec_method() and apply it at both the draft-model builder and the
EngineConfig.spec_method assignment so the registered name reaches C++.
…TP on 2080Ti) ForwardSpeculativeRound -> CommitAcceptedRecurrentStateKernel dispatches the recurrent-state dtype through TM_DISPATCH_DTYPES with only (bfloat16_t, float). On pre-SM80 GPUs (no bf16 tensor core) the engine dtype is float16, so the GDN recurrent state is f16 and the speculative round aborts with 'unsupported type: f16'. The kernel body computes in float and only touches StateT via ToFloat/FromFloat, and the input side already dispatches half_t, so adding half_t is a correctness fix for SM75 MTP. Not caught by CI (A100/bf16 path never hits this branch).
…idth CI lint's docformatter hook (v1.7.7, --wrap-descriptions 120) rejects the 82-char one-line summary. Shortened to 58 chars; ruff + docformatter clean.
…ixes Inherited CI blockers from InternLM#5006 (this PR is stacked on it): - unit_test (exit 2, collection error): 3 top-level 'import _turbomind' fail under CI 'pip install -e .' because the bare module name is not on sys.path. Switch to 'from lmdeploy.turbomind import _tm' (canonical, matches test_linear.py) and function-level imports to the package name. - lint (ruff): F841 dead var, F401 unused imports, I001 import sorting. Verified in CI-matched env (0.18.0 + cu12.8 + built _tm.so + torch): 308 tests collected, 0 collection errors (was 213 collected, 2 errors).
Enable direct verification on SM75 so MTP uses a native paged attention instead of the prefill fallback (per-step KV flatten + full-history attention). - new policy_sm75.cuh + kernel_sm75.cu, compiled 75-real only; custom cute atom TM_16x8x16 reuses TurboMind's m16n8k16 -> two m16n8k8 emulation (Turing has no f16 m16n8k16), keeping k16 tiling + ldmatrix - sync KV copy (no cp.async), elementwise P store (no stmatrix), Stages=1, CtaM=64 - int4/uint4 KV reader + dequant (ConvertKvCache<uint4_t,half>), quant_policy 4 - two per-arch static libs + host dispatch_arch.cc; SM90 WGMMA path namespaced and behaviour-unchanged; SM80/89/120 remain unsupported Result: MTP 2.0-2.6x @4K-64K (fp16) and 1.3-1.7x @64K/256K (int4); canary 10/10; needle OK to ~247K. Isolated to SM75.
This branch has not been deployed
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
Stacked on #5019, which is
itself stacked on #5006.
#5006 provides the verification-attention framework; #5019 provides the SM75
runtime fixes and the canonical
_tmtest import this branch inherits.Once #5006 and #5019 are merged, the diff of this PR shrinks to exactly the two
commits (SM75 kernel + tuning/int4 bench). The branch is built on the current
#5019 head and will be rebased after the base PRs merge.
Motivation
The dedicated verification-attention path is SM90-only, so SM75 MTP routes every
verification row through the prefill path (per-step KV flatten plus full-history
attention). This PR adds a native SM75 kernel and makes the verification path
per-arch, without changing SM90 behavior.
Modification
policy_sm75.cuh+kernel_sm75.cu, compiled75-realonly. Turing has nof16
m16n8k16, so a custom cute atom reuses them16n8k8emulation; sync KVcopy (no
cp.async), elementwise P store (nostmatrix), Stages=1, CtaM=64.quant_policy 4).dispatch_arch.cc; the SM90WGMMA path is namespaced and behavior-unchanged. SM80/89/120 remain unsupported.
arch_ == 750) and an int4 attention bench.Dependency note
_tmtest import and SM75 runtime fixes; this branch bases hereValidated checkpoints
SM75 (RTX 2080 Ti), TP2: Qwen3.8-27B NVFP4 and Qwen3.6-35B-A3B NVFP4.
p > 8); causal/non-causal, fp16 + int4 KVMTP remains a short/mid-context lever on this checkpoint/configuration; at
~254K int4 the measured result is parity, not a speedup.
BC-breaking
None for SM90: the WGMMA path is unchanged. SM75 gains a native path; SM80/89/120
keep the existing fallback. The SM75 kernel is compiled only into the SM75 target.
Notes
The PR also lands the arch-neutral dispatch/int4 plumbing that makes future arch
support possible; the SM75 kernel itself is the only arch-specific behavior. The
upstream CI runs on A100/SM80+, so SM75-only tests are skip-guarded and the SM75
evidence is reported here.