Skip to content

feat(deepseek-v4): support W8A8 INT8 output projection - #427

Open
ceci3 wants to merge 13 commits into
mainfrom
feat/deepseek-v4-int8
Open

feat(deepseek-v4): support W8A8 INT8 output projection#427
ceci3 wants to merge 13 commits into
mainfrom
feat/deepseek-v4-int8

Conversation

@ceci3

@ceci3 ceci3 commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • register a thin DeepseekV4ForCausalLM implementation through ModelRegistry
  • add fused inverse-RoPE plus per-row INT8 activation quantization for the DSV4 wo_a projection
  • route the DSV4 operator through OpManager with default.flagos, vendor.cuda, and reference.torch implementations
  • use native CUTLASS INT8 scaled matmul when FlagGems is disabled
  • preserve torch.compile and FULL_AND_PIECEWISE CUDA graph execution
  • prepare group-major W8A8 weights/scales for grouped projections and add unit coverage

OpManager dispatch

The deepseek_v4_inv_rope_quant_int8 frontend uses CachedOp and supports:

  • FlagGems: fused Triton implementation under the FlagGems device guard
  • CUDA vendor: fused Triton implementation on NVIDIA GPUs
  • Reference: pure PyTorch inverse-RoPE and symmetric INT8 quantization

Invalid reference registrations for unimplemented MoE methods are removed so the reference backend can initialize and participate in fallback.

Scope

  • targets the vLLM 0.24 DeepSeek-V4 NVIDIA implementation
  • does not add cache_dtype == int8_per_token_head support
  • does not require FlagGems
  • does not use --enforce-eager

Validation

  • Python compilation checks passed
  • pytest -q tests/unit_tests/dispatch tests/unit_tests/quantization/test_w8a8_linear.py (289 passed)
  • actual OpManager execution verified independently for default.flagos, vendor.cuda, and reference.torch; all three produced identical INT8 outputs
  • end-to-end TP8/EP8 serving with FP8 KV cache, torch.compile, and FULL_AND_PIECEWISE CUDA graphs
  • throughput benchmark completed successfully for 1K, 4K, 16K, and 64K input lengths; INT8 output throughput improved over the no-FlagGems FP8 baseline by 8.59%, 1.51%, 3.01%, and 4.05%, respectively

@github-actions github-actions Bot added the docs label Aug 31, 2026

tensors = [torch.empty(1) for _ in range(7)]
out = torch.empty(2, 3, 4)
result = deepseek_v4._deepseek_v4_fl_attention(*tensors, out, "layer")

tensors = [torch.empty(1) for _ in range(7)]
out = torch.empty(2, 3, 4)
result = deepseek_v4._deepseek_v4_fl_attention(*tensors, out, "layer")
Comment on lines +97 to +107
del (
hidden_states,
qr,
kv,
kv_score,
indexer_kv_score,
indexer_weights,
positions,
out,
layer_name,
)
Comment thread vllm_fl/ops/sparse_attn_indexer.py Fixed
Comment thread vllm_fl/ops/sparse_attn_indexer.py Fixed
Comment on lines +368 to +371
# if current_platform.is_cuda() and topk_tokens in (512, 1024, 2048):
# workspace_manager = current_workspace_manager()
# (topk_workspace,) = workspace_manager.get_simultaneous(
# ((RADIX_TOPK_WORKSPACE_SIZE,), torch.uint8),
Comment on lines +381 to +390
# else:
# torch.ops._C.top_k_per_row_decode(
# logits,
# next_n,
# seq_lens,
# topk_indices,
# num_rows,
# logits.stride(0),
# logits.stride(1),
# topk_tokens,
Comment thread vllm_fl/ops/sparse_attn_indexer.py Fixed
Comment thread vllm_fl/ops/sparse_attn_indexer.py Fixed
Comment on lines +368 to +371
# if current_platform.is_cuda() and topk_tokens in (512, 1024, 2048):
# workspace_manager = current_workspace_manager()
# (topk_workspace,) = workspace_manager.get_simultaneous(
# ((RADIX_TOPK_WORKSPACE_SIZE,), torch.uint8),
Comment on lines +381 to +390
# else:
# torch.ops._C.top_k_per_row_decode(
# logits,
# next_n,
# seq_lens,
# topk_indices,
# num_rows,
# logits.stride(0),
# logits.stride(1),
# topk_tokens,
ceci3 and others added 3 commits September 1, 2026 02:57
<!--
 Copyright 2026 FlagOS Contributors

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 -->

### PR Category
<!-- One of [Core | Vendor | OP | Tools | Others] -->

### PR Type
<!-- One of [User Experience | New Features | Bug Fixes | Improvements |
Performance | Breaking Change | Deprecations | Test Case | Docs |
Others] -->

### Description
<!-- Describe what this PR does and why. -->

### Related Issues
<!-- Link any related issues: Fixes #issue, Closes #issue, or Related to
#issue -->

### Changes
<!-- List the key changes made in this PR. -->
-

### Testing
<!-- How has this change been tested? Include test commands, hardware
used, etc. -->
-

### Checklist
- [ ] I have run the existing tests and they pass
- [ ] I have added tests for my changes (if applicable)
- [ ] I have updated the documentation (if applicable)
@github-actions github-actions Bot added the ci label Sep 1, 2026
xmhubj and others added 3 commits September 1, 2026 15:42
<!--
 Copyright 2026 FlagOS Contributors

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 -->

### PR Category
<!-- One of [Core | Vendor | OP | Tools | Others] -->

### PR Type
<!-- One of [User Experience | New Features | Bug Fixes | Improvements |
Performance | Breaking Change | Deprecations | Test Case | Docs |
Others] -->

### Description
<!-- Describe what this PR does and why. -->

### Related Issues
<!-- Link any related issues: Fixes #issue, Closes #issue, or Related to
#issue -->

### Changes
<!-- List the key changes made in this PR. -->
-

### Testing
<!-- How has this change been tested? Include test commands, hardware
used, etc. -->
-

### Checklist
- [ ] I have run the existing tests and they pass
- [ ] I have added tests for my changes (if applicable)
- [ ] I have updated the documentation (if applicable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants