Skip to content

Add option to disable gpu metrics collection - #65809

Open
pawelbeza wants to merge 1 commit into
ray-project:masterfrom
pawelbeza:pawelbeza/optionally-disable-gpu-metrics-collection
Open

Add option to disable gpu metrics collection#65809
pawelbeza wants to merge 1 commit into
ray-project:masterfrom
pawelbeza:pawelbeza/optionally-disable-gpu-metrics-collection

Conversation

@pawelbeza

Copy link
Copy Markdown

Description

Ray’s dashboard reporter periodically polls NVML for GPU metrics. In some
environments, these calls can contend with other GPU operations and contribute
to kernel lockups or panics.

Reducing the polling frequency only mitigates the problem. Deployments using
external GPU observability need a way to disable NVML polling completely.

Related issues

Fixes #65808

@pawelbeza
pawelbeza requested a review from a team as a code owner August 31, 2026 17:11

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a configuration option to disable GPU metrics collection in the Ray dashboard agent, which helps avoid unnecessary polling of GPU management libraries like NVML. The feedback highlights three key improvements: maintaining backward compatibility in DashboardAgent.__init__ by adjusting the parameter order, optimizing GpuMetricProvider to avoid instantiating GPU providers when metrics are disabled, and defensively accessing gpu_metrics_enabled using getattr to prevent potential AttributeError issues in tests or custom implementations.

Comment on lines 51 to 53
disable_metrics_collection: bool = False,
disable_gpu_metrics: bool = False,
is_head: bool = False,

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.

medium

Adding disable_gpu_metrics before is_head changes the positional argument order of DashboardAgent.__init__. If any callers or tests instantiate DashboardAgent using positional arguments (e.g., passing is_head positionally), this change will silently break backward compatibility by misaligning the arguments.

To maintain backward compatibility, please place disable_gpu_metrics after is_head (right before the * keyword-only argument marker).

Suggested change
disable_metrics_collection: bool = False,
disable_gpu_metrics: bool = False,
is_head: bool = False,
disable_metrics_collection: bool = False,
is_head: bool = False,
disable_gpu_metrics: bool = False,

Comment on lines +529 to 532
def __init__(self, enable_metric_report: bool = True):
self._provider: Optional[GpuProvider] = None
self._enable_metric_report = True
self._enable_metric_report = enable_metric_report
self._providers = [NvidiaGpuProvider(), AmdGpuProvider()]

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.

medium

When enable_metric_report is False, there is no need to instantiate the GPU providers (NvidiaGpuProvider and AmdGpuProvider). Instantiating them unnecessarily consumes memory and could potentially trigger side effects (such as loading driver libraries or executing system queries) during initialization.

We can optimize this by only instantiating the providers when enable_metric_report is True.

Suggested change
def __init__(self, enable_metric_report: bool = True):
self._provider: Optional[GpuProvider] = None
self._enable_metric_report = True
self._enable_metric_report = enable_metric_report
self._providers = [NvidiaGpuProvider(), AmdGpuProvider()]
def __init__(self, enable_metric_report: bool = True):
self._provider: Optional[GpuProvider] = None
self._enable_metric_report = enable_metric_report
self._providers = [NvidiaGpuProvider(), AmdGpuProvider()] if enable_metric_report else []

Comment on lines +581 to +583
self._gpu_metric_provider = GpuMetricProvider(
enable_metric_report=dashboard_agent.gpu_metrics_enabled
)

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.

medium

Directly accessing dashboard_agent.gpu_metrics_enabled can raise an AttributeError if dashboard_agent is a mock object (common in unit tests) or a custom agent implementation that does not define this attribute.

Using getattr with a default value of True is a safer, more defensive approach that prevents potential runtime or test failures.

Suggested change
self._gpu_metric_provider = GpuMetricProvider(
enable_metric_report=dashboard_agent.gpu_metrics_enabled
)
self._gpu_metric_provider = GpuMetricProvider(
enable_metric_report=getattr(dashboard_agent, "gpu_metrics_enabled", True)
)

@ray-gardener ray-gardener Bot added core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Aug 31, 2026
@Kunchd Kunchd self-assigned this Aug 31, 2026
Co-authored-by: Eslam Elnikety <eelnikety@microsoft.com>
Signed-off-by: Eslam Elnikety <eelnikety@microsoft.com>
Signed-off-by: Paweł Bęza <pawelbeza@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pawelbeza
pawelbeza force-pushed the pawelbeza/optionally-disable-gpu-metrics-collection branch from 9470ec7 to 9550497 Compare September 1, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community core Issues that should be addressed in Ray Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an option to disable GPU metric polling

2 participants