feat(deepseek-v4): support W8A8 INT8 output projection - #427
Open
ceci3 wants to merge 13 commits into
Open
Conversation
|
|
||
| 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 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 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, |
<!--
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)
<!--
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)
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
DeepseekV4ForCausalLMimplementation throughModelRegistrywo_aprojectiondefault.flagos,vendor.cuda, andreference.torchimplementationsOpManager dispatch
The
deepseek_v4_inv_rope_quant_int8frontend usesCachedOpand supports:Invalid reference registrations for unimplemented MoE methods are removed so the reference backend can initialize and participate in fallback.
Scope
cache_dtype == int8_per_token_headsupport--enforce-eagerValidation
pytest -q tests/unit_tests/dispatch tests/unit_tests/quantization/test_w8a8_linear.py(289 passed)default.flagos,vendor.cuda, andreference.torch; all three produced identical INT8 outputs