Skip to content

Add verify_gpu_reset test case for GPU reset validation - #4716

Open
SrikanthMyakam (SRIKKANTH) wants to merge 2 commits into
mainfrom
smyakam/newtc_verify_gpu_reset/2026_09_11
Open

SrikanthMyakam (SRIKKANTH) wants to merge 2 commits into
mainfrom
smyakam/newtc_verify_gpu_reset/2026_09_11

Conversation

@SRIKKANTH

@SRIKKANTH SrikanthMyakam (SRIKKANTH) commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Description

Add a new GPU test case that resets all GPUs with 'nvidia-smi -r' several times and checks the guest kernel stays healthy. A CPU soft lockup during GPU reset is timing dependent, so the reset is repeated and dmesg is diffed against a baseline after every iteration to attribute only new kernel errors to the reset. The GPU count from lspci and the driver health are re-checked at the end so a GPU that never comes back on the PCI bus is caught.

nvidia-persistenced, nvidia-fabricmanager and nvidia-dcgm hold /dev/nvidia* open and make the reset fail with "In use by another client", and idle nvidia_uvm/nvidia_drm still count as clients. Stop those services and unload the modules before resetting, then restore the services afterwards without masking the original failure. An unsupported reset path is reported as a skip instead of a failure.

Add NvidiaSmi.reset() which returns the raw result so callers can tell an unsupported reset apart from a real failure.

Related Issue

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Documentation update

Checklist

  • Description is filled in above
  • No credentials, secrets, or internal details are included
  • Peer review requested (if not, add required peer reviewers after raising PR)
  • Tests executed and results posted below

Test Validation

Key Test Cases:

  • verify_gpu_reset

Impacted LISA Features:

  • GPU

Tested Azure Marketplace Images:

  • Canonical ubuntu-24_04-lts server latest

Test Results

Image VM Size Result
Canonical ubuntu-24_04-lts server latest Standard_NC96ads_A100_v4 PASSED

Add a new GPU test case that resets all GPUs with 'nvidia-smi -r' several
times and checks the guest kernel stays healthy. A CPU soft lockup during
GPU reset is timing dependent, so the reset is repeated and dmesg is
diffed against a baseline after every iteration to attribute only new
kernel errors to the reset. The GPU count from lspci and the driver health
are re-checked at the end so a GPU that never comes back on the PCI bus is
caught.

nvidia-persistenced, nvidia-fabricmanager and nvidia-dcgm hold /dev/nvidia*
open and make the reset fail with "In use by another client", and idle
nvidia_uvm/nvidia_drm still count as clients. Stop those services and
unload the modules before resetting, then restore the services afterwards
without masking the original failure. An unsupported reset path is reported
as a skip instead of a failure.

Add NvidiaSmi.reset() which returns the raw result so callers can tell an
unsupported reset apart from a real failure.

Key Test Cases:
verify_gpu_reset|verify_load_gpu_driver

Impacted LISA Features:
Gpu, GpuEnabled

Tested Azure Marketplace Images:
- Canonical ubuntu-24_04-lts server latest

Copilot AI 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.

🟡 Changes recommended

Unresolved cleanup, timeout, baseline, service-restoration, and post-reset validation findings remain.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds NVIDIA GPU reset validation and exposes raw reset results through NvidiaSmi.reset().

Changes:

  • Repeats GPU resets with dmesg and GPU/driver health checks.
  • Releases GPU-holding services/modules before reset and restores services afterward.
  • Adds reset timeout and unsupported-path handling.
File summaries
File Summary and final findings
lisa/tools/gpu_smi.py Adds NVIDIA reset support. Moderate (1 vote): the 2,000-second case timeout does not cover three 900-second resets plus setup and cleanup.
lisa/microsoft/testsuites/gpu/gpusuite.py Adds verify_gpu_reset. Moderate (3 votes): protect holder release with cleanup and preserve partially stopped services. Moderate (3 votes): catch AssertionError during service restoration. Moderate (1 vote): increase the case timeout. Critical (2 votes): force-refresh the post-reset GPU query. Moderate (1 vote): capture the dmesg baseline after holder release.
Review details

Suppressed comments (3)

lisa/microsoft/testsuites/gpu/gpusuite.py:291

  • The case timeout is 2,000 seconds, but each reset is allowed 900 seconds and this loop performs three resets (2,700 seconds) before setup, dmesg checks, and cleanup are included. On a slow multi-GPU SKU, a valid reset can therefore be terminated by the case timeout during the third iteration; increase this case timeout to cover the reset budget plus setup/cleanup.
        timeout=TIMEOUT,

lisa/microsoft/testsuites/gpu/gpusuite.py:315

  • Major: This baseline is captured before _release_gpu_holders() stops services and unloads the NVIDIA modules. If that setup emits a matching kernel error, the first iteration reports it as a reset regression even though the reset did not cause it. Capture the baseline after holder release and immediately before the reset loop, while keeping it inside the cleanup scope.
        baseline_errors = set(
            dmesg.check_kernel_errors(force_run=True, throw_error=False).splitlines()

lisa/tools/gpu_smi.py:36

  • The test method is limited to GpuTestSuite.TIMEOUT = 2000 seconds, but it can run three resets and each NvidiaSmi.reset may wait up to RESET_TIMEOUT = 900 seconds, before accounting for driver setup. Three slow-but-successful resets can therefore exceed the outer case timeout and interrupt the method during reset/cleanup. Increase the case timeout to cover the loop and setup, or derive each reset timeout from the remaining case budget.
    RESET_TIMEOUT = 900
  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

"back on the PCI bus"
).is_equal_to(expected_count)

_check_driver_installed(node, log)
Comment thread lisa/microsoft/testsuites/gpu/gpusuite.py Outdated
Comment thread lisa/microsoft/testsuites/gpu/gpusuite.py
@LiliDeng

Copy link
Copy Markdown
Collaborator

AI Test Case Selection

Selected 6 test case(s): verify_gpu_reset,verify_load_gpu_driver,verify_gpu_extension_installation,verify_gpu_adapter_count,verify_gpu_rescind_validation,verify_gpu_cuda_with_pytorch

Marketplace image: suse sles-15-sp6 gen2 latest

Result: Succeeded

View full logs in Azure DevOps

Copilot AI review requested due to automatic review settings September 11, 2026 16:11

Copilot AI 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.

🟡 Changes recommended

Fix the dmesg duplicate-counting gap and ensure service restoration works across backends and surfaces failures.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Lite

Comment on lines +328 to +331
baseline_errors = set(
dmesg.check_kernel_errors(
force_run=True, throw_error=False
).splitlines()
# start_service asserts on the exit code, so a failed restart
# surfaces as an AssertionError.
try:
service.start_service(name)
Comment on lines +376 to +377
except (LisaException, AssertionError) as identifier:
log.info(f"could not restart '{name}' after reset: {identifier}")
@LiliDeng

Copy link
Copy Markdown
Collaborator

AI Test Case Selection

Selected 6 test case(s): verify_gpu_reset,verify_load_gpu_driver,verify_gpu_extension_installation,verify_gpu_adapter_count,verify_gpu_rescind_validation,verify_gpu_cuda_with_pytorch

Marketplace image: suse sles-15-sp6 gen2 latest

Result: Succeeded

View full logs in Azure DevOps

5. Validate the gpu count is unchanged and the driver is still healthy.
""",
timeout=GPU_RESET_TIMEOUT,
priority=3,

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.

Add maturity="preview",

output = f"{result.stdout}\n{result.stderr}"
if self._gpu_reset_unsupported_pattern.search(output):
raise SkippedException(
f"GPU reset is not available to the guest on this VM "

@LiliDeng LiliDeng Sep 16, 2026

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.

f" is not needed in this line.

raise LisaException(
f"'nvidia-smi -r' failed with exit code {result.exit_code} "
f"on gpu reset iteration {iteration}: {output}. Verify no "
f"process is holding a GPU and that the VM size allows a "

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.

f" is not needed in this line.

f"'nvidia-smi -r' failed with exit code {result.exit_code} "
f"on gpu reset iteration {iteration}: {output}. Verify no "
f"process is holding a GPU and that the VM size allows a "
f"guest initiated reset."

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.

f" is not needed in this line.

- baseline_errors
)
assert_that(sorted(new_errors)).described_as(
f"new kernel errors appeared in dmesg after gpu reset iteration "

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.

f" is not needed in this line.

assert_that(sorted(new_errors)).described_as(
f"new kernel errors appeared in dmesg after gpu reset iteration "
f"{iteration}; resetting a GPU must not hang or destabilize the "
f"guest kernel"

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.

f" is not needed in this line.

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.

3 participants