Repository navigation
[https://nvbugs/6930163][fix] Shut down Inductor compile workers in KV pool rebalance accuracy test #20450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[https://nvbugs/6930163][fix] Shut down Inductor compile workers in KV pool rebalance accuracy test #20450
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,11 @@ | |
| tests/integration/defs/accuracy/test_kv_pool_rebalance_accuracy.py | ||
| """ | ||
|
|
||
| import threading | ||
|
|
||
| import pytest | ||
| import torch._inductor.config as inductor_config | ||
| from torch._inductor.async_compile import shutdown_compile_workers | ||
|
|
||
| from tensorrt_llm import LLM | ||
| from tensorrt_llm.llmapi import KvCacheConfig, SamplingParams | ||
|
|
@@ -59,6 +63,22 @@ def _inject_pool_ratio_mismatch(llm: LLM, *, skew: float = 2.0) -> None: | |
| _introspection.force_rebalance_precondition(kv_cache_manager.impl, skew=skew) | ||
|
|
||
|
|
||
| def _shutdown_inductor_compile_workers() -> None: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This duplicates the shutdown-and-join in |
||
| """Stop Inductor's compile-worker pool and wait for its threads to exit. | ||
|
|
||
| The sampler's logprob fusions are ``torch.compile``d, so the first request | ||
| with ``logprobs`` lazily starts Inductor's process-global compile pool. | ||
| With the PyExecutor in-process, that pool's daemon threads would otherwise | ||
| outlive the test and trip the integration suite's thread-leak check. | ||
| """ | ||
| shutdown_compile_workers() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only covers the SubprocPool threads. |
||
| # The pool's health monitor and quiesce timer only notice the shutdown at | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possible race with the quiesce timer: it checks |
||
| # their next poll; the timer polls every quiesce_async_compile_time / 2. | ||
| for thread in threading.enumerate(): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if thread.name.startswith("InductorSubproc") or thread.name == "subproc_worker_timer": | ||
| thread.join(timeout=inductor_config.quiesce_async_compile_time) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The result of the join is never checked. If a thread is still alive after the timeout, this returns silently and any later leak report has nothing tying it back here. Consider |
||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- # | ||
| # Test | ||
| # --------------------------------------------------------------------------- # | ||
|
|
@@ -232,13 +252,18 @@ def test_rebalance_matches_baseline(self, disable_overlap, monkeypatch): | |
| # can reach .engine on the client side. | ||
| monkeypatch.setenv("TLLM_WORKER_USE_SINGLE_PROCESS", "1") | ||
|
|
||
| baseline = _generate_tokens( | ||
| model_path=self.MODEL_PATH, disable_overlap=disable_overlap, enable_rebalance=False | ||
| ) | ||
| # pytest-threadleak checks before fixture teardown, so the compile pool | ||
| # has to be shut down inside the test body. | ||
| try: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With #20294 merged, this is no longer needed: the threads it shuts down are already in the integration |
||
| baseline = _generate_tokens( | ||
| model_path=self.MODEL_PATH, disable_overlap=disable_overlap, enable_rebalance=False | ||
| ) | ||
|
|
||
| treated = _generate_tokens( | ||
| model_path=self.MODEL_PATH, disable_overlap=disable_overlap, enable_rebalance=True | ||
| ) | ||
| treated = _generate_tokens( | ||
| model_path=self.MODEL_PATH, disable_overlap=disable_overlap, enable_rebalance=True | ||
| ) | ||
| finally: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
| _shutdown_inductor_compile_workers() | ||
|
|
||
| assert len(baseline) == len(treated) == len(_PROMPTS) | ||
| for i, (b, t) in enumerate(zip(baseline, treated)): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| accuracy/test_disaggregated_serving.py::TestQwen3_30B_A3B::test_mixed_ctx_gen_model[ctxpp2gentp2] SKIP (https://nvbugs/5748664) | ||
| accuracy/test_kimi3.py::TestKimiK3DSpark::test_gsm8k_tep8 SKIP (https://nvbugs/6766812) | ||
| accuracy/test_kv_pool_rebalance_accuracy.py::TestKvPoolRebalanceAccuracy::test_rebalance_matches_baseline[no_overlap] SKIP (https://nvbugs/6930163) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part is worth keeping. With #20294 merged, both waivers can come out on their own. |
||
| accuracy/test_kv_pool_rebalance_accuracy.py::TestKvPoolRebalanceAccuracy::test_rebalance_matches_baseline[overlap] SKIP (https://nvbugs/6930163) | ||
| accuracy/test_llm_api_pytorch.py::TestDeepSeekV3Lite::test_bfloat16_4gpus[ep4-mtp_nextn=2-attention_dp=True-cuda_graph=True-overlap_scheduler=True-torch_compile=True] SKIP (https://nvbugs/6402058) | ||
| accuracy/test_llm_api_pytorch.py::TestDeepSeekV3Lite::test_bfloat16_4gpus[tp2pp2-mtp_nextn=2-attention_dp=True-cuda_graph=True-overlap_scheduler=True-torch_compile=True] SKIP (https://nvbugs/6198774) | ||
| accuracy/test_llm_api_pytorch.py::TestDeepSeekV3Lite::test_bfloat16_4gpus[tp4-mtp_nextn=2-attention_dp=True-cuda_graph=True-overlap_scheduler=True-torch_compile=True] SKIP (https://nvbugs/6198774) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module-level imports of private torch internals (
torch._inductor.config,torch._inductor.async_compile.shutdown_compile_workers). If a torch upgrade moves them, collection fails and both parametrizations error out. If the threads are renamed, the join silently does nothing. If kept, import lazily inside the helper.