Skip to content

feat(deepseek): add optional MoE expert statistics dump - #185

Draft
high-cloud wants to merge 4 commits into
hw-native-sys:mainfrom
high-cloud:deepseek-moe-stats-dump
Draft

feat(deepseek): add optional MoE expert statistics dump#185
high-cloud wants to merge 4 commits into
hw-native-sys:mainfrom
high-cloud:deepseek-moe-stats-dump

Conversation

@high-cloud

@high-cloud high-cloud commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an optional DeepSeek V4 MoE load-statistics dump that keeps one fixed
kernel ABI whether collection is enabled or disabled. Enabled runs emit
per-layer physical-expert activation and routed-token counts as JSONL; disabled
runs skip buffer clearing, device-to-host copies, and file writes.

Changes

  • Add --moe-stats-output to the unified online/offline CLI and allow embedded
    executors to enable, redirect, or disable collection at runtime.
  • Register fixed statistics buffers through the current TaskArgs architecture
    for prefill, decode, MTP prefill, standalone MTP decode, and fused MTP decode.
  • Preserve chunked-prefill dynamic token views while passing the MoE dump flag
    as an unspecialized runtime scalar.
  • Initialize persistent MTP state through registered allocation bases required
    by the current DistributedWorker; a PyPTO offset-copy API is tracked as the
    follow-up needed to replace whole-rank initialization uploads.
  • Add JSONL serialization, unit coverage, and an operator skill with a bundled
    output validator.
  • Pin pypto-lib to the fixed-ABI implementation from
    Add: dump DeepSeek V4 MoE expert load statistics pypto-lib#1016.

Verification

  • /data/yangyaodong/.conda/envs/pypto-lib/bin/python -m pytest tests/unit:
    208 passed.
  • python tests/lint/check_headers.py: passed.
  • python tests/lint/check_english_only.py: passed.
  • ruff check --config ruff.toml .: passed.
  • Real-NPU GBS32 run task_20260824_005902_21669804308 on physical devices
    1,3,5,7,9,11,13,15: 32 requests each generated 256 tokens (8192 total),
    and the JSONL dump contained 215 records across prefill, MTP prefill, and
    fused MTP decode.

Closes #181

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6cff1c3f-773a-45ab-ad9b-2334067039c1


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

- Expose online and offline controls for per-layer physical-expert load
  statistics without changing the disabled runtime path
- Reuse fixed resident buffers across prefill, decode, MTP, and fused MTP
  dispatches, and write routed token counts as JSONL
- Add unit coverage and an operator skill for enabling and validating the
  dump

Closes hw-native-sys#181
Bind the MoE statistics buffer explicitly for MTP prefill so the optional
dump ABI works in both enabled and disabled modes.

Publish MTP initialization mirrors from registered allocation bases because
DistributedWorker rejects interior device pointers. Zero the full mirrors
before their first upload; a PyPTO offset-copy API will be tracked separately
to avoid whole-shard updates in continuous serving.
@high-cloud
high-cloud force-pushed the deepseek-moe-stats-dump branch from 7977d9b to 4282f44 Compare August 24, 2026 12:38
Preserve the dynamic prefill TaskArgs path while appending the MoE dump
runtime scalar after rebasing onto chunked-prefill support.

Carry moe_token_counts through the newly split standalone MTP ABI and update
the existing kernel-signature assertions to cover runtime scalars explicitly.
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.

[Feature] 支持运行时可开关的 MoE 专家负载数据 Dump

1 participant