How to Define a Whole NPU Cost Model

This procedure registers Ascend whole-NPU allocation and, optionally, project NPU quota as billing items. It measures allocated devices, not AI-core, HBM, or runtime utilization.

What this configuration provides

  • Allocation: one assigned NPU device contributes one NPU-hour.
  • Project quota (optional): the project's hard NPU quota can be accumulated as NPU-hours.
  • Model pricing: allocation records retain the NPU model, so different models can have different prices.
  • Project-quota pricing: quota records have no device or model dimension, so use one project-level base price.

1. Create the recording rule

INFO

Where to apply this configuration

Apply this PrometheusRule in the cluster that contains the NPUs and npu-exporter. Before applying it, confirm that the exporter target is healthy and that npu_chip_info_name has vdie_id, name, and namespace labels.

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: alauda-npu-billing-recording
  namespace: kube-system
  labels:
    prometheus: kube-prometheus
spec:
  groups:
    - name: alauda.billing.npu
      interval: 30s
      rules:
        - record: alauda_npu_allocated_count
          expr: |
            count by (UUID, label_modelName, namespace) (
              label_replace(
                label_replace(
                  npu_chip_info_name{namespace!="", namespace!="kube-system"},
                  "UUID", "$1", "vdie_id", "(.+)"
                ),
                "label_modelName", "$1", "name", "(.+)"
              )
            )
        - record: alauda_npu_project_quota_count
          expr: |
            avg by (project, cluster) (
              avg_over_time(
                cpaas_project_resourcequota{
                  resource="requests.huawei.com/Ascend910",
                  type="project-hard"
                }[5m]
              )
            )
WARNING

The requests.huawei.com/Ascend910 value is only an example. Replace it with the exact NPU resource key exposed by the target cluster, including the actual accelerator model or model suffix. Check the resource label of cpaas_project_resourcequota in Prometheus before applying the rule. If the key does not match, the project-quota metric remains empty and no ProjectQuota usage is collected.

The project-quota rule is optional. Remove it when project-quota billing is not required.

Verify the normalized metrics in Prometheus:

alauda_npu_allocated_count
alauda_npu_project_quota_count

Both the exporter target and the required normalized query must be healthy before continuing.

2. Create the collection configuration

INFO

Where to apply this configuration

Apply this ConfigMap in the NPU cluster where the Cost Management Agent runs.

apiVersion: v1
kind: ConfigMap
metadata:
  name: slark-agent-npu-config
  namespace: cpaas-system
  labels:
    cpaas.io/slark.collection.config: "true"
data:
  config: |
    - kind: NPU
      category: NPU
      item: npuAllocationHours
      period: Hourly
      usage:
        query: alauda_npu_allocated_count
        step: 5m
        mappers:
          name: UUID
          namespace: namespace
          cluster: ""
          project: ""
      labels:
        query: alauda_npu_allocated_count
        mappers:
          name: UUID
          namespace: namespace
          cluster: ""
          project: ""
    - kind: Project
      category: NPU
      item: projectNPUQuotaHours
      period: Hourly
      usage:
        query: alauda_npu_project_quota_count
        step: 5m
        mappers:
          name: project
          namespace: ""
          cluster: cluster
          project: project

The label_ prefix is required in the Prometheus label source. Cost Management stores label_modelName as the billing label modelName.

After applying the ConfigMap, reload the Cost Management Agent:

kubectl -n cpaas-system delete pod -l service_name=slark-agent

3. Create the display configuration

INFO

Where to apply this configuration

Apply this ConfigMap in the Global cluster where the Cost Management Server runs.

apiVersion: v1
kind: ConfigMap
metadata:
  name: slark-display-config-for-npu
  namespace: kube-public
  labels:
    cpaas.io/slark.display.config: "true"
data:
  config: |
    - name: NPU
      displayname:
        zh: "整卡 NPU"
        en: "Whole NPU"
      methods:
        - name: Allocation
          displayname: {zh: "分配量", en: "Allocation Usage"}
          item: npuAllocationHours
          divisor: 1
          unit: {zh: "卡时", en: "NPU-hours"}
        - name: ProjectQuota
          displayname: {zh: "项目配额", en: "Project Quota"}
          item: projectNPUQuotaHours
          divisor: 1
          unit: {zh: "卡时", en: "NPU-hours"}

After applying the ConfigMap, reload the Cost Management Server:

kubectl -n cpaas-system delete pod -l service_name=slark-server

4. Add prices to the cost model

In the platform console, open Metering and Billing > Cost Models and create or edit the cost model linked to the NPU cluster.

Billing itemMethodUnitPrice rule
Whole NPUAllocation UsageNPU-hoursDefault price, with optional modelName overrides
Whole NPUProject QuotaNPU-hoursProject-level default price
WARNING

Project Quota is optional and has no NPU model dimension. Do not configure modelName price overrides for this method.

For model-specific allocation prices, use the exact value from the exporter as a modelName label override. The value is case-sensitive.

5. Verify the result

Wait for at least one hourly billing window. Verify the result in this order:

  1. Usage: confirm an NPU usage record exists with the expected cluster, namespace, UUID, and model label.
  2. Bill: confirm a bill is generated and the expected default or model-specific price is applied.
  3. Console: confirm the item and amount appear in cost details and statistics.

For shared deployment rules, see Configuration Conventions.