Repository navigation
[https://nvbugs/7125691][fix] Restore the Kimi K3 KDA reference helpers used by test_kda_prefill.py - #22685
Conversation
…rs used by test_kda_prefill.py Signed-off-by: Eric Tsai <ertsai@nvidia.com>
|
No actionable comments were generated in the recent review. WalkthroughThe change adds input-generation and recurrent-reference helpers to the Kimi K3 KDA test module. The helpers create CUDA tensors and compute token-by-token outputs and final state in fp64. ChangesKDA prefill test support
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Other · Severity of issue fixed: Low Possibly related PRs
Suggested reviewers: Merge Risk:
|
|
/bot run --extra-stage "GR100-PyTorch-Post-Merge-1" |
|
PR_Github #86339 [ run ] triggered by Bot. Commit: |
There was a problem hiding this comment.
Thanks for the PR. It restores the kimi_k3_inputs and recurrent_reference helpers that #22247 removed from _kda_reference.py, so the five test_kda_prefill.py cases stop failing with AttributeError on GR100.
Reviewed at commit a47561bad6 (1 file, +51/−1).
Approve: no Blocker found. 2 suggestions below are nice to have.
Nice to have (2): 1 inline, 1 below
-
(N5: Code tidiness)
batch_rowsin the restoredkimi_k3_inputsis never passed by any caller (the only call is test_kda_prefill.py:53), so it brings back an unused input path. (_kda_reference.py:20) -
[Nice to have] (R3: Repository rules) AGENTS.md asks every change to follow CODING_GUIDELINES.md ("Read and follow
CODING_GUIDELINES.mdfor ALL code changes"), and the restored helpers miss two of its Static Typing rules:_kda_reference.py:48def recurrent_reference(q, k, v, g, beta, state, A_log, dt_bias):and_kda_reference.py:24def unit(t):have no annotations. Static Typing 4: "Always annotate functions. Make the return typeNoneif the function does not return anything". Without them the type checker infersAnyfor the eight tensor inputs and for the(o, state)result that test_kda_prefill.py:138 unpacks._kda_reference.py:20returns-> Dict, imported at_kda_reference.py:10. Static Typing 6: "Prefer using the built-in typeslist,dict, andtupleto the legacytyping.List,typing.Dict, andtyping.Tuple."
Suggested fix (and drop
from typing import Dict):def kimi_k3_inputs(...) -> dict[str, torch.Tensor]: ... def unit(t: torch.Tensor) -> torch.Tensor: ... def recurrent_reference( q: torch.Tensor, k: torch.Tensor, v: torch.Tensor, g: torch.Tensor, beta: torch.Tensor, state: torch.Tensor, A_log: torch.Tensor, dt_bias: torch.Tensor, ) -> tuple[torch.Tensor, torch.Tensor]:
What this review checked
- Apart from two docstrings, the restored
kimi_k3_inputsandrecurrent_referenceare byte-identical to the version before #22247. On CPU,recurrent_referencematchesKdaPrefill.reference(k3r_kda_prefill.py:176-200) within the 1e-2 output and 1e-6 state tolerances oftest_reference_is_the_family_recurrence. - At the base,
kr.kimi_k3_inputs(test_kda_prefill.py:53) andkr.recurrent_reference(:138) are the only unresolved helper-module references under tests/unittest/_torch/modeling_v2. At this head all 3,221 resolve, so #22247 left no other test calling a helper it deleted. test_kda_prefill.pyis listed on the GR100 post-merge stage (l0_gr100.yml:155), and its skip gate (kda_prefill.ARCHS= SM103, SM107) admits GR100. No waive or other open PR covers the test or nvbug 7125691.- Not covered: A GPU run: the test needs SM103 or SM107, so the reference comparison ran on CPU.
- Not covered: The author's B300 run (not inspected); pre-merge CI does not run test_kda_prefill.py, which is listed only for GR100 post-merge.
- Not covered: ruff and pyrefly (not installed here); lint relies on the passing Pre-commit Check.
Automated review by trtllm-agent-review. If a point is wrong, reply in its thread. After you push fixes or reply, the bot re-checks the Blockers within a few hours.
|
Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements. |
|
PR_Github #86339 [ run ] completed with state
|
|
/bot skip --comment "tests passed" |
|
PR_Github #86624 [ skip ] triggered by Bot. Commit: |
|
PR_Github #86624 [ skip ] completed with state |
Description
#22247 removed
kimi_k3_inputsandrecurrent_referencefromops/ssm/_kda_reference.py.test_kda_prefill.py(added by #21996) still calls both, so its five cases fail withAttributeErroron GR100 post-merge. This PR restores the two helpers.Test Coverage
unittest/_torch/modeling_v2/models/kimi_k3_vl/ops/ssm/test_kda_prefill.pypasses on B300 (5 cases).PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.Dev Engineer Review
kimi_k3_inputsandrecurrent_referencein the test-only reference module_kda_reference.py. Both were removed by#22247, buttest_kda_prefill.pystill calls them.QA Engineer Review
tests/unittest/_torch/modeling_v2/models/kimi_k3_vl/ops/ssm/_kda_reference.py(modified, +51/-1). It is a helper module, not a test file.test_kda_prefill.py(5 cases). The author reports these pass on B300. GR100 results and CI results: not available.Per-File QA Perspective
_kda_reference.py(test-code helper): adds an fp64 token-by-token KDA prefill reference and its input generator. Verifytest_kda_prefill.pyruns all 5 cases on GR100. Test-list membership: not available.