Skip to content

WIP: support deepseek v3.2 used Pytorch model - #2076

Draft
sunbaosong wants to merge 1 commit into
xLLM-AI:mainfrom
sunbaosong:base-pr2009
Draft

WIP: support deepseek v3.2 used Pytorch model#2076
sunbaosong wants to merge 1 commit into
xLLM-AI:mainfrom
sunbaosong:base-pr2009

Conversation

@sunbaosong

Copy link
Copy Markdown
Collaborator

Description

Related Issues

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactor
  • Documentation
  • Test
  • Build or CI

Pull Request Checklist

Thank you for contributing to xLLM. Before requesting review, please make sure the following items are complete.

PR Title and Commit Messages

  • The PR title and each commit message follow the xLLM commit format: <type>: <subject>.

Allowed types: feat, bugfix, docs, test, refactor, chore, style, revert, perf, model, build, release.
The subject should use clear English, start with a verb, include at least 4 words, and end with ..

Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit or an equivalent command.
  • I have installed the hooks with pre-commit install.
  • I have run pre-commit run --all-files and fixed any reported issues.

If you are unsure how to set up pre-commit, see the pre-commit documentation.

Self Review

  • I have self-reviewed the code according to .agents/skills/code-review/references/custom-code-style.md, especially code written or assisted by AI.
  • I have rebased this PR onto the latest main branch.

Build and Test Coverage

  • Tests have been added or updated as needed.
  • CUDA: python setup.py build test has passed on a CUDA machine.
  • NPU: python setup.py build test has passed on an NPU machine.
  • MLU: python setup.py build test has passed on an MLU machine.

Reviewer Notes

// construct_quant_lightning_indexer_output_tensor. For TND query + PA_BSND key
// the selected-count axis is sized by the key's head axis; BSND query adds the
// extra batch axis.
at::Tensor construct_lightning_indexer_output_tensor(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

torch::

… fix

DeepSeek-V3.2 W8A8 adaptation for Ascend NPU, with xllm-vs-vllm bit-exact
alignment and multinode correctness. Squashes the adaptation + four fixes:

- feat: absorbed-form MLA + W8A8 (static/dynamic) + MoE + TP adaptation
  (npu_grouped_matmul, npu_moe_init_routing_v2, npu_moe_token_unpermute,
  npu_swiglu / npu_dynamic_quant, SFA).
- fix: align W8A8/MLA ops with vllm for bit-exact precision (single-card +
  TP=2: gate -> topk -> dispatch -> gmm1 -> gmm2 -> combine -> AR all
  bit-exact).
- fix: gate o_proj quant_bias to tp_rank==0 (row-parallel; was double-
  counted by all_reduce at TP>=2).
- fix: align MoE with vllm CANN ops (routed_scaling applied post-combine
  pre-AR, sum-then-reduce AR structure) for TP=2 bit-exact.
- fix(multinode): use the framework's GLOBAL tp_rank (config["tp_rank"],
  = tp_group_->rank()) for weight sharding instead of the local device
  index (_tp_rank_from_device returns 0..7 on every node). The local rank
  made every node load the same first N/per-node shards (missing the rest,
  cross-node duplicated) -> all_reduce double-counted + MoE expert weights
  partly loaded -> L13 MoE explosion -> garbled output on 16-NPU multinode.

Verified: single-card + TP=2 5L bit-exact with vllm; 16-NPU 2-node
multinode output coherent (was garbled).

Pre-squash individual commits preserved on branch backup/dsv32-pre-squash.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants