You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[https://nvbugs/7156469][fix] Isolate QSA decode plan-count test setup - #22958
Before this change, test_decode_rows_get_exact_plans used a shared _CORE and assumed its three-row plan survived the subsequent five-row call. However, _PrimsTSSparseCore._workspace_for clears active plans when the workspace grows. On baseline 1aa8a889cf, a fresh-process run grows the workspace from 3584 to 4096 bytes and fails the existing 1 == (1 + 1) assertion.
Give the test a real, per-test sparse core with pytest's restoring monkeypatch fixture, and execute the existing five-row decode before the existing three-row decode. Require exactly one cached plan after the first call and exactly two after the second. Retain the five-row output shape and reference comparison, and compare the three-row output produced after changing row counts against the corresponding reference rows. Both decode argument sets and reference tolerances remain unchanged; no attention implementation, test ID or CI registration changes.
tests/unittest/_torch/attention/sparse/qsa/test_qsa_prims_ts_core.py::test_decode_rows_get_exact_plans requires both distinct decode plans and checks both the initial five-row output and the three-row output after the row-count change.
The complete test_qsa_prims_ts_core.py module covers workspace-growth validation, packed prefill, decode, BF16/FP8 KV and CUDA-graph replay.
The existing GB300 post-merge attention entry continues to select this case; no additional test cases or CI matrix entries are added.
Direct GB300 verification through the repository's test_unittests.py::test_unittests_v2 launcher, with four GPUs visible and the configured SBSA CI image:
Invocation
Baseline 1aa8a889cf
Candidate 8ce8f15b0f
Exact case in a fresh pytest process
Fails 1 == (1 + 1)
Passes in 3 separate processes
Complete module, one process
19 passed
19 passed
Complete module, four xdist workers
19 passed
19 passed
The candidate runs have no failures, errors or skipped leaf cases. A separate diagnostic exact-case run also passes: the five-row call allocates 4096 bytes, then the three-row call requests 3584 bytes without replacing the workspace or discarding the five-row plan. One-time mutation checks confirm that the revised test rejects a missing cached plan for either size and incorrect output after changing row counts. These are direct test runs, not a full CI pipeline result.
PR Checklist
Reviewed the applicable checklist items. This test-only change adds no API, dependency or ownership change; existing regression coverage is retained.
Dev Engineer Review
The test now uses a fresh prims_ts_core._PrimsTSSparseCore(), set through monkeypatch.setattr(prims_ts_core, "_CORE", core). The fixture restores _CORE after the test.
The module-level import from ...qsa import prims_ts_core exists at line 11 of the base file. No new import is needed.
The test asserts absolute plan counts (1, then 2). This holds only while the isolated core starts empty, which the fresh core ensures.
The five-row decode now runs first, followed by the three-row decode. Both outputs are checked against the reference.
No source code changed. The diff touches one test function.
QA Engineer Review
Test files modified: tests/unittest/_torch/attention/sparse/qsa/test_qsa_prims_ts_core.py.
Function: test_decode_rows_get_exact_plans. It now uses an isolated core and runs the five-row decode first.
Checks: one plan after the first call, two after the second, the five-row output against expected, and the three-row output against expected[:3].
Test-list status: test-db/l0_gr100.yml lists only test_auto_gates_small_decode_batches from this module. The diff does not show the exact test ID in a list. The GB300 post-merge entry named in the objectives is not verified here.
Coverage verdict: sufficient for the stated plan-cache regression. Test-list selection needs follow-up.
Per-File QA Perspective
test_qsa_prims_ts_core.py: Isolates the plan-count test from shared core state. Verify it passes in a fresh process and under xdist. Confirm the exact test ID is selected by the intended CI entry.
The decode-row test uses the shared _CORE and executes three rows before
five rows. _PrimsTSSparseCore._workspace_for clears _plans when the
workspace grows, so the increment checked by
test_decode_rows_get_exact_plans can depend on earlier allocations.
Use a fresh sparse core scoped by pytest's monkeypatch fixture and run
the five-row decode first. Require exactly one cached plan after that
call and exactly two after the three-row call. Keep the five-row output
and reference checks, and compare the output after changing row counts
against the corresponding reference rows at the same tolerances in
tests/unittest/_torch/attention/sparse/qsa/test_qsa_prims_ts_core.py.
Before this change, test_decode_rows_get_exact_plans at 1aa8a88 fails
with 1 == (1 + 1) on GB300. The workspace grows from 3584 to 4096 bytes
between its three-row and five-row calls, dropping the three-row plan.
Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
Reviewing files that changed from the base of the PR and between 3d42bbe and 282fc53.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The decode test now uses an isolated _PrimsTSSparseCore instance. It checks plan counts after five-row and three-row calls, and compares the three-row output with the matching reference slice.
Changes
Decode plan test
Layer / File(s)
Summary
Isolated core and decode assertions tests/unittest/_torch/attention/sparse/qsa/test_qsa_prims_ts_core.py
The test uses a fresh core instance, checks that the calls create two plans, and compares the three-row output with the first three reference rows.
This change only makes an existing decode plan-count test more reliable and does not touch production attention code. No merge-blocking risk is identified.
Security architecture risk: Minimal · up to 8ce8f
The change isolates the decode test from shared cache state and adds an output check. It does not change production behavior or expand access.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the NVBugs ID and type [fix], and says the change isolates the QSA decode plan-count test setup. The raw summary and objectives confirm this matches the changeset: the test now uses an…
Description check
The description follows the template's main sections. It explains the problem (shared _CORE and workspace growth clearing plans), the fix (per-test core via monkeypatch, call reordering, plan-count an…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the NVBugs ID and type [fix], and says the change isolates the QSA decode plan-count test setup. The raw summary and objectives confirm this matches the changeset: the test now uses an isolated sparse core, runs the five-row decode first, and checks plan counts. The title is specific and follows the repository format.
Full details: Description check
Explanation
The description follows the template's main sections. It explains the problem (shared _CORE and workspace growth clearing plans), the fix (per-test core via monkeypatch, call reordering, plan-count and reference checks), and the test coverage. It links the NVBugs ID. The PR checklist is marked as reviewed. The template's Description and Test Coverage headings are present and filled in. Minor gaps: the description does not restate the template's API-change label decision, and it does not explicitly address the CODEOWNERS or documentation items beyond stating no ownership change.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
2 points — The fresh core gives the test a known starting state. Running five rows before three avoids the workspace growth that could discard the first plan. Review requires tracing two calls and checking that the sliced inputs correspond to expected[:3].
Affinity (0–1)
0.513 component/tag match
Affinity evidence
Merged authorship 2 × √points; first review 1 × √points; global normalization 0.753606
Outstanding points at selection
7 → 7 (+0)
Points already reserved on this PR
2
Effective weight
0.5
Completed review points (preceding 168 hours)
18
Combined points after assignment
25
Demand-derived target
25.00 points (soft share)
Additional fair share before assignment
0.00 points
Share explanation
Within demand-derived share.
Selection rule
balance-first maintenance
Assignment scope (heyuhhh)
sparse_attention
Affinity and workload are snapshots at selection, not live counters. Existing reservations on this PR are counted once.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. This PR gives test_decode_rows_get_exact_plans its own sparse core and runs the 5-row decode before the 3-row one, so workspace growth no longer drops the cached plan and the test passes in a fresh process; it also checks the 3-row output against the reference.
This is a test-only change. The review read the production workspace-sizing code only to check the test's assumptions.
Approve: no Blocker found. 1 suggestion below is nice to have.
Nice to have (1): 1 inline, 0 below
(N2: Test design and organization) The 5-then-3 call order is what keeps both plans cached, but the test doesn't say so; putting the 3-row call first again fails len(core._plans) == 2 with 1 == 2. (test_qsa_prims_ts_core.py:551)
What this review checked
The plan counts are deterministic on every GPU that runs the test (B200 and B300 pre-merge, GB300 post-merge). In this geometry the split-KV fanout is capped at 1 (tensorrt_llm/_torch/attention/backends/prims_ts/_q_token_kv_block_sparse_policy.py:105-106), so the 3-row workspace (3584 B) never exceeds the 5-row one (4096 B) and _workspace_for keeps both plans.
monkeypatch.setattr(prims_ts_core, "_CORE", core) reaches both calls, because prims_ts_sparse_gqa reads _CORE at call time (tensorrt_llm/_torch/attention/backends/sparse/qsa/prims_ts_core.py:522), and the shared core is restored afterwards. The sibling test_prefill_rows_share_plans_within_bucket is not order-dependent, because its second call hits the same plan key.
The test can still catch a regression. The 3-row and 5-row plan keys differ in route shape and route count (tensorrt_llm/_torch/attention/backends/sparse/qsa/prims_ts_core.py:383-384), so decode plans that are bucketed or shared across row counts fail len(core._plans) == 2. expected[:3] is the matching reference for the sliced inputs.
Not covered: No GPU run: the test was not executed for this review.
Not covered: No pre-merge CI run on the PR yet.
Automated review by trtllm-agent-review. If a point is wrong, reply in its thread. Once you have pushed code changes and replied in every Blocker thread, the bot re-checks the Blockers within a few hours. A Blocker you think should not be fixed needs no code change: reply in its thread with the reason and the evidence.
Explain that the larger decode runs first because workspace growth
clears the active plan cache. Only a comment changes; the decode calls,
plan-count checks and output/reference comparisons stay unchanged.
Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
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
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.
Description
Before this change,
test_decode_rows_get_exact_plansused a shared_COREand assumed its three-row plan survived the subsequent five-row call. However,_PrimsTSSparseCore._workspace_forclears active plans when the workspace grows. On baseline1aa8a889cf, a fresh-process run grows the workspace from 3584 to 4096 bytes and fails the existing1 == (1 + 1)assertion.Give the test a real, per-test sparse core with pytest's restoring
monkeypatchfixture, and execute the existing five-row decode before the existing three-row decode. Require exactly one cached plan after the first call and exactly two after the second. Retain the five-row output shape and reference comparison, and compare the three-row output produced after changing row counts against the corresponding reference rows. Both decode argument sets and reference tolerances remain unchanged; no attention implementation, test ID or CI registration changes.Fixes https://nvbugs/7156469
Test Coverage
tests/unittest/_torch/attention/sparse/qsa/test_qsa_prims_ts_core.py::test_decode_rows_get_exact_plansrequires both distinct decode plans and checks both the initial five-row output and the three-row output after the row-count change.test_qsa_prims_ts_core.pymodule covers workspace-growth validation, packed prefill, decode, BF16/FP8 KV and CUDA-graph replay.Direct GB300 verification through the repository's
test_unittests.py::test_unittests_v2launcher, with four GPUs visible and the configured SBSA CI image:1aa8a889cf8ce8f15b0f1 == (1 + 1)The candidate runs have no failures, errors or skipped leaf cases. A separate diagnostic exact-case run also passes: the five-row call allocates 4096 bytes, then the three-row call requests 3584 bytes without replacing the workspace or discarding the five-row plan. One-time mutation checks confirm that the revised test rejects a missing cached plan for either size and incorrect output after changing row counts. These are direct test runs, not a full CI pipeline result.
PR Checklist
Dev Engineer Review
prims_ts_core._PrimsTSSparseCore(), set throughmonkeypatch.setattr(prims_ts_core, "_CORE", core). The fixture restores_COREafter the test.from ...qsa import prims_ts_coreexists at line 11 of the base file. No new import is needed.QA Engineer Review
Test files modified:
tests/unittest/_torch/attention/sparse/qsa/test_qsa_prims_ts_core.py.test_decode_rows_get_exact_plans. It now uses an isolated core and runs the five-row decode first.expected, and the three-row output againstexpected[:3].test-db/l0_gr100.ymllists onlytest_auto_gates_small_decode_batchesfrom this module. The diff does not show the exact test ID in a list. The GB300 post-merge entry named in the objectives is not verified here.Per-File QA Perspective
test_qsa_prims_ts_core.py: Isolates the plan-count test from shared core state. Verify it passes in a fresh process and under xdist. Confirm the exact test ID is selected by the intended CI entry.