From 3c8c74f9f77369167f77754e74a4b8be25721dce Mon Sep 17 00:00:00 2001 From: handongl Date: Tue, 28 Jul 2026 01:20:42 -0700 Subject: [PATCH] [nvbugs/6523880][fix] Restore test_cli_flow legacy scoping and fix mpi_session D205 L0_PostMerge "Release Check" runs pre-commit over all files and failed on three hooks, from two independent regressions. 1. ruff + ruff-format on tests/integration/defs/accuracy/test_cli_flow.py PR #16612 dropped 537 entries from legacy-files.txt while removing legacy python relics. test_cli_flow.py is the only one of those 537 whose file still exists on disk, so dropping its entry deleted nothing -- it silently reclassified the file from Group B (yapf/isort/autoflake formatting plus supplemental ruff-legacy lint) into Group A (full ruff check + ruff format), a style it has never conformed to. That surfaced 4 ruff findings (I001 plus three E501 from the medusa/eagle choice-tree literals) and a whole-file ruff-format rewrite. Restored the legacy-files.txt entry and regenerated the derived configs with `python scripts/legacy_utils.py gen-configs`, which adds the path to ruff-legacy.toml, the managed pyproject.toml block and the managed .pre-commit-config.yaml block. The file is already clean under yapf, isort, autoflake and ruff-legacy, so its classification is consistent again with no formatting churn. 2. ruff-legacy on tensorrt_llm/llmapi/mpi_session.py PR #15908 added an env_overrides paragraph to MpiPoolSession.__init__, whose docstring opens directly with `"""Args:`. That gave the file a second D205 against a ratchet baseline of D205: 1. Rewrote the docstring with a summary line, a blank line and a Google-style Args: block, re-wrapped inside yapf's 80-column limit. The file is back to its baseline counts (D200: 1, D205: 1, D415: 1); the baseline itself is unchanged and no rule is disabled. Signed-off-by: handongl --- .pre-commit-config.yaml | 2 ++ legacy-files.txt | 1 + pyproject.toml | 1 + ruff-legacy.toml | 1 + tensorrt_llm/llmapi/mpi_session.py | 34 +++++++++++++++++------------- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 37c51fbbb377..4f5b84698c22 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -488,6 +488,7 @@ common-files: &common_files | tests/integration/defs/accuracy/accuracy_core.py | tests/integration/defs/accuracy/scripts/collect_evaluated_accuracies.py | tests/integration/defs/accuracy/scripts/compute_theta_and_thresholds.py | + tests/integration/defs/accuracy/test_cli_flow.py | tests/integration/defs/accuracy/test_disaggregated_serving.py | tests/integration/defs/accuracy/test_llm_api_autodeploy.py | tests/integration/defs/accuracy/test_llm_api_pytorch.py | @@ -1258,6 +1259,7 @@ legacy-files: &legacy_files | tests/integration/defs/accuracy/accuracy_core.py | tests/integration/defs/accuracy/scripts/collect_evaluated_accuracies.py | tests/integration/defs/accuracy/scripts/compute_theta_and_thresholds.py | + tests/integration/defs/accuracy/test_cli_flow.py | tests/integration/defs/accuracy/test_disaggregated_serving.py | tests/integration/defs/accuracy/test_llm_api_autodeploy.py | tests/integration/defs/accuracy/test_llm_api_pytorch.py | diff --git a/legacy-files.txt b/legacy-files.txt index 021a4fb301a8..29648dcdbcff 100644 --- a/legacy-files.txt +++ b/legacy-files.txt @@ -480,6 +480,7 @@ tests/integration/defs/accuracy/__init__.py tests/integration/defs/accuracy/accuracy_core.py tests/integration/defs/accuracy/scripts/collect_evaluated_accuracies.py tests/integration/defs/accuracy/scripts/compute_theta_and_thresholds.py +tests/integration/defs/accuracy/test_cli_flow.py tests/integration/defs/accuracy/test_disaggregated_serving.py tests/integration/defs/accuracy/test_llm_api_autodeploy.py tests/integration/defs/accuracy/test_llm_api_pytorch.py diff --git a/pyproject.toml b/pyproject.toml index 2efd23c84d48..6a5d36801339 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -537,6 +537,7 @@ exclude = [ "tests/integration/defs/accuracy/accuracy_core.py", "tests/integration/defs/accuracy/scripts/collect_evaluated_accuracies.py", "tests/integration/defs/accuracy/scripts/compute_theta_and_thresholds.py", + "tests/integration/defs/accuracy/test_cli_flow.py", "tests/integration/defs/accuracy/test_disaggregated_serving.py", "tests/integration/defs/accuracy/test_llm_api_autodeploy.py", "tests/integration/defs/accuracy/test_llm_api_pytorch.py", diff --git a/ruff-legacy.toml b/ruff-legacy.toml index 39a722295b41..7e4897f0c374 100644 --- a/ruff-legacy.toml +++ b/ruff-legacy.toml @@ -497,6 +497,7 @@ include = [ "tests/integration/defs/accuracy/accuracy_core.py", "tests/integration/defs/accuracy/scripts/collect_evaluated_accuracies.py", "tests/integration/defs/accuracy/scripts/compute_theta_and_thresholds.py", + "tests/integration/defs/accuracy/test_cli_flow.py", "tests/integration/defs/accuracy/test_disaggregated_serving.py", "tests/integration/defs/accuracy/test_llm_api_autodeploy.py", "tests/integration/defs/accuracy/test_llm_api_pytorch.py", diff --git a/tensorrt_llm/llmapi/mpi_session.py b/tensorrt_llm/llmapi/mpi_session.py index 8f9264923782..93c863ff7b29 100644 --- a/tensorrt_llm/llmapi/mpi_session.py +++ b/tensorrt_llm/llmapi/mpi_session.py @@ -241,21 +241,25 @@ def __init__(self, n_workers: int, wait_shutdown: bool = False, env_overrides: Optional[Dict[str, str]] = None): - """Args: - n_workers: number of MPI workers to spawn. - wait_shutdown: when True, ``shutdown()`` blocks until the spawned - worker processes have actually exited. ``MPIPoolExecutor.shutdown`` - returns at disconnect, but a worker's GPU memory is only released - when its process exits; callers that start new GPU work right - after ``shutdown()`` (e.g. CI test infrastructure handing a - pre-spawned pool to the next test) race that release and can OOM. - Off by default: production teardown does not need the barrier and - keeps its current latency. - env_overrides: extra environment variables to set in the WORKERS at - spawn, on top of the TRTLLM*/TLLM* variables forwarded from the - parent. The parent process environment is never touched — this - replaces the racy "set os.environ around the spawn, then restore" - pattern for callers that spawn pools from background threads. + """Spawn a pool of MPI worker processes. + + Args: + n_workers: number of MPI workers to spawn. + wait_shutdown: when True, ``shutdown()`` blocks until the spawned + worker processes have actually exited. + ``MPIPoolExecutor.shutdown`` returns at disconnect, but a + worker's GPU memory is only released when its process exits; + callers that start new GPU work right after ``shutdown()`` + (e.g. CI test infrastructure handing a pre-spawned pool to the + next test) race that release and can OOM. Off by default: + production teardown does not need the barrier and keeps its + current latency. + env_overrides: extra environment variables to set in the WORKERS at + spawn, on top of the TRTLLM*/TLLM* variables forwarded from the + parent. The parent process environment is never touched — this + replaces the racy "set os.environ around the spawn, then + restore" pattern for callers that spawn pools from background + threads. """ self.n_workers = n_workers self._wait_shutdown = wait_shutdown