← Back to Pull requests

feat: add ENPU slicing and optional mem-swap allocation #141

Closed
unknown closed this pull request without merging on Sep 28, 2026 05:58 UTC
View on GitHub
unknown unknown commented on Sep 23, 2026 05:42 UTC
Author

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds enpu as an opt-in Ascend backend alongside hami-vnpu-core and hardware vNPU templates. HAMi-selected devices receive per-container vCANN-RT configuration and runtime mounts, with fixed-share, elastic, or best-effort policies.

  • Build runtime assets from official ubs-virt release 1.0.0 in the official ARM64 compiler image, record provenance/checksums, and bundle the assets and upstream license in the device-plugin image.

  • Reserve local virtual IDs on the HAMi-selected physical DIE under a file lock. Persist each reservation in its container config, reuse it on retries/restarts, preserve existing allocations, and reclaim deleted Pods only after both Kubernetes and kubelet release them.

  • Add optional enpu-manager allocation for a mem-swap-capable runtime. Keep the memory request equal to HAMi's reservation, validate manager-returned identities/quotas, and support a separate runtime memory limit.

  • Publish the hami.io/enpu node capability annotation, synchronized with the companion scheduler, while retaining the existing hami-core annotation.

  • Add Helm/node settings, ordinary-slicing and mem-swap examples, and upstream prerequisite links. Preserve existing backends when ENPU is disabled, and bound ENPU virtual-device slots to the runtime's supported range.
  • Which issue(s) this PR fixes:

    Part of #140. Companion HAMi scheduler PR: https://github.com/Project-HAMi/HAMi/pull/3110. Deploy both changes together for ENPU admission, scheduling, and runtime allocation.

    Special notes for your reviewer:

    ENPU is disabled by default. This initially supports one physical DIE per container and retains the Ascend RuntimeClass. A3/910C requires independent-DIE mode; A2/910B is a configuration compatibility target, not an additional hardware-validation claim.

    Official release 1.0.0 provides ordinary slicing only. The manager path is optional preparation for upstream mem-swap and does not change the pinned release build. Automatic manager allocation cleanup on Pod deletion is not implemented in this PR.

    Validation:

  • Device-plugin internal unit tests, CI-style static analysis, chart generation/lint/render/schema checks, and chart release-path verification. The node annotation update also passes internal unit tests, ENPU-specific race tests, and CI-version lint, with registration coverage for all four ENPU/hami-core capability combinations.

  • Prior real-device validation on Ascend910C/A3, driver 26.1.1: official-release runtime packaged in the plugin image, all three ENPU policies with concurrent vLLM workloads; hami-vnpu-core inference and memory-limit rejection; hardware-template allocation, inference, and cleanup.

  • Preview mem-swap validation used prerelease runtime/manager components with diagnostic patches: three Qwen3.6-27B-w8a8 Pods completed ten rotation rounds at a 95% pre-swap watermark. The default 80% watermark reproduced a swap acknowledgement stall. This is not a claim that the upstream preview is production-ready or that unmodified release 1.0.0 supports mem-swap.

  • Final local-slot allocation changes pass full internal unit tests, ENPU-specific race tests, compilation, and CI-version lint. Regression cases cover mismatched kubelet/HAMi IDs with identical suffixes, 100 concurrent slots, independent processes and retries, legacy reservations, capacity exhaustion, and conservative cleanup. The kubelet checkpoint format was verified read-only on the existing test node; the final allocator has not yet been redeployed on NPU hardware.

  • A broad race run also exposed the existing TestNewPluginServer parallel global-map write; it reproduces on the pre-fix source. That unrelated path is unchanged.
  • Does this PR introduce a user-facing change?:

    Yes. Users can explicitly request huawei.com/vnpu-mode: enpu and configure its policy. Mem-swap requires compatible upstream components and additional manager configuration. Existing deployments keep ENPU disabled unless configured otherwise.

    AI Disclosure:

    Codex assisted with implementation, review, tests, documentation, and this PR description.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added optional ENPU (vCANN-RT) runtime slicing for supported Ascend devices, with configurable scheduling policies and compute and memory quotas.
    Added mem-swap support for memory oversubscription, along with deployment settings and workload examples.
    Added Helm configuration for ENPU, including node-level enablement and runtime settings.
    Added ENPU-enabled image builds, runtime asset verification, and checks when installing runtime assets.
    Added persistent ENPU allocation tracking and Prometheus metrics for ENPU device and workload resource usage.
    Documentation
    Added ENPU setup guidance, hardware requirements, configuration and monitoring examples, and English and Chinese usage instructions.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 638 lines (+478 / -160) across 7 files Reviewer: archlitchi Review duration: 7215m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.50) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 638 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.386
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #141"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.4% (MEDIUM) · Higher = larger blast radius
    50.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.8% · Safe to merge
    21.8%