Skip to content

[https://nvbugs/6437410][fix] fix nemotron weight update test - #16712

Open
shuyixiong wants to merge 4 commits into
NVIDIA:mainfrom
shuyixiong:user/shuyix/fix_nemotron_weight_update
Open

[https://nvbugs/6437410][fix] fix nemotron weight update test#16712
shuyixiong wants to merge 4 commits into
NVIDIA:mainfrom
shuyixiong:user/shuyix/fix_nemotron_weight_update

Conversation

@shuyixiong

@shuyixiong shuyixiong commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Dev Engineer Review

  • Nemotron-H setup now checks required imports directly.
  • The test derives and passes layers_block_type from the checkpoint configuration.
  • The logit comparison threshold now reflects expected numerical differences.
  • Ray CI stages pre-install pinned causal-conv1d and mamba_ssm wheels by architecture.
  • The obsolete part4 waiver was removed.
  • No obvious correctness, API, configuration, or regression issues identified.

QA Engineer Review

Modified test functions:

  • Refactored test_llm_update_weights_nemotron_h.
  • Removed the mamba_deps fixture.
  • Removed _nemotron_h_body.
  • Removed _nemotron_h_subprocess_entry.
  • Updated RefHFModelWithIPCHandles.__init__.

Coverage:

  • tests/integration/test_lists/waives.txt previously waived the Nemotron part4 case. That waiver was removed.
  • The remaining waiver entries are unchanged.
  • The available summary does not provide CBTS execution or coverage results.

Verdict: needs follow-up — test-list coverage is present, but CBTS coverage data is unavailable.

Description

Test Coverage

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-compatible or api-breaking. For api-breaking, include BREAKING in 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.

Signed-off-by: Shuyi Xiong <219646547+shuyixiong@users.noreply.github.com>
Signed-off-by: shuyixiong <219646547+shuyixiong@users.noreply.github.com>
@shuyixiong

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast --stage-list "H100_PCIe-PyTorch-Ray-1, DGX_B200-4_GPUs-PyTorch-Ray-1"

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Changes

Update-weights test coverage

Layer / File(s) Summary
Install Ray test dependencies
jenkins/L0_Test.groovy, jenkins/scripts/slurm_install.sh
Ray-enabled test setup installs pinned, architecture-specific causal_conv1d and mamba_ssm wheels without dependencies.
Update model configuration and Nemotron-H test
tests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.py, tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py, tests/integration/test_lists/waives.txt
The reference model forwards optional configuration values. The Nemotron-H test checks imports, derives layers_block_type, removes subprocess helpers, uses a 0.85 logits threshold, and no longer has the removed part4 waiver.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: schetlur-nv, brnguyen2, qijune, tburt-nv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the template and checklist but omits the issue, solution, and test coverage details. Add a concise explanation of the Nemotron test problem and fix, and list the relevant Ray and unit tests used for validation.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required NVBugs and fix format and clearly identifies the Nemotron weight update test fix.
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 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch user/shuyix/fix_nemotron_weight_update
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py`:
- Around line 796-847: Update test_llm_update_weights_nemotron_h to launch the
pytest command with subprocess.Popen(start_new_session=True), replacing
subprocess.run while preserving its output capture and timeout behavior. In the
subprocess.TimeoutExpired handler, terminate the entire process group with
os.killpg using the child’s process group ID before failing the test, ensuring
Ray/NCCL workers are also stopped.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bf9183ba-ae60-4bd9-9a0e-04b6c54031a4

📥 Commits

Reviewing files that changed from the base of the PR and between 128d020 and 4c17c85.

📒 Files selected for processing (3)
  • tests/integration/test_lists/waives.txt
  • tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py
  • tests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.py
💤 Files with no reviewable changes (1)
  • tests/integration/test_lists/waives.txt

Comment on lines +796 to +847
@pytest.mark.part4
@skip_pre_hopper
def test_llm_update_weights_nemotron_h(mamba_deps):
"""Runs _nemotron_h_body in a spawned subprocess so HF transformers
sees the mamba-ssm / causal-conv1d fast path installed by the
mamba_deps fixture. See _nemotron_h_body docstring for why."""
ctx = multiprocessing.get_context("spawn")
queue = ctx.Queue()
proc = ctx.Process(target=_nemotron_h_subprocess_entry, args=(queue,))
proc.start()
proc.join()
err = queue.get() if not queue.empty() else None
if proc.exitcode != 0:
pytest.fail(f"Subprocess exited with code {proc.exitcode}\n{err or ''}")
if err is not None:
pytest.fail(err)
"""Runs the Nemotron-H body in a fresh ``python -m pytest`` subprocess so
HF transformers re-imports cleanly and picks up the mamba-ssm /
causal-conv1d fast path installed by the ``mamba_deps`` fixture (a plain
in-process run would keep the parent's negative import caches; see the
_nemotron_h_body docstring). Driving it as a subprocess — instead of a
hand-managed ``multiprocessing`` child — lets ``subprocess.run`` and the
inner pytest own the process lifecycle: a hang is bounded by ``timeout=``,
a crash surfaces as a non-zero return code, and the failure detail is the
inner pytest's own traceback."""
# Must stay under the outer pytest ``--timeout`` so a genuine hang (e.g. a
# Ray/NCCL/CUDA deadlock) is reported here with useful output instead of
# the whole test being hard-killed at the pytest timeout.
subprocess_timeout_s = 1800.0

node_id = f"{os.path.abspath(__file__)}::test_nemotron_h_body_impl"
cmd = [
sys.executable,
"-m",
"pytest",
node_id,
"--run-ray",
"-p",
"no:cacheprovider",
"-p",
"no:xdist",
"--tb=short",
"-s",
"-v",
]
env = {**os.environ, _NEMOTRON_H_BODY_ENV: "1"}
try:
result = subprocess.run(
cmd,
env=env,
capture_output=True,
text=True,
timeout=subprocess_timeout_s,
)
except subprocess.TimeoutExpired as e:
out = (e.stdout or "") + (e.stderr or "")
pytest.fail(
f"Nemotron-H subprocess did not complete within "
f"{subprocess_timeout_s:.0f}s (likely hung); terminated.\n{out}"
)
if result.returncode != 0:
pytest.fail(
f"Nemotron-H subprocess failed (exit code {result.returncode}).\n"
f"{result.stdout}\n{result.stderr}"
)

@coderabbitai coderabbitai Bot Jul 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n 'nemotron' tests/integration/test_lists/waives.txt
rg -n 'test_llm_update_weights_nemotron_h|test_nemotron_h_body_impl' tests/integration/test_lists/waives.txt tests/integration/test_lists/test-db tests/integration/test_lists/qa -r ''

Repository: NVIDIA/TensorRT-LLM

Length of output: 1332


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the test file around the affected lines and the inner body helper.
sed -n '720,920p' tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py

printf '\n--- waiver/test-list search ---\n'
rg -n 'test_llm_update_weights_nemotron_h|test_nemotron_h_body_impl|nemotron_h' tests/integration/test_lists tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py || true

printf '\n--- list files mentioning this unittest path ---\n'
rg -n 'unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py|test_llm_update_weights_multi_gpu.py' tests/integration/test_lists || true

Repository: NVIDIA/TensorRT-LLM

Length of output: 8486


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check whether any integration test-list files were modified in this PR.
git diff --name-only -- tests/integration/test_lists

# Show the exact hunks, if any, for the relevant waiver file and test file.
printf '\n--- waives diff ---\n'
git diff -- tests/integration/test_lists/waives.txt || true

printf '\n--- test file diff summary ---\n'
git diff --stat -- tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py

Repository: NVIDIA/TensorRT-LLM

Length of output: 210


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Look for established timeout/process-group patterns in nearby tests.
rg -n 'start_new_session|killpg|TimeoutExpired|subprocess\.run\(' tests/unittest tests/integration | sed -n '1,120p'

Repository: NVIDIA/TensorRT-LLM

Length of output: 12968


Kill the whole Ray subprocess tree on timeout. subprocess.run(..., timeout=...) only stops the direct python -m pytest child; Ray/NCCL workers can survive a hang and keep GPU memory pinned. Launch it with Popen(start_new_session=True) and os.killpg(...) the group in the TimeoutExpired path.

  • Changed tests: test_llm_update_weights_nemotron_h, test_nemotron_h_body_impl.
  • Coverage: test_llm_update_weights_nemotron_h is listed in tests/integration/test_lists/test-db/l0_dgx_b200.yml via -m "part4"; test_nemotron_h_body_impl is intentionally unlisted.
  • Verdict: sufficient.
🧰 Tools
🪛 ast-grep (0.44.1)

[error] 829-835: Command coming from incoming request
Context: subprocess.run(
cmd,
env=env,
capture_output=True,
text=True,
timeout=subprocess_timeout_s,
)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(subprocess-from-request)


[error] 829-835: Use of unsanitized data to create processes
Context: subprocess.run(
cmd,
env=env,
capture_output=True,
text=True,
timeout=subprocess_timeout_s,
)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(os-system-unsanitized-data)

🪛 Ruff (0.15.21)

[error] 830-830: subprocess call: check for execution of untrusted input

(S603)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py`
around lines 796 - 847, Update test_llm_update_weights_nemotron_h to launch the
pytest command with subprocess.Popen(start_new_session=True), replacing
subprocess.run while preserving its output capture and timeout behavior. In the
subprocess.TimeoutExpired handler, terminate the entire process group with
os.killpg using the child’s process group ID before failing the test, ensuring
Ray/NCCL workers are also stopped.

Source: Path instructions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AI is right here, but we should use the utilities already available:

def popen(*popenargs,
start_new_session=True,
suppress_output_info=False,
**kwargs) -> Generator[subprocess.Popen]:

This is also one reason why we should make these integration tests instead of unittests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- existing integration subprocess utility ---'
sed -n '250,300p' tests/integration/defs/trt_test_alternative.py

printf '%s\n' '--- utility usages ---'
rg -n -C 3 'killpg|start_new_session|trt_test_alternative' tests/integration tests/unittest \
  -g '*.py' | sed -n '1,220p'

Length of output: 21468


@tongyuantongyu, confirmed. The helper is the right solution—and stronger than my original killpg() suggestion:

  • tests/integration/defs/trt_test_alternative.py::popen() defaults to start_new_session=True.
  • Its cleanup_process_tree() recursively identifies and terminates descendants, addressing Ray workers that may create separate process groups.
  • It also handles timeout output collection and has cross-platform behavior.

So the appropriate follow-up is to migrate this coverage to the integration framework and use trt_test_alternative there, rather than duplicating subprocess lifecycle logic in this unittest.


✏️ Learnings added
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 16712
File: tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py:796-847
Timestamp: 2026-07-23T10:22:02.769Z
Learning: `tests/integration/defs/trt_test_alternative.py::popen()` and its `cleanup_process_tree()` are the canonical TensorRT-LLM utilities for subprocess-based integration tests. They recursively clean descendant processes because `os.killpg()` alone is insufficient when child processes, including Ray workers, create their own process groups; use these utilities rather than local process-group cleanup implementations.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

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.

It's gone — no process tree to clean.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #60897 [ run ] triggered by Bot. Commit: 4c17c85 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #60897 [ run ] completed with state SUCCESS. Commit: 4c17c85
/LLM/main/L0_MergeRequest_PR pipeline #49165 (Partly Tested) completed with status: 'SUCCESS'

CI Report

Link to invocation

@shikicloud shikicloud 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.

LGTM.


class RefHFModelWithIPCHandles(RefHFModel):
def __init__(self, model_dir: str, device_id: int = 0, num_hidden_layers: int = 4):
def __init__(self, model_dir: str, device_id: int = 0, **model_kwargs):

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.

nit: Collapsing the explicit num_hidden_layers: int = 4 into an untyped**model_kwargsmakes the signature less self-documenting — a reader can no longer tell from the signature which kwargs actually matter, and the type annotation is gone. Since only two keys are ever meaningful, a keyword-only signature keeps the honesty the old code had while still supporting hybrid models:


def __init__(self, model_dir: str, device_id: int = 0, *,
             num_hidden_layers: int | None = None,
             layers_block_type: list[str] | None = None):

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.

Done.

# such models. Catch a silently ignored override loudly here.
num_hidden_layers = model_kwargs.get("num_hidden_layers")
if num_hidden_layers is not None:
assert self.model.config.num_hidden_layers == num_hidden_layers

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.

nit: Add self-explaining forthe failure:

assert self.model.config.num_hidden_layers == num_hidden_layers, (
    f"num_hidden_layers override silently ignored: "
    f"HF loaded {self.model.config.num_hidden_layers}, expected {num_hidden_layers}"
)

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.

Done.

# reference and the mamba SSM / selective-scan path introduces small
# numerical differences (observed top-20 overlap ~0.89 vs the 0.9
# default).
compare_logits(llm_logits, ref_logits, threshold=0.8)

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.

Observed overlap is ~0.89 but the threshold is dropped to 0.8 — could we tighten to 0.85 to keep a comfortable margin over BF16/selective-scan noise while still catching a real regression?

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.

Tightened to 0.85. Correction: ~0.89 is the mean, not the worst. 5 runs x 4 prompts (GB200, TP=4): mean 0.8909, min 0.8672, max 0.9281.

@chzblych chzblych 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.

Approved for the waive list change.

if err is not None:
pytest.fail(err)
"""Runs the Nemotron-H body in a fresh ``python -m pytest`` subprocess so
HF transformers re-imports cleanly and picks up the mamba-ssm /

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we find a sane version that won't mess our environment, put it into https://github.com/NVIDIA/TensorRT-LLM/blob/main/requirements-dev.txt, and remove these subprocess & nested pytest stuffs? If not we'd better make them integration tests. They are too heavy to be unittests in the current shape.

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.

Put them in the Ray-stage install next to ray[default] rather than requirements-dev.txt, as explicit wheel URLs: a requirements file can't pass --no-build-isolation, and a plain version pin means a ~19 min source build per stage since upstream's newest wheels are DLFW 26.04 while our image is 26.05.

Comment on lines +796 to +847
@pytest.mark.part4
@skip_pre_hopper
def test_llm_update_weights_nemotron_h(mamba_deps):
"""Runs _nemotron_h_body in a spawned subprocess so HF transformers
sees the mamba-ssm / causal-conv1d fast path installed by the
mamba_deps fixture. See _nemotron_h_body docstring for why."""
ctx = multiprocessing.get_context("spawn")
queue = ctx.Queue()
proc = ctx.Process(target=_nemotron_h_subprocess_entry, args=(queue,))
proc.start()
proc.join()
err = queue.get() if not queue.empty() else None
if proc.exitcode != 0:
pytest.fail(f"Subprocess exited with code {proc.exitcode}\n{err or ''}")
if err is not None:
pytest.fail(err)
"""Runs the Nemotron-H body in a fresh ``python -m pytest`` subprocess so
HF transformers re-imports cleanly and picks up the mamba-ssm /
causal-conv1d fast path installed by the ``mamba_deps`` fixture (a plain
in-process run would keep the parent's negative import caches; see the
_nemotron_h_body docstring). Driving it as a subprocess — instead of a
hand-managed ``multiprocessing`` child — lets ``subprocess.run`` and the
inner pytest own the process lifecycle: a hang is bounded by ``timeout=``,
a crash surfaces as a non-zero return code, and the failure detail is the
inner pytest's own traceback."""
# Must stay under the outer pytest ``--timeout`` so a genuine hang (e.g. a
# Ray/NCCL/CUDA deadlock) is reported here with useful output instead of
# the whole test being hard-killed at the pytest timeout.
subprocess_timeout_s = 1800.0

node_id = f"{os.path.abspath(__file__)}::test_nemotron_h_body_impl"
cmd = [
sys.executable,
"-m",
"pytest",
node_id,
"--run-ray",
"-p",
"no:cacheprovider",
"-p",
"no:xdist",
"--tb=short",
"-s",
"-v",
]
env = {**os.environ, _NEMOTRON_H_BODY_ENV: "1"}
try:
result = subprocess.run(
cmd,
env=env,
capture_output=True,
text=True,
timeout=subprocess_timeout_s,
)
except subprocess.TimeoutExpired as e:
out = (e.stdout or "") + (e.stderr or "")
pytest.fail(
f"Nemotron-H subprocess did not complete within "
f"{subprocess_timeout_s:.0f}s (likely hung); terminated.\n{out}"
)
if result.returncode != 0:
pytest.fail(
f"Nemotron-H subprocess failed (exit code {result.returncode}).\n"
f"{result.stdout}\n{result.stderr}"
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AI is right here, but we should use the utilities already available:

def popen(*popenargs,
start_new_session=True,
suppress_output_info=False,
**kwargs) -> Generator[subprocess.Popen]:

This is also one reason why we should make these integration tests instead of unittests.

@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 - CONCERNS

Verdict: This test-only fix is mechanically mergeable and the core approach (truncating hybrid NemotronH via layers_block_type instead of the silently-ignored num_hidden_layers) looks correct, but the timeout error path leaks GPU-holding worker processes and should be fixed before merge.

Concerns

  1. [MAJOR] tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py:831 - TimeoutExpired handler leaks the Ray/NCCL process group
    • What is wrong: The subprocess is started with subprocess.run(...) with no new session / process group. On subprocess.TimeoutExpired, only the direct pytest child is terminated; the Ray/NCCL/CUDA workers it forked are orphaned.
    • How it fails: The 1800s timeout exists precisely to catch a Ray/NCCL/CUDA deadlock. When that hang occurs -> TimeoutExpired fires -> pytest.fail(...) is raised, but the worker grandchildren survive and keep holding multi-GPU memory. Subsequent tests on the same node then fail with OOM / device-busy, turning a single hang into a cascade.
    • Suggested fix: launch in its own process group and kill the group on timeout, e.g.
      proc = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE, text=True,
                              start_new_session=True)
      try:
          out, err = proc.communicate(timeout=subprocess_timeout_s)
      except subprocess.TimeoutExpired:
          os.killpg(os.getpgid(proc.pid), signal.SIGKILL)
          out, err = proc.communicate()
          pytest.fail(f"Nemotron-H subprocess hung >{subprocess_timeout_s:.0f}s; killed.\n{out}\n{err}")

Minor notes (non-blocking)

  • tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py:772 - threshold lowered 0.9 -> 0.8 while observed overlap is ~0.89; the ~0.09 slack could mask a real regression. Consider ~0.85.
  • tests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.py:44 - dropping the num_hidden_layers=4 default means any caller that relied on it now loads the full checkpoint. Please confirm no other instantiations depend on the old default.
  • tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py:812 - -p no:xdist can error if pytest-xdist is not installed in the subprocess env.

QA view

  • Test coverage: adequate for a test-only change - it re-enables the previously waived Nemotron-H test; there is no production code to cover. Runtime pass/fail is unverified (CBTS results unavailable per the PR description) and the timeout/leak path is not itself exercised.
  • SM coverage: arch-guarded by @skip_pre_hopper, so it runs on Hopper+ only; the FP8 Nemotron/Qwen case stays waived, so the fp8 variant of this path remains untested. No new arch introduced without a test.
  • Test code: see the MAJOR (process-group leak) plus the loosened threshold and -p no:xdist notes above.
  • Test time: significant - removing the part4 waiver re-enables a 4-GPU weight-update test on a (7-layer-truncated) 30B model with an 1800s budget. Exact runtime can't be read from the diff.
  • Needs /qa-verify: yes - this un-waives a previously failing bug-fix test whose result is unavailable, changes test infrastructure (subprocess-driven pytest + process lifecycle), and has a leaky error path. A human QA should confirm it passes on Hopper+ and leaves no orphaned GPU workers.

Does this actually fix nvbugs/6437410?

Likely yes. The traced failure is that NemotronHConfig derives num_hidden_layers from layers_block_type and silently ignores the direct override, so the old model_kwargs={'num_hidden_layers':7} kept the full 30B model (OOM / unmatched logits). The diff truncates via layers_block_type[:7] on both the HF reference and the LLM, adds an assert to catch the silent-ignore case, loosens the threshold for mamba/selective-scan drift, and re-runs in a fresh python -m pytest subprocess so the mamba-ssm fast path is picked up. That chain addresses the root cause, but it is unverified at runtime.

Possible new issues

  • Leaked Ray/NCCL GPU workers on a hang (MAJOR) can break later tests on the same node.
  • Removed num_hidden_layers=4 default may cause unshown callers to load full checkpoints.
  • The 0.8 threshold reduces sensitivity to future numerical regressions.

What I could not verify

  • The other instantiations of RefHFModelWithIPCHandles (not in the diff) and whether any relied on the old default of 4 layers.
  • Actual test pass/fail and whether the subprocess leaves orphaned processes at runtime - CBTS coverage was not provided.
  • Whether pytest-xdist is guaranteed present in the subprocess environment.

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

… drop nested pytest

Signed-off-by: shikicloud <shikiw@nvidia.com>
@shikicloud
shikicloud requested a review from a team as a code owner August 4, 2026 02:43
@shikicloud
shikicloud requested a review from crazydemo August 4, 2026 02:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
jenkins/L0_Test.groovy (1)

3811-3813: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Verify the integrity of the downloaded native wheels.

These commands install native-code wheels from public GitHub during CI. The release assets publish SHA-256 checksums, but this command does not verify them. Add per-architecture checksum validation or mirror the wheels into controlled Artifactory before installation. (github.com)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@jenkins/L0_Test.groovy` around lines 3811 - 3813, Update the native wheel
installation block to verify SHA-256 checksums for both causal-conv1d and
mamba_ssm assets before pip installation, using the architecture-specific
published checksums for mambaArch. Alternatively, source the wheels from
controlled Artifactory, but do not install directly from the public URLs without
integrity validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@tests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.py`:
- Around line 44-51: Update RefHFModelWithIPCHandles.__init__ to annotate its
return as None and replace Optional[int] with int | None and Optional[List[str]]
with list[str] | None, preserving the existing constructor behavior and
parameters.

---

Nitpick comments:
In `@jenkins/L0_Test.groovy`:
- Around line 3811-3813: Update the native wheel installation block to verify
SHA-256 checksums for both causal-conv1d and mamba_ssm assets before pip
installation, using the architecture-specific published checksums for mambaArch.
Alternatively, source the wheels from controlled Artifactory, but do not install
directly from the public URLs without integrity validation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 21608973-137a-4a75-89a8-c7863f851674

📥 Commits

Reviewing files that changed from the base of the PR and between 4c17c85 and 3705f99.

📒 Files selected for processing (4)
  • jenkins/L0_Test.groovy
  • jenkins/scripts/slurm_install.sh
  • tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py
  • tests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.py

Comment on lines +44 to +51
def __init__(
self,
model_dir: str,
device_id: int = 0,
*,
num_hidden_layers: Optional[int] = None,
layers_block_type: Optional[List[str]] = None,
):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Verify the repository Python target before applying Python 3.10+ syntax.
fd -HI '^(pyproject\.toml|setup\.py|\.python-version|\.tool-versions)$' . -0 |
  xargs -0 -r rg -n 'requires-python|python_requires|target-version|python'

Repository: NVIDIA/TensorRT-LLM

Length of output: 6821


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="tests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.py"

printf '%s\n' '--- repository guidance ---'
if [ -f CODING_GUIDELINES.md ]; then
  cat -n CODING_GUIDELINES.md
else
  printf '%s\n' 'CODING_GUIDELINES.md not found'
fi

printf '%s\n' '--- target file ---'
cat -n "$file"

printf '%s\n' '--- relevant imports and constructor usages ---'
rg -n -C 3 '^(from typing|import typing)|RefHFModelWithIPCHandles|num_hidden_layers|layers_block_type' "$file"

printf '%s\n' '--- changed-file summary ---'
git diff --stat -- "$file"

printf '%s\n' '--- test-list references ---'
rg -n 'test_llm_update_weights|update_weights' tests/integration/test_lists tests 2>/dev/null | head -200

Repository: NVIDIA/TensorRT-LLM

Length of output: 50377


🏁 Script executed:

#!/bin/bash
set -euo pipefail

target="tests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.py"

printf '%s\n' '--- target constructor and nearby code ---'
sed -n '43,95p' "$target"

printf '%s\n' '--- test functions in target ---'
rg -n '^def test_|^async def test_|^class ' "$target"

printf '%s\n' '--- base class definition ---'
rg -n -C 8 'class RefHFModel|def __init__' tests utils tensorrt_llm 2>/dev/null | head -240

printf '%s\n' '--- test-list entries for this module ---'
rg -n -C 3 'test_llm_update_weights|ray_orchestrator.*single_gpu|update_weights' tests/integration/test_lists 2>/dev/null || true

printf '%s\n' '--- typing imports and usages in target ---'
python3 - <<'PY'
from pathlib import Path
import ast

path = Path("tests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.py")
tree = ast.parse(path.read_text())
imports = {}
for node in tree.body:
    if isinstance(node, ast.ImportFrom) and node.module == "typing":
        for alias in node.names:
            imports[alias.asname or alias.name] = alias.name

used = {node.id for node in ast.walk(tree) if isinstance(node, ast.Name)}
for local_name, imported_name in imports.items():
    print(f"{imported_name}: {'used' if local_name in used else 'unused'}")
PY

Repository: NVIDIA/TensorRT-LLM

Length of output: 20284


🏁 Script executed:

#!/bin/bash
set -euo pipefail

target="tests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.py"

printf '%s\n' '--- target diff ---'
git diff --unified=3 -- "$target"

printf '%s\n' '--- base helper candidates ---'
fd -HI -t f 'torch_ref|ref.*model' tests | head -100

printf '%s\n' '--- base helper definitions ---'
rg -n -C 12 'class RefHFModel|def __init__' tests/unittest tests/utils 2>/dev/null | rg -B 12 -A 12 'RefHFModel|torch_ref' | head -240 || true

printf '%s\n' '--- test-list references ---'
if [ -d tests/integration/test_lists ]; then
  rg -n -C 3 'test_llm_update_weights|ray_orchestrator|update_weights' tests/integration/test_lists || true
else
  printf '%s\n' 'tests/integration/test_lists not found'
fi

printf '%s\n' '--- typing import usage in target ---'
python3 - <<'PY'
from pathlib import Path
import ast

path = Path("tests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.py")
tree = ast.parse(path.read_text())
typing_names = {}
for node in tree.body:
    if isinstance(node, ast.ImportFrom) and node.module == "typing":
        for alias in node.names:
            typing_names[alias.asname or alias.name] = alias.name
used = {node.id for node in ast.walk(tree) if isinstance(node, ast.Name)}
for local_name, imported_name in typing_names.items():
    print(f"{imported_name}: {'used' if local_name in used else 'unused'}")
PY

Repository: NVIDIA/TensorRT-LLM

Length of output: 21409


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- target test decorators and calls ---'
sed -n '170,360p' tests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.py

printf '%s\n' '--- cross-file helper and Nemotron-H references ---'
rg -n -C 4 'RefHFModelWithIPCHandles|layers_block_type|num_hidden_layers' \
  tests/unittest/_torch/ray_orchestrator tests/unittest/utils/torch_ref.py

printf '%s\n' '--- exact CI list entries ---'
sed -n '238,255p' tests/integration/test_lists/test-db/l0_h100.yml

Repository: NVIDIA/TensorRT-LLM

Length of output: 40864


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- Nemotron-H test function ---'
sed -n '620,715p' tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py
rg -n -C 2 'test.*nemotron|test_llm_update_weights.*nemotron|multi_gpu' \
  tests/integration/test_lists/test-db tests/integration/test_lists/qa 2>/dev/null || true

Repository: NVIDIA/TensorRT-LLM

Length of output: 50377


Use Python 3.10 type syntax and annotate the constructor return.

RefHFModelWithIPCHandles.__init__ needs a -> None annotation. Replace Optional[int] and Optional[List[str]] with int | None and list[str] | None.

Test coverage summary

  • Changed test functions: none. Changed helper: RefHFModelWithIPCHandles.__init__.
  • Existing consumers include the single-GPU update-weight tests and test_llm_update_weights_nemotron_h.
  • Test lists: l0_h100.yml covers parts 0–2; l0_dgx_b200.yml covers part 4.
  • Verdict: sufficient.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.py`
around lines 44 - 51, Update RefHFModelWithIPCHandles.__init__ to annotate its
return as None and replace Optional[int] with int | None and Optional[List[str]]
with list[str] | None, preserving the existing constructor behavior and
parameters.

Sources: Coding guidelines, Learnings

Signed-off-by: shikicloud <shikiw@nvidia.com>

# Conflicts:
#	tests/unittest/_torch/ray_orchestrator/multi_gpu/test_llm_update_weights_multi_gpu.py
@shikicloud

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast --stage-list "H100_PCIe-PyTorch-Ray-1, DGX_B200-4_GPUs-PyTorch-Ray-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63636 [ run ] triggered by Bot. Commit: fd0b20c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63636 [ run ] completed with state SUCCESS. Commit: fd0b20c
/LLM/main/L0_MergeRequest_PR pipeline #51592 (Partly Tested) completed with status: 'SUCCESS'

CI Report

Link to invocation

@shikicloud

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63692 [ run ] triggered by Bot. Commit: fd0b20c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63692 [ run ] completed with state FAILURE. Commit: fd0b20c
/LLM/main/L0_MergeRequest_PR pipeline #51644 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

@shikicloud

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63919 [ run ] triggered by Bot. Commit: fd0b20c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63919 [ run ] completed with state FAILURE. Commit: fd0b20c
/LLM/main/L0_MergeRequest_PR pipeline #51859 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

@shuyixiong

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63952 [ run ] triggered by Bot. Commit: fd0b20c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63952 [ run ] completed with state FAILURE. Commit: fd0b20c
/LLM/main/L0_MergeRequest_PR pipeline #51892 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

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.

7 participants