perf(dflash): add MMID dispatch telemetry#519
Open
cheese-cakee wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…uant paths - mmvq.cu: width-1 MUL_MAT_ID now reports variant=single instead of variant=legacy_moe. The single-column MMVQ case is not the multi-token legacy MoE launch, so the old label conflated single-token decode with grouping-rejected batches. - ggml-cuda.cu: graph telemetry reports mmvq_max=0 for non-quantized nodes instead of the type-independent ceiling get_mmvq_mmid_max_batch returns, matching the mmvq_ok=0 eligibility already reported for those nodes. - ENVIRONMENT.md: add DFLASH_MMID_TELEMETRY to the generated inventory list. Diagnostics stay default-off; no inference-path behavior change.
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
- mmvq.cu: the ungrouped MUL_MAT_ID path now labels the kernel that actually runs (moe / tokenwise / generic), derived from the same env flags mul_mat_vec_q_switch_type reads, instead of always variant=legacy_moe. The DFLASH_CUDA_MMVQ_MOE_TOKENWISE and DFLASH_CUDA_MMVQ_MOE_KERNEL modes are now reported accurately. - ggml-cuda.cu: the graph-compatibility scan no longer breaks on the first graph-incompatible node when telemetry is on, so event=graph is emitted for every MUL_MAT_ID node. The early exit is preserved when telemetry is off, so the graph-capture decision is unchanged either way. Diagnostics stay default-off; no inference-path behavior change.
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
Adds a default-off
DFLASH_MMID_TELEMETRYdiagnostic that reports, for everyMUL_MAT_ID(MoE expert matmul): the dispatch path chosen, the MMVQ varianttaken, and per-node CUDA-graph compatibility. It exists to make the grouped-MMID
work and the MoE graph-capture gate measurable without a debugger or a custom
build. Zero cost and no behavior change when the variable is unset.
Changes
ggml/src/ggml-cuda/ggml-cuda.cu(ggml_cuda_mul_mat_id):event=dispatchline naming the path taken (
mmvq/mmvf/mmq/mmf/sync_fallback)with type, width (
ne2), pairs, expert count,top_k, and the MMVQ ceiling.ggml/src/ggml-cuda/ggml-cuda.cu(ggml_cuda_graph_check_compability):event=graphline for everyMUL_MAT_IDnode with the MMVQ/MMQ eligibilityused to decide graph capture. Reports
mmvq_max=0for non-quantized nodes.The scan's early exit is skipped while telemetry is on so a node that disables
graphs does not suppress later nodes' lines.
ggml/src/ggml-cuda/mmvq.cu(ggml_cuda_mul_mat_vec_q):event=mmvqlinereporting the variant that actually runs:
grouped,single(width-1single-column MMVQ), or, for the ungrouped multi-token path, the downstream
kernel
mul_mat_vec_q_switch_typeselects (moe/tokenwise/generic)with a
reason.server/docs/ENVIRONMENT.md: document the variable in the table and thegenerated inventory.
How it works
The flag is read via function-local
staticgetenvs (evaluated once each), andevery emit site is guarded by one, so an unset flag is a predictable no-op. The
event=mmvqvariant is derived from the same env staticsmul_mat_vec_q_switch_typeuses, so the label matches the kernel that runs. Whenthe flag is off the graph-compatibility scan keeps its original early exit, so the
graph-capture decision and its cost are unchanged; only with the flag on does it
keep scanning to log every node. The one always-on change (from the base commit)
is hoisting the
mmvq_mmid_maxcomputation, whose value is identical where used.Output is byte-identical with the flag set or unset.
Performance
None intended. Diagnostics only; no kernel selection or dispatch logic changes.
Limitations
ggml-cudabackend only.event=graphlines are emitted from the graph-compatibility check, so theyappear only when CUDA graphs are enabled for the graph.
Verification
Hardware: RTX 4050 Laptop GPU (Ada, sm_89), CUDA 12.6 (nvcc V12.6.85), WSL2
Ubuntu, g++ 13.3.0. ggml built with
GGML_CUDA=ON GGML_CUDA_GRAPHS=ON, archsm_89 (graphs on so the
event=graphpath is compiled in).A standalone harness issues
MUL_MAT_IDat widths {1, 2, 8} for Q4_K/Q6_K plus anon-quantized (F16) node, across the dispatch modes, all with
DFLASH_MMID_TELEMETRY=1. Representative captured lines:Assertions, all passing: the variant label matches the mode selected in each run
(
grouped/moe/tokenwise/generic),variant=singlefor width-1, andvariant=legacy_moenever appears (0 occurrences); in a graph where the F16 nodeprecedes the Q4_K node, both emit
event=graph(the later node is no longerdropped by the compatibility scan's early exit), with the F16 node reporting
mmvq_max=0and the Q4_K nodemmvq_max=16. The diagnostic writes only to stderrand touches no tensor data or dispatch decision, so generated output is unchanged
whether the variable is set or unset.