Skip to content

Get vgpu cores form annotation for overselling#4585

Closed
yuntianfeijing wants to merge 1 commit into
volcano-sh:masterfrom
yuntianfeijing:master
Closed

Get vgpu cores form annotation for overselling#4585
yuntianfeijing wants to merge 1 commit into
volcano-sh:masterfrom
yuntianfeijing:master

Conversation

@yuntianfeijing

Copy link
Copy Markdown

What type of PR is this?

Feature

What this PR does / why we need it:

支持 vgpu core 及 moeory 超卖,从注解中获取 vgpu core 值,并兼容 volcano-vgpu-device-plugin 上报注解未设置 core 的情况。

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

超卖支持,需要先升级 volcano-vgpu-device-plugin
Project-HAMi/volcano-vgpu-device-plugin#79

Does this PR introduce a user-facing change?


@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign hwdef
You can assign the PR to them by writing /assign @hwdef in a comment when ready.

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

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

Summary of Changes

Hello @yuntianfeijing, 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!

此拉取请求引入了对vGPU核心和内存超卖的支持。通过从Pod注解中读取vGPU核心配置,并提供对未指定核心值的兼容性处理,它增强了调度器管理和分配虚拟GPU资源的能力。这一改进使得资源利用更加灵活高效。

Highlights

  • vGPU核心与内存超卖: 此拉取请求引入了对vGPU核心和内存超卖的支持,允许更灵活的资源分配。
  • 从注解获取vGPU核心值: 现在可以从Pod注解中获取vGPU核心值,并兼容volcano-vgpu-device-plugin未设置核心注解的情况,此时默认核心值为100。
  • 动态核心容量检查: 调度逻辑已更新,使用动态的vGPU核心值进行容量检查,而非硬编码的100,从而支持更精细的超卖配置。
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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.

@volcano-sh-bot volcano-sh-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 1, 2025

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

Code Review

This pull request introduces support for vGPU core overselling by allowing the core count to be specified in a node annotation. This is a useful feature that adds more flexibility. The implementation correctly adds a Core field to the GPUDevice struct, parses it from annotations, and uses it in the scheduling logic, replacing a hardcoded value. My feedback focuses on improving the robustness and readability of the annotation parsing logic. I've suggested adding error handling for existing parsing operations and refactoring the new logic for parsing the cores value to make it more explicit and easier to maintain.

Comment thread pkg/scheduler/api/devices/nvidia/vgpu/utils.go Outdated
Comment on lines +74 to +95
offsetForCore := 0
// Check if items[3] is a number for core, otherwise it is the GPU card type
cores, err := strconv.Atoi(items[3])
if err != nil || len(items) < 7 {
// If items[3] is not core number, set default 100, offsetForCore is 0
cores = 100
} else {
// If items[3] is core number, index will add offsetForCore after items[3]
offsetForCore = 1
}

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 logic to parse the optional cores value and maintain backward compatibility is a bit dense and could be hard to maintain. Consider refactoring for improved readability. A more explicit check based on the number of fields would make the intent clearer and the code easier to reason about.

offsetForCore := 0
// The annotation string can be in one of two formats:
// Old: uuid,count,devmem,type,health,sharingMode (6 fields)
// New: uuid,count,devmem,cores,type,health,sharingMode (7 fields)
// This logic handles both for backward compatibility.
cores, err := strconv.Atoi(items[3])
if err == nil && len(items) >= 7 {
	// This is the new format, items[3] is the core value.
	offsetForCore = 1
} else {
	// This is the old format or a malformed new format.
	// `cores` will be set to default, and `err` will be ignored.
	cores = 100
}

Signed-off-by: yuntianfeijing <zhangxl56@lenovo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants