Skip to content

[https://nvbugs/6462303][chore] Unwaive KV cache v2 scheduler tests with executor loop tracing - #17039

Open
yizhang-nv wants to merge 1 commit into
NVIDIA:mainfrom
yizhang-nv:yizhan/unwaive-kv-cache-v2-scheduler-tests
Open

[https://nvbugs/6462303][chore] Unwaive KV cache v2 scheduler tests with executor loop tracing#17039
yizhang-nv wants to merge 1 commit into
NVIDIA:mainfrom
yizhang-nv:yizhan/unwaive-kv-cache-v2-scheduler-tests

Conversation

@yizhang-nv

@yizhang-nv yizhang-nv commented Jul 30, 2026

Copy link
Copy Markdown
Member

Summary

Unwaives the two flaky KV cache v2 scheduler tests and instruments them so the next CI occurrence is actually diagnosable.

Test NVBug Waived symptom
TestKVCacheV2Llama::test_chunked_prefill 6428002 Test timeout / Test terminated unexpectedly (DGX_B200-PyTorch, post-merge)
TestKVCacheV2Llama::test_eviction_with_block_reuse 6462303 Test terminated unexpectedly (DGX_B200-PyTorch, pre-merge)

Both bugs only ever record Test terminated unexpectedly — the pytest session dies with no indication of where, so there is nothing to debug from the CI artifacts.

Why unwaive now

I reran the full l0_b200 pre-merge/pytorch shards containing each test (9-way least_duration split, same pytest command line as jenkins/L0_Test.groovy) 50x each on B200. The target tests passed in every completed iteration — the failure does not reproduce on demand, so waiting for a local repro is not a viable path. Getting a trace out of the next CI occurrence is.

Tracing scope

TLLM_TRACE_EXECUTOR_LOOP=ALL makes trace_func (tensorrt_llm/_utils.py) print every executed line of the PyExecutor event loop, so the last line before the process dies pinpoints the hang.

The trace is expensive, so it is opted into via a fixture on these two tests only — never module- or stage-wide. Verified experimentally by running the traced test alongside three untraced ones in a single session:

  • traced test: 1,917,380 trace lines (~157 MB)
  • everything after it: 22 lines (stdout flush lag from the exiting worker)

monkeypatch restores the environment after the test, and the MPI pool cache independently refuses to reuse a pool whose spawn environment changed ([session-reuse] retiring cached pool: env changed since spawn: ['TLLM_TRACE_EXECUTOR_LOOP']), so the variable cannot leak into a reused worker.

Measured overhead on the traced test: ~32s -> ~40s.

Note the stage log grows by roughly 150 MB per traced test. The tracing is meant to be temporary — it should be removed once either bug is root-caused.

Test Coverage

kv_cache/test_kv_cache_v2_scheduler.py::TestKVCacheV2Llama::test_chunked_prefill, kv_cache/test_kv_cache_v2_scheduler.py::TestKVCacheV2Llama::test_eviction_with_block_reuse

PR Checklist

  • PR title has one of the prefixes [fix], [feat], [doc], [infra], [chore]
  • Test cases are provided for new code paths
  • Any new dependencies have been scanned for license and vulnerabilities
  • CODEOWNERS updated if ownership changes
  • Documentation updated as needed

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added targeted event-loop tracing to KV cache scheduler integration tests.
    • Re-enabled coverage for chunked prefill and block-reuse eviction scenarios by removing their skip entries.
    • Improved diagnostic visibility for investigating intermittent test issues.

…ith executor loop tracing

test_chunked_prefill (nvbugs 6428002) and test_eviction_with_block_reuse
(nvbugs 6462303) are waived as flaky. Both only ever report "Test terminated
unexpectedly" in CI, which gives no indication of where the session died, and
50 full-stage reruns of DGX_B200-PyTorch on current main did not reproduce
either failure locally.

Unwaive both and opt them into TLLM_TRACE_EXECUTOR_LOOP so the next CI
occurrence records exactly where the executor loop stopped. Tracing is applied
through a fixture on these two tests only, since the line trace is expensive
(~1.9M stdout lines / ~157 MB per traced test) -- monkeypatch restores the
environment afterwards, and the MPI pool cache already retires pools whose
spawn environment no longer matches, so no other test in the session is traced.

Signed-off-by: Yi Zhang <187001205+yizhang-nv@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b8b53dc2-bbfd-42cb-9034-1b1a715ae4c2

📥 Commits

Reviewing files that changed from the base of the PR and between d0543dc and 20c74e1.

📒 Files selected for processing (2)
  • tests/integration/defs/kv_cache/test_kv_cache_v2_scheduler.py
  • tests/integration/test_lists/waives.txt
💤 Files with no reviewable changes (1)
  • tests/integration/test_lists/waives.txt

📝 Walkthrough

Walkthrough

Two KV cache scheduler integration tests now enable executor-loop tracing through a scoped pytest fixture. Their skip entries are removed from the integration waive list.

Changes

KV cache scheduler tracing

Layer / File(s) Summary
Executor-loop tracing fixture
tests/integration/defs/kv_cache/test_kv_cache_v2_scheduler.py
Adds a scoped fixture that sets TLLM_TRACE_EXECUTOR_LOOP=ALL for a test and restores the environment afterward.
Traced scheduler test activation
tests/integration/defs/kv_cache/test_kv_cache_v2_scheduler.py, tests/integration/test_lists/waives.txt
Updates test_chunked_prefill and test_eviction_with_block_reuse to use tracing and removes both tests from the waive list.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: bowenfu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, specific, and matches the main change: unwaiving KV cache v2 scheduler tests with tracing.
Description check ✅ Passed The description includes the issue, rationale, tracing approach, test coverage, and checklist, so it is mostly complete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@yizhang-nv

Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast --stage-list "DGX_B200-PyTorch-1, DGX_B200-PyTorch-8"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62661 [ run ] triggered by Bot. Commit: 20c74e1 Link to invocation

@BowenFu BowenFu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the isolation, since both tests re-enter pre-merge B200 (l0_b200.yml:3-16, lines 165/175): _spawn_snapshot() compares the whole environment minus a short ignore list, so setting and then unsetting TLLM_TRACE_EXECUTOR_LOOP retires the cached MPI pool on both edges — the variable can't reach a neighbouring test, and mpi_session.py forwards TLLM* at spawn so it does reach the worker. Waiver removal is exact-ID; test_chunked_prefill_multi_request and test_chunked_prefill_with_eviction are untouched.

One caveat I'm not blocking on: trace_func uses unflushed print(), so an abrupt kill can lose the final user-space buffer — you'll get essentially all 157 MB but not a guaranteed last line. If the next occurrence lands and the tail is ambiguous, that's why.

Worth stating for whoever picks this up later: this is the diagnostics step Po-Han asked for on both 6428002 and 6462303 ("run 50 times / file a PR to dump more debugging info"), so the tracing is temporary by construction — please do drop it once either bug is root-caused.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62661 [ run ] completed with state FAILURE. Commit: 20c74e1
/LLM/main/L0_MergeRequest_PR pipeline #50801 (Partly Tested) completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@fredricz-20070104 fredricz-20070104 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary - Approve

Reviewed the full diff; no blocking or major issues found.

Minor, non-blocking notes:

  • tests/integration/test_lists/waives.txt: Re-enabling a pre-merge flaky test can block unrelated PRs
  • tests/integration/defs/kv_cache/test_kv_cache_v2_scheduler.py: Tracing is temporary by construction — leave a removal marker

Automated review by NVCortex Lite, run by @fredricz-20070104.

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.

4 participants