Skip to content

Fix gpu_uuid to be physical gpu#614

Merged
myersCody merged 2 commits intomainfrom
gpu_uuid_mig
Mar 17, 2026
Merged

Fix gpu_uuid to be physical gpu#614
myersCody merged 2 commits intomainfrom
gpu_uuid_mig

Conversation

@myersCody
Copy link
Copy Markdown
Contributor

@myersCody myersCody commented Mar 17, 2026

Use parent gpu uuid for gpu_uuid.

uv run nise report ocp --ocp-cluster-id test-mig-cluster --static-report-file tests/ocp_gpu_static_report.yml -w
```

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines how GPU identifiers are generated and managed, particularly for Multi-Instance GPU (MIG) setups. The primary goal is to ensure that the gpu_uuid uniquely identifies the physical GPU, while a distinct mig_instance_id is used for individual MIG partitions. This change improves the clarity and accuracy of GPU resource reporting and management within the system.

Highlights

  • GPU UUID Assignment: Modified the logic for GPU UUID generation to ensure that gpu_uuid consistently represents the physical GPU, especially in configurations involving Multi-Instance GPU (MIG) partitions. Previously, gpu_uuid for MIG instances was derived from the MIG partition itself.
  • MIG Instance ID Handling: Updated the mig_instance_id field to be a string, allowing for more flexible and descriptive identifiers for MIG partitions. The generation now supports direct string input, integer conversion to a 'MIG-' prefixed string, or a UUID-based string if not provided.
  • Test Suite Enhancements: Expanded the test suite to validate the new GPU UUID and MIG instance ID behaviors, including a new test case to explicitly confirm that all MIG slices on a single physical GPU share the same gpu_uuid while maintaining unique mig_instance_ids.
  • Version Update: Incremented the project version from 5.3.9 to 5.4.0 to reflect the new feature and changes.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • nise/init.py
    • Updated the __version__ string from 5.3.9 to 5.4.0.
  • nise/generators/ocp/ocp_generator.py
    • Changed gpu_uuid assignment for MIG instances to use parent_gpu_uuid instead of a MIG-specific UUID.
    • Refactored mig_instance_id generation to handle string, integer, or default UUID-based string values, ensuring it is always a string.
    • Added comments to clarify the distinction between gpu_uuid (physical GPU) and mig_instance_id (MIG partition).
  • tests/test_ocp_generator.py
    • Updated assertions in test_gen_gpus_yaml_with_mig_instances to expect gpu_uuid to start with 'GPU-' and mig_instance_id to be a string starting with 'MIG-'.
    • Renamed test_gen_gpus_raises_when_mig_instance_id_is_not_integer to test_gen_gpus_raises_when_mig_instance_id_invalid_type and updated its logic to check for non-string/non-integer types.
    • Added a new test test_mig_instances_share_same_physical_gpu_uuid to verify shared physical GPU UUIDs and unique MIG instance IDs.
    • Modified assertions in test_gen_hourly_gpu_usage_includes_mig_fields to reflect mig_instance_id as a string and gpu_uuid as a 'GPU-' prefixed string.
    • Updated mig_instance_id in test_update_gpu_data test data from an integer to a string.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

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 correctly updates the GPU generation logic to use a shared physical GPU UUID for all MIG slices of a single GPU, which was the main goal. The handling of mig_instance_id has also been updated to be more flexible. I've provided one suggestion to improve the consistency of mig_instance_id generation to avoid potential confusion based on the input type from YAML. The accompanying test changes are good and a new test has been added to validate the core change, which is great.

Comment thread nise/generators/ocp/ocp_generator.py Outdated
Comment on lines +1670 to +1685
raw_mig_id = mig_spec.get("mig_instance_id")
if raw_mig_id is not None:
if isinstance(raw_mig_id, str):
mig_partition_id = raw_mig_id
elif isinstance(raw_mig_id, int):
mig_partition_id = f"MIG-{raw_mig_id}"
else:
try:
mig_partition_id = f"MIG-{int(raw_mig_id)}"
except (ValueError, TypeError) as exc:
raise ValueError(
f"pod {pod_name}: mig_instance_id must be a string or integer, "
f"got {type(raw_mig_id).__name__}"
) from exc
else:
mig_partition_id = f"MIG-{uuid5(NAMESPACE_DNS, mig_name)}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The current logic for determining mig_partition_id handles integers and string representations of integers inconsistently. For example, a mig_instance_id of 1 (integer) becomes "MIG-1", while "1" (string) is used as-is, resulting in "1". This can lead to unexpected behavior depending on how the value is specified in the input YAML.

The suggested change refactors this logic to be more predictable. It attempts to interpret the mig_instance_id as a number first. If successful, it prefixes the value with "MIG-". If not, it treats it as a string identifier. This ensures that numeric IDs are handled consistently, whether they are provided as integers or strings, while still allowing for arbitrary string-based IDs.

Additionally, it would be beneficial to add test cases to verify this new behavior:

  • A case where mig_instance_id is an integer (e.g., 1).
  • A case where mig_instance_id is a numeric string (e.g., "1").
  • A case where mig_instance_id is a non-numeric string (e.g., "my-partition").

This will ensure the logic is robust and prevent future regressions.

Suggested change
raw_mig_id = mig_spec.get("mig_instance_id")
if raw_mig_id is not None:
if isinstance(raw_mig_id, str):
mig_partition_id = raw_mig_id
elif isinstance(raw_mig_id, int):
mig_partition_id = f"MIG-{raw_mig_id}"
else:
try:
mig_partition_id = f"MIG-{int(raw_mig_id)}"
except (ValueError, TypeError) as exc:
raise ValueError(
f"pod {pod_name}: mig_instance_id must be a string or integer, "
f"got {type(raw_mig_id).__name__}"
) from exc
else:
mig_partition_id = f"MIG-{uuid5(NAMESPACE_DNS, mig_name)}"
raw_mig_id = mig_spec.get("mig_instance_id")
if raw_mig_id is None:
mig_partition_id = f"MIG-{uuid5(NAMESPACE_DNS, mig_name)}"
else:
try:
# Handle integers and string representations of integers consistently.
mig_partition_id = f"MIG-{int(raw_mig_id)}"
except (ValueError, TypeError):
# If it's not numeric, treat it as a string ID if possible.
if isinstance(raw_mig_id, str):
mig_partition_id = raw_mig_id
else:
raise ValueError(
f"pod {pod_name}: mig_instance_id must be a string or integer, "
f"got {type(raw_mig_id).__name__}"
)

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.7%. Comparing base (2f4e57d) to head (5f2f70a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #614   +/-   ##
=====================================
  Coverage   93.6%   93.7%           
=====================================
  Files         56      56           
  Lines       4787    4794    +7     
  Branches     669     672    +3     
=====================================
+ Hits        4483    4490    +7     
  Misses       164     164           
  Partials     140     140           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@myersCody myersCody merged commit 3f26185 into main Mar 17, 2026
7 checks passed
@myersCody myersCody deleted the gpu_uuid_mig branch March 17, 2026 19:35
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.

2 participants