Get vgpu cores form annotation for overselling#4585
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
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
-
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. ↩
There was a problem hiding this comment.
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.
| 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 | ||
| } |
There was a problem hiding this comment.
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>
40158a1 to
d231086
Compare
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?