HAMi on Ascend NPU(整卡)

当 Ascend 工作负载需要独占整卡分配,但仍应使用 HAMi 调度和资源管理时,请使用此场景。对于不使用 HAMi 的直接 Ascend 分配,请使用 直接请求 Ascend NPU 资源。对于硬切或软切,请使用 HAMi on Ascend vNPU

在创建工作负载之前

确认以下内容:

  • 已安装 Alauda Build of HAMi,并启用了 Enable Ascend
  • 已安装 Alauda Build of HAMi Ascend Device Plugin,并选择目标节点,通常为 ascend=on
  • NPU Operator Driver、OCI Runtime 和 ascend RuntimeClass 仍然可用,但该节点池的原生 Ascend Device Plugin 已被禁用。

检查暴露的资源:

kubectl get node <node-name> \
  -o jsonpath='{.status.allocatable}'

节点必须报告型号特定的 Ascend 计数资源。无论节点是否处于部分内存模式,仅使用计数的请求都会选择整卡分配。当工作负载需要硬切或软切时,请使用 HAMi on Ascend vNPU配置 Ascend 切片模式

运行整卡工作负载

下面的 Pod 清单以 Ascend 310P3 为具体示例。该硬件型号通过 HAMi v2.9.0 和 HAMi Ascend Device Plugin v1.4.0 提供的 huawei.com/Ascend310P 资源键暴露。请将镜像替换为包含测试应用所需 CANN 库和 npu-smi 的 ARM64 Ascend 镜像。

apiVersion: v1
kind: Pod
metadata:
  name: hami-ascend310p-whole
spec:
  schedulerName: hami-scheduler
  runtimeClassName: ascend
  restartPolicy: Never
  containers:
    - name: npu-workload
      image: <your-ascend-image>
      command: ["/bin/sh", "-c"]
      args:
        - |
          npu-smi info
          sleep 3600
      resources:
        requests:
          huawei.com/Ascend310P: "1"
        limits:
          huawei.com/Ascend310P: "1"

不要为此整卡请求添加 memory 资源、core 资源或 huawei.com/vnpu-mode 注解。

创建并检查 Pod:

kubectl apply -f hami-ascend310p-whole.yaml
kubectl get pod hami-ascend310p-whole -o wide
kubectl get pod hami-ascend310p-whole \
  -o go-template='scheduler={{ .spec.schedulerName }}{{ "\n" }}runtimeClass={{ .spec.runtimeClassName }}{{ "\n" }}allocation={{ index .metadata.annotations "hami.io/Ascend310P-devices-allocated" }}{{ "\n" }}'
kubectl exec hami-ascend310p-whole -- /bin/sh -c '
  test -z "$ASCEND_VNPU_SPECS" &&
  test -z "$NPU_MEM_QUOTA" &&
  npu-smi info
'

结果解读如下:

  • scheduler=hami-schedulerruntimeClass=ascend 确认了预期的调度与 Ascend 运行时路径。
  • 非空的 hami.io/Ascend310P-devices-allocated 注解确认 HAMi 已分配该设备。
  • 由于请求的是仅计数资源,且不存在 ASCEND_VNPU_SPECSNPU_MEM_QUOTA,因此可确认该工作负载未选择硬切或软切。
  • npu-smi info 成功执行确认了基本设备访问。请运行一个具有代表性的 CANN 或推理工作负载进行端到端验证。

对于 Ascend 910 系列设备,请从 hami-scheduler-device 获取型号映射,确认其在节点 allocatable 资源中的计数资源,并将 huawei.com/Ascend310P 以及分配注解后缀替换为相应值。

下一步