Repository navigation
Conversation
Captures the ffn_moe_topk id tensors via the eval callback and writes one layer,expert CSV row per routed activation, for a prompt evaluation plus a short greedy continuation. Measures expert-routing skew on a real workload, which decides whether hot-expert caching/pinning/placement strategies can work for a given model before implementing them. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Hi @aryan0078, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
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.
Overview
Adds
examples/moe-trace: a small diagnostic that logs which routed experts aMoE model selects — one
layer,expertCSV row per routed activation — for aprompt evaluation plus a short greedy continuation.
It hooks the scheduler eval callback and downloads only the
ffn_moe_topkidtensors (one tiny i32 tensor per MoE layer per ubatch), so tracing adds
negligible overhead to the evaluation itself.
Motivation: expert-routing statistics decide whether hot-expert strategies
(caching, pinning, offload placement) can work for a given model, and that is
worth measuring on a real workload before implementing anything. Concretely,
tracing Qwen3.8-Flash-Next (512 experts, top-10) showed 98.6% of all 24,576
(layer, expert) slots active within ~1.3k tokens and a hottest-slot share of
only ~2.5x uniform — i.e. no exploitable hot set, which ruled out a planned
cache implementation in an hour instead of after days of building it.
Usage and aggregation one-liners are in the example's README.
Additional information
Output goes to
MOE_TRACE_OUT(defaultmoe_trace.csv). The tool only readstensors named
ffn_moe_topk*, whichbuild_moe_ffnnames uniformly acrossMoE architectures.
Requirements
an AI assistant (Claude Code). I reviewed the diff and ran the tool against
real models on my machine (RX 6700, Vulkan; i7-12700).
🤖 Generated with Claude Code