Skip to content

feat: add hami_host_gpu_memory_controller_utilization_ratio metric - #2615

Closed
manoj-1407 wants to merge 2 commits into
Project-HAMi:masterfrom
manoj-1407:feat/host-gpu-memory-controller-utilization
Closed

feat: add hami_host_gpu_memory_controller_utilization_ratio metric#2615
manoj-1407 wants to merge 2 commits into
Project-HAMi:masterfrom
manoj-1407:feat/host-gpu-memory-controller-utilization

Conversation

@manoj-1407

@manoj-1407 manoj-1407 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Used Claude to help spot the gap, went through the code myself.

What type of PR is this?
/kind feature

What this PR does / why we need it:
GetUtilizationRates() already returns util.Memory alongside util.Gpu
but we were just throwing it away. added it as
hami_host_gpu_memory_controller_utilization_ratio — zero extra NVML
calls since the data was already there. useful for LLM inference
workloads where memory bandwidth saturates before SM does.

Which issue(s) this PR fixes:
Fixes #2613

Special notes for your reviewer:
tiny change — one descriptor, one Describe line, one sendMetric call.

Does this PR introduce a user-facing change?:
yes — hami_host_gpu_memory_controller_utilization_ratio gauge

Summary by CodeRabbit

  • New Features

    • Added a Prometheus metric for host GPU memory-controller utilization.
    • Exposed memory-controller utilization values through GPU monitoring metrics.
  • Bug Fixes

    • Improved error reporting when GPU utilization metrics cannot be created.

GetUtilizationRates() returns both Gpu (SM) and Memory (memory controller)
utilization. hami_host_gpu_utilization_ratio already exports util.Gpu.
util.Memory was fetched but silently discarded.

Add hami_host_gpu_memory_controller_utilization_ratio with identical label
set {device_index, device_uuid, device_type}. SM and memory controller
utilization diverge on memory-bandwidth-bound workloads (LLM inference),
making this metric independently useful for alerting on memory bus saturation.

Signed-off-by: G. Manoj Kumar <manojkumar148700@gmail.com>
Signed-off-by: manoj-1407 <manojkumar148700@gmail.com>
…er utilization metric

- TestDescribeRegistersMemoryControllerUtilization: verifies
  hami_host_gpu_memory_controller_utilization_ratio appears in Describe()
- TestCollectMemoryControllerUtilizationValue: checks the actual gauge
  value emitted via the descriptor, covering the sendMetric call
  flagged by codecov

Signed-off-by: manoj-1407 <manojkumar148700@gmail.com>
@hami-robot

hami-robot Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: manoj-1407
Once this PR has been reviewed and has the lgtm label, please assign archlitchi for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hami-robot hami-robot Bot added the size/M label Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 37b5db10-a282-4047-9056-7b57e6895283

📥 Commits

Reviewing files that changed from the base of the PR and between bb1a9fa and 691c582.

📒 Files selected for processing (2)
  • cmd/vGPUmonitor/metrics.go
  • cmd/vGPUmonitor/metrics_test.go
 ______________________________________________________________
< Security by obscurity? I'm about to become very 'unobscure'. >
 --------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@manoj-1407 manoj-1407 closed this Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Caution

CodeRabbit couldn't update its existing comment. The review summary may be out of date.

Error details
putComment timed out

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cmd/vGPUmonitor/metrics_test.go (1)

82-103: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Exercise the collector path in this test.

This test constructs a metric directly from hostGPUMemoryUtilizationdesc. It does not call ClusterManagerCollector.collectGPUUtilizationMetrics or gather from ClusterManagerCollector. It would pass if production code omitted util.Memory, emitted util.Gpu, or supplied incorrect labels. Drive the collector with a known util.Memory value, then assert the metric name, gauge value, and all three labels.

🤖 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 `@cmd/vGPUmonitor/metrics_test.go` around lines 82 - 103, Update
TestCollectMemoryControllerUtilizationValue to exercise
ClusterManagerCollector.collectGPUUtilizationMetrics or gather from
ClusterManagerCollector using a fixture with a known util.Memory value. Assert
the emitted metric’s name, gauge value, and all three labels, ensuring the
collector maps util.Memory correctly instead of constructing the metric directly
from hostGPUMemoryUtilizationdesc.
🤖 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.

Nitpick comments:
In `@cmd/vGPUmonitor/metrics_test.go`:
- Around line 82-103: Update TestCollectMemoryControllerUtilizationValue to
exercise ClusterManagerCollector.collectGPUUtilizationMetrics or gather from
ClusterManagerCollector using a fixture with a known util.Memory value. Assert
the emitted metric’s name, gauge value, and all three labels, ensuring the
collector maps util.Memory correctly instead of constructing the metric directly
from hostGPUMemoryUtilizationdesc.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 37b5db10-a282-4047-9056-7b57e6895283

📥 Commits

Reviewing files that changed from the base of the PR and between bb1a9fa and 691c582.

📒 Files selected for processing (2)
  • cmd/vGPUmonitor/metrics.go
  • cmd/vGPUmonitor/metrics_test.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: expose gpu memory controller utilization from existing nvml call

1 participant