Skip to content

fix(config): align ascend vnpus and mig template with latest hami - #19

Closed
spencercjh wants to merge 2 commits into
Project-HAMi:masterfrom
spencercjh:fix/latest-hami-ascend-config
Closed

spencercjh wants to merge 2 commits into
Project-HAMi:masterfrom
spencercjh:fix/latest-hami-ascend-config

Conversation

@spencercjh

@spencercjh spencercjh commented Jul 6, 2026 •

Copy link
Copy Markdown

Summary

  • Align Ascend vnpus parsing with the latest HAMi wrapped config shape.
  • Align shared MigTemplate / MigTemplateUsage structs with latest HAMi by adding the Core field (from promote dynamic mig #1519).
  • Keep device initialization on config.VNPUs.Configs.
  • Add config tests for latest wrapped format, old flat-shape rejection, and wrapped-config initialization.

Validation

  • go test ./...

Signed-off-by: spencercjh <jiahao.cai@dynamia.ai>
@hami-robot

hami-robot Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Welcome @spencercjh! It looks like this is your first PR to Project-HAMi/mock-device-plugin 🎉

@hami-robot hami-robot Bot added the size/L label Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The device API structs add core-related fields, VNPU config gains a wrapper shape and extra YAML fields, config loading consumes the wrapper, and tests cover wrapped parsing, invalid flat input, and device initialization.

Changes

Device schema updates

Layer / File(s) Summary
MIG template core fields
internal/pkg/api/device/device.go
MigTemplate and MigTemplateUsage each gain a Core field in their serialized shapes.
VNPUConfig and VNPUs type definitions
internal/pkg/api/device/ascend/device.go
VNPUConfig gains ResourceCoreName, RuntimeClassName, and OverwriteEnv; new VNPUs wraps HamiVnpuCore and Configs []VNPUConfig.

VNPUs wrapper config wiring

Layer / File(s) Summary
Config field and InitDevicesWithConfig wiring
internal/pkg/config/config.go
Config.VNPUs changes to ascend.VNPUs, and InitDevicesWithConfig now passes config.VNPUs.Configs into ascend.InitDevices.
Tests for wrapped VNPUs config
internal/pkg/config/config_test.go
Adds a temp-config helper plus tests for wrapped vnpus parsing, flat-shape rejection, and Ascend device initialization from wrapped config.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant LoadConfig
  participant Config
  participant InitDevicesWithConfig
  participant ascend_InitDevices

  LoadConfig->>Config: populate VNPUs (ascend.VNPUs)
  InitDevicesWithConfig->>Config: read config.VNPUs.Configs
  InitDevicesWithConfig->>ascend_InitDevices: InitDevices(config.VNPUs.Configs)
Loading

Poem

I hopped through YAML, neat and small,
Added core fields to the device hall,
Wrapped VNPU configs snug and new,
Then ran some tests to see it through,
A carrot cheer for paths that align! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main changes: aligning Ascend VNPUs and MIG template fields with the latest HAMi config.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@spencercjh

Copy link
Copy Markdown
Author

/assign archlitchi

Align mock-device-plugin's MigTemplate/MigTemplateUsage with upstream HAMi

commit 313c1c0 (promote dynamic mig #1519) added Core to the real struct.

This field was missing because mock's local struct was introduced before that upstream change.

Signed-off-by: spencercjh <jiahao.cai@dynamia.ai>
@hami-robot

hami-robot Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: spencercjh
Once this PR has been reviewed and has the lgtm label, please ask for approval from archlitchi. 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

@spencercjh spencercjh changed the title fix(config): align ascend vnpus with latest hami fix(config): align ascend vnpus and mig template with latest hami Jul 6, 2026
@spencercjh

spencercjh commented Jul 7, 2026 •

Copy link
Copy Markdown
Author

Duplicated with #18

@spencercjh spencercjh closed this Jul 7, 2026
@spencercjh
spencercjh deleted the fix/latest-hami-ascend-config branch July 7, 2026 02:23
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.

2 participants