Skip to content

[None][perf] Fuse KDA verify and opt-in prefill projections - #17046

Closed
longlee0622 wants to merge 2 commits into
NVIDIA:feat/kimi_k3from
longlee0622:agent/kimi-kda-fused-verify-inproj
Closed

[None][perf] Fuse KDA verify and opt-in prefill projections#17046
longlee0622 wants to merge 2 commits into
NVIDIA:feat/kimi_k3from
longlee0622:agent/kimi-kda-fused-verify-inproj

Conversation

@longlee0622

@longlee0622 longlee0622 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Reuse finalized fused KDA input-projection weights during speculative verify.
  • Avoid six separate q/k/v/f/b/g GEMMs when fused weights are available.
  • Add opt-in fused prefill projection via TLLM_KDA_ENABLE_FUSED_PREFILL_PROJ=1; default remains disabled for performance evaluation.
  • Preserve the separate projection fallback when the env var is disabled or fused weights are unavailable.
  • Cover fused prefill and fused verify against their sequential projection paths on B200.

Testing

  • SKIP=ruff-format pre-commit run --files tensorrt_llm/_torch/models/modeling_kimi_linear.py tests/unittest/_torch/modeling/test_kimi_kda_fused_verify_parity.py
  • python3 -m py_compile tensorrt_llm/_torch/models/modeling_kimi_linear.py tests/unittest/_torch/modeling/test_kimi_kda_fused_verify_parity.py
  • B200 on umbriel-b200-027: python3 -m pytest --confcutdir=tests/unittest/_torch/modeling tests/unittest/_torch/modeling/test_kimi_kda_fused_verify_parity.py -v -x -s
    • Result: 2 passed
    • Fused prefill output, conv state, and SSM state: cosine 1.000000, relative L2 0
    • Verify round 1/2 output cosine: 0.999993
    • Verify committed-state cosine: 1.000000

The confcutdir flag isolates this target GPU test from the checkout-wide conftest. The available dev images prebuilt C++ bindings are from another branch and fail global collection before this Python-only test is reached.

Post-#17088 integration

The rebased prefill dispatch now preserves #17088 behavior in this order:

  1. Full projection fusion when TLLM_KDA_ENABLE_FUSED_PREFILL_PROJ=1.
  2. Otherwise use [TRTLLM-14703][fix] 1st cherrypick [combine MR99+MR100+MR102 on latest feat (with MR100 dispatch wiring)], 2nd cherrypick [deferred-finalize scales fix, fused-epilogue batch gate, hardening] #17088 qkvg_proj for default packed q/k/v when available.
  3. Otherwise use separate q/k/v fallback.

Verify remains fully fused by default. Final head 7a35a5e022: local and GitHub pre-commit checks plus DCO pass. The B200 parity data above predates the rebase; the post-rebase change is dispatch integration and formatting, not kernel code.

@longlee0622 longlee0622 changed the title [None][perf] Fuse KDA verify input projections [None][perf] Fuse KDA verify and opt-in prefill projections Jul 30, 2026
Signed-off-by: Jonas Li <6110159+longlee0622@users.noreply.github.com>
@longlee0622
longlee0622 force-pushed the agent/kimi-kda-fused-verify-inproj branch from bb743e1 to 3c3ae7b Compare August 3, 2026 03:34
Signed-off-by: Jonas Li <6110159+longlee0622@users.noreply.github.com>
@longlee0622
longlee0622 force-pushed the agent/kimi-kda-fused-verify-inproj branch from 3c3ae7b to 7a35a5e Compare August 3, 2026 04:01
@longlee0622

Copy link
Copy Markdown
Collaborator Author

Superseded by #17311

@longlee0622 longlee0622 closed this Aug 5, 2026
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.

1 participant