huawei-cloud-ascend-command
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseProvides Huawei Ascend NPU natural language command translation and execution. Supports full npu-smi commands: device queries, configuration management, firmware upgrade, vNPU virtualization, certificate management, and compute power testing.
提供Huawei Ascend NPU自然语言命令的翻译与执行功能。支持完整的npu-smi命令:设备查询、配置管理、固件升级、vNPU虚拟化、证书管理以及算力测试。
Overview
概述
This skill provides natural language management for Huawei Ascend NPU devices via npu-smi commands. Supports both local direct execution and SSH remote modes.
Related Skills:
- - General SSH remote operations (disk, Docker, logs, processes)
huawei-cloud-ascend-remote-connect - - Alternative NPU management implementation
npu-smi-skill - - Model deployment and testing on Ascend DevServer
model-deploy-test-skill
Capabilities:
- Device queries (health, temperature, power, HBM, ECC, topology)
- Configuration management (ECC, fan mode, fan speed)
- Firmware upgrade and status
- vNPU virtualization
- Certificate management
- Compute power testing (FLOPS)
本Skill通过npu-smi命令为Huawei Ascend NPU设备提供自然语言管理功能,支持本地直接执行和SSH远程两种模式。
相关Skill:
- - 通用SSH远程操作(磁盘、Docker、日志、进程)
huawei-cloud-ascend-remote-connect - - NPU管理的替代实现方案
npu-smi-skill - - 在Ascend DevServer上进行模型部署与测试
model-deploy-test-skill
功能特性:
- 设备查询(健康状态、温度、功耗、HBM、ECC、拓扑结构)
- 配置管理(ECC、风扇模式、风扇转速)
- 固件升级与状态查询
- vNPU虚拟化管理
- 证书管理
- 算力测试(FLOPS)
Architecture
架构
System Architecture Diagram
系统架构图
┌─────────────────────────────────────────────────────────────────────┐
│ Agent Orchestration │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ 1. Parse user intent → Match Trigger keywords │ │
│ │ 2. Prepare params → host, user, password explicit │ │
│ │ 3. Invoke Skill → skill exec --name ascend-command │ │
│ │ 4. Return result → User │ │
│ └────────────────────────────┬────────────────────────────────┘ │
│ │ Explicit param passing (Rule 1) │
│ ▼ │
├─────────────────────────────────────────────────────────────────────┤
│ User Interaction Layer │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ Natural Language Commands / CLI Arguments │ │
│ │ (NPU health check, temperature, firmware upgrade) │ │
│ └────────────────────────────┬────────────────────────────────┘ │
│ │ │
│ ▼ │
├─────────────────────────────────────────────────────────────────────┤
│ Skill Core Components (Stateless (Rule 2)) │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Command Executor│←→│ NPU Client │←→│ Trend Recorder │ │
│ │ - NL Parsing │ │ - npu-smi cmd │ │ - Metric Log │ │
│ │ - Command Route│ │ - Local/SSH │ │ - Trend Analysis│ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
│ │ │ │
│ ▼ ▼ │
├─────────────────────────────────────────────────────────────────────┤
│ Huawei Cloud Ascend Infrastructure │
│ Data Flow: Agent → Skill(host,user,pwd) → SSH → npu-smi → Response │
└─────────────────────────────────────────────────────────────────────┘┌─────────────────────────────────────────────────────────────────────┐
│ Agent Orchestration │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ 1. Parse user intent → Match Trigger keywords │ │
│ │ 2. Prepare params → host, user, password explicit │ │
│ │ 3. Invoke Skill → skill exec --name ascend-command │ │
│ │ 4. Return result → User │ │
│ └────────────────────────────┬────────────────────────────────┘ │
│ │ Explicit param passing (Rule 1) │
│ ▼ │
├─────────────────────────────────────────────────────────────────────┤
│ User Interaction Layer │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ Natural Language Commands / CLI Arguments │ │
│ │ (NPU health check, temperature, firmware upgrade) │ │
│ └────────────────────────────┬────────────────────────────────┘ │
│ │ │
│ ▼ │
├─────────────────────────────────────────────────────────────────────┤
│ Skill Core Components (Stateless (Rule 2)) │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Command Executor│←→│ NPU Client │←→│ Trend Recorder │ │
│ │ - NL Parsing │ │ - npu-smi cmd │ │ - Metric Log │ │
│ │ - Command Route│ │ - Local/SSH │ │ - Trend Analysis│ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
│ │ │ │
│ ▼ ▼ │
├─────────────────────────────────────────────────────────────────────┤
│ Huawei Cloud Ascend Infrastructure │
│ Data Flow: Agent → Skill(host,user,pwd) → SSH → npu-smi → Response │
└─────────────────────────────────────────────────────────────────────┘Agent Orchestration Flow
Agent编排流程
User request: "Query NPU status on 116.204.23.145"
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Agent parses intent │
│ - Keyword "NPU" → Match ascend-command │
│ - IP address → SSH params needed │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Agent prepares params (explicit, Rule 1) │
│ --host 116.204.23.145 │
│ --user root │
│ --password *** │
│ --command "NPU list" │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Skill executes (Stateless, Rule 2) │
│ - NpuClient(host, user, password) explicit receive │
│ - Execute npu-smi command │
│ - Return result │
└─────────────────────────────────────────────────────────────┘
│
▼
Return to userUser request: "Query NPU status on 116.204.23.145"
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Agent解析用户意图 │
│ - 关键词"NPU" → 匹配ascend-command │
│ - IP地址 → 需要SSH参数 │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Agent准备参数(显式传递,规则1) │
│ --host 116.204.23.145 │
│ --user root │
│ --password *** │
│ --command "NPU list" │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Skill执行(无状态,规则2) │
│ - NpuClient(host, user, password) 显式接收参数 │
│ - 执行npu-smi命令 │
│ - 返回结果 │
└─────────────────────────────────────────────────────────────┘
│
▼
返回给用户Related Skills (Agent orchestrated, no direct call, Rule 3)
相关Skill(由Agent编排,禁止直接调用,规则3)
| Skill | Purpose | Orchestration Scenario |
|---|---|---|
| SSH remote ops | Agent selects when user needs disk/Docker/logs |
| NPU management | Alternative impl, Agent selects by scenario |
| Model deploy | Use ascend-command to monitor NPU after deploy |
Note: No direct calls between Skills, orchestrated by Agent based on user intent.
| Skill | 用途 | 编排场景 |
|---|---|---|
| SSH远程操作 | 当用户需要磁盘/Docker/日志操作时,由Agent选择调用 |
| NPU管理 | 替代实现方案,Agent根据场景选择调用 |
| 模型部署 | 部署完成后使用ascend-command监控NPU状态 |
注意:Skill之间禁止直接调用,需由Agent根据用户意图进行编排调度。
Prerequisites
前置条件
System Requirements
系统要求
- Python 3.8+
- Pure Python standard library implementation, no additional dependencies required
- Python 3.8+
- 基于纯Python标准库实现,无需额外依赖
Environment Check
环境检查
Prerequisite check: Python3 requiredbashpython3 --version # Python3 >= 3.8
前置检查:需安装Python3bashpython3 --version # Python3 >= 3.8
Authentication
认证
Security rules (must be followed):
- Prohibited from reading, echoing, or printing password values
- Prohibited from asking the user to input passwords directly in the conversation
- Only allowed to read credentials from command line arguments
安全规则(必须遵守):
- 禁止读取、回显或打印密码值
- 禁止在对话中直接要求用户输入密码
- 仅允许从命令行参数中读取凭证
Parameter Confirmation
参数确认
Input Parameters
输入参数
| Parameter | Required | Description |
|---|---|---|
| command | Yes (one-shot) | Natural language command to execute |
| host | No | SSH remote host IP address |
| user | No | SSH username |
| password | No | SSH password |
| 参数 | 是否必填 | 描述 |
|---|---|---|
| command | 是(单次执行模式) | 要执行的自然语言命令 |
| host | 否 | SSH远程主机IP地址 |
| user | 否 | SSH用户名 |
| password | 否 | SSH密码 |
Confirmation Requirements
确认要求
The following operations require explicit user confirmation:
- ECC enable/disable
- Fan mode changes
- Firmware upgrade
- vNPU creation/deletion
- Certificate management
以下操作需要用户显式确认后方可执行:
- ECC启用/禁用
- 风扇模式修改
- 固件升级
- vNPU创建/删除
- 证书管理
Core Workflow
核心工作流
Task 1: One-Shot Command Execution
任务1:单次命令执行
bash
python3 scripts/main.py --command "NPU health check"bash
python3 scripts/main.py --command "NPU health check"Task 2: SSH Remote Execution
任务2:SSH远程执行
bash
python3 scripts/main.py --command "NPU list" --host 192.168.1.100 --user root --password xxxbash
python3 scripts/main.py --command "NPU list" --host 192.168.1.100 --user root --password xxxTask 3: Interactive Mode
任务3:交互模式
bash
python3 scripts/main.pybash
python3 scripts/main.pyUsage Instructions
使用说明
Device Queries
设备查询
List all NPU devices
NPU health check
Get NPU temperature
Get NPU power usage
Get NPU memory info列出所有NPU设备
NPU健康检查
获取NPU温度
获取NPU功耗
获取NPU内存信息Configuration Management
配置管理
Set ECC mode
Set fan mode设置ECC模式
设置风扇模式Firmware Upgrade
固件升级
Query firmware version
Upgrade firmware查询固件版本
升级固件Virtualization
虚拟化管理
Query vNPU info
Create vNPU查询vNPU信息
创建vNPUFLOPS Test
FLOPS测试
Run FLOPS test
Run FP32 FLOPS test
Run multi-device FLOPS test运行FLOPS测试
运行FP32 FLOPS测试
运行多设备FLOPS测试Output Format
输出格式
Standard Response Format
标准响应格式
All command outputs follow a structured format:
json
{
"status": "success",
"command": "npu-smi info -l",
"description": "List all NPU devices"
}所有命令输出均遵循结构化格式:
json
{
"status": "success",
"command": "npu-smi info -l",
"description": "List all NPU devices"
}Error Response Format
错误响应格式
[ERROR] <error-code>
Message: <error-description>
Suggestion: <troubleshooting-tip>[ERROR] <error-code>
Message: <error-description>
Suggestion: <troubleshooting-tip>Verification Method
验证方法
Basic Verification Steps
基础验证步骤
-
Environment Checkbash
python3 --version # Verify Python 3.8+ -
Local Command Testbash
python3 scripts/main.py --command "NPU list" -
Remote Command Testbash
python3 scripts/main.py --host <ascend-ip> --user root --password <pwd> --command "NPU health check"
-
环境检查bash
python3 --version # 验证Python版本 >= 3.8 -
本地命令测试bash
python3 scripts/main.py --command "NPU list" -
远程命令测试bash
python3 scripts/main.py --host <ascend-ip> --user root --password <pwd> --command "NPU health check"
Expected Results
预期结果
| Test Case | Expected Output |
|---|---|
| Environment check | Python version >= 3.8 |
| Local command | NPU device information or "npu-smi not found" |
| Remote command | NPU status from remote server |
| 测试用例 | 预期输出 |
|---|---|
| 环境检查 | Python版本 >= 3.8 |
| 本地命令 | NPU设备信息或"npu-smi not found" |
| 远程命令 | 来自远程服务器的NPU状态信息 |
Script Files
脚本文件
Entry File
入口文件
- main.py: Skill entry file (required)
- Function: Provide interactive mode, one-shot mode, SSH remote mode
- Supports: Command line arguments, interactive prompt
- main.py: Skill入口文件(必填)
- 功能:提供交互模式、单次执行模式、SSH远程模式
- 支持:命令行参数、交互式提示符
Core Scripts
核心脚本
-
executor.py: NPU command executor (main entry)
- Function: Natural language parsing, command routing, sensitive operation confirmation
- Supported commands: Device queries, configuration, firmware upgrade, virtualization, certificate management
- Core methods: ,
handle_command(text)confirm_sensitive()
-
npu_client.py: NPU client
- Function: Wraps npu-smi command execution, supports local and SSH remote execution
- Core methods: ,
list_devices(),get_health(),get_temperature(),get_power(),get_memory(),set_ecc_enable(),upgrade_query(),create_vnpu()get_tls_cert() - Optimization: SSH ControlMaster, batch execution, parallel FLOPS testing
-
executor.py: NPU命令执行器(主入口)
- 功能:自然语言解析、命令路由、敏感操作确认
- 支持命令:设备查询、配置管理、固件升级、虚拟化、证书管理
- 核心方法:,
handle_command(text)confirm_sensitive()
-
npu_client.py: NPU客户端
- 功能:封装npu-smi命令执行,支持本地和SSH远程执行
- 核心方法:,
list_devices(),get_health(),get_temperature(),get_power(),get_memory(),set_ecc_enable(),upgrade_query(),create_vnpu()get_tls_cert() - 优化点:SSH ControlMaster复用、批量执行、并行FLOPS测试
Command Translation Mapping
命令翻译映射
Device Queries
设备查询
| Natural Language | Command | Description |
|---|---|---|
| List all NPU devices | | List all NPU devices |
| NPU card info | | Card and chip mapping |
| NPU info | | Full NPU information |
| 自然语言 | 命令 | 描述 |
|---|---|---|
| 列出所有NPU设备 | | 列出所有NPU设备 |
| NPU卡信息 | | 卡与芯片映射关系 |
| NPU详细信息 | | NPU完整信息 |
Health Check
健康检查
| Natural Language | Command | Description |
|---|---|---|
| NPU health check | | Check device health |
| Check NPU status | | Check device health |
| 自然语言 | 命令 | 描述 |
|---|---|---|
| NPU健康检查 | | 检查设备健康状态 |
| 查看NPU状态 | | 检查设备健康状态 |
Temperature/Power/Memory
温度/功耗/内存
| Natural Language | Command | Description |
|---|---|---|
| NPU temperature | | Get temperature |
| NPU power | | Get power usage |
| NPU memory | | Get memory info |
| NPU utilization | | Get utilization |
| 自然语言 | 命令 | 描述 |
|---|---|---|
| NPU温度 | | 获取温度数据 |
| NPU功耗 | | 获取功耗数据 |
| NPU内存 | | 获取内存信息 |
| NPU使用率 | | 获取使用率数据 |
Configuration
配置管理
| Natural Language | Command | Description |
|---|---|---|
| Set ECC | | Enable ECC (requires confirmation) |
| Set fan mode | | Set fan mode (requires confirmation) |
| 自然语言 | 命令 | 描述 |
|---|---|---|
| 设置ECC | | 启用ECC(需确认) |
| 设置风扇模式 | | 设置风扇模式(需确认) |
Firmware Upgrade
固件升级
| Natural Language | Command | Description |
|---|---|---|
| Firmware version | | Query firmware version |
| Upgrade firmware | | Upload firmware (requires confirmation) |
| 自然语言 | 命令 | 描述 |
|---|---|---|
| 固件版本 | | 查询固件版本 |
| 升级固件 | | 上传固件(需确认) |
Virtualization
虚拟化管理
| Natural Language | Command | Description |
|---|---|---|
| vNPU info | | Query vNPU info |
| Template info | | Query template info |
| Create vNPU | | Create vNPU (requires confirmation) |
| 自然语言 | 命令 | 描述 |
|---|---|---|
| vNPU信息 | | 查询vNPU信息 |
| 模板信息 | | 查询模板信息 |
| 创建vNPU | | 创建vNPU(需确认) |
Certificate Management
证书管理
| Natural Language | Command | Description |
|---|---|---|
| Certificate info | | View TLS certificate |
| Certificate expiration | | Query certificate expiration threshold |
| 自然语言 | 命令 | 描述 |
|---|---|---|
| 证书信息 | | 查看TLS证书 |
| 证书有效期 | | 查询证书过期阈值 |
FLOPS Test (ascend-dmi)
FLOPS测试(ascend-dmi)
Default behavior: single device FP16, fast return (~2 seconds)
| Natural Language | Command | Description |
|---|---|---|
| FLOPS test | | Default: NPU 0, FP16 |
| NPU FLOPS | | Same as above |
| NPU 3 FLOPS | | Specify NPU 3 |
| FP32 FLOPS | | FP32 precision |
| All devices FLOPS | 8 devices async parallel | All NPUs tested simultaneously |
Execution strategy:
- Single device: Direct execution, ~2 seconds return
- Multi-device: Async parallel execution, total ~2 seconds (not serial 16 seconds)
- Precision: Default fp16, supports fp32/bf16/int8/hf32
默认行为:单设备FP16,快速返回(约2秒)
| 自然语言 | 命令 | 描述 |
|---|---|---|
| FLOPS测试 | | 默认:NPU 0,FP16精度 |
| NPU FLOPS测试 | | 同上 |
| NPU 3 FLOPS测试 | | 指定NPU 3 |
| FP32 FLOPS测试 | | FP32精度 |
| 全设备FLOPS测试 | 8设备异步并行 | 同时测试所有NPU |
执行策略:
- 单设备:直接执行,约2秒返回
- 多设备:异步并行执行,总耗时约2秒(非串行16秒)
- 精度:默认fp16,支持fp32/bf16/int8/hf32
Performance Optimization
性能优化
| Optimization | Description | Effect |
|---|---|---|
| SSH persistent connection | ControlMaster reuse | Connection time ~0.1s |
| Batch execution | | Reduce SSH round trips |
| Parallel query | | 16s -> 2s |
| Single parse | | O(N) -> O(1) |
| 优化点 | 描述 | 效果 |
|---|---|---|
| SSH持久连接 | ControlMaster复用 | 连接时间缩短至约0.1秒 |
| 批量执行 | | 减少SSH往返次数 |
| 并行查询 | | 16秒→2秒 |
| 单次解析 | | O(N)→O(1) |
Troubleshooting
故障排查
Command Not Recognized
命令未识别
- Check if input contains supported keywords
- Try using more explicit commands
- 检查输入是否包含支持的关键词
- 尝试使用更明确的命令表述
SSH Connection Failed
SSH连接失败
- Verify SSH parameters are correct
- Ensure SSH service is running on target machine
- 验证SSH参数是否正确
- 确保目标机器上SSH服务已运行
npu-smi Not Available
npu-smi不可用
- Ensure CANN and npu-smi are installed on target machine
- Check LD_LIBRARY_PATH environment variable
- 确保目标机器上已安装CANN和npu-smi
- 检查LD_LIBRARY_PATH环境变量
Notes
注意事项
Security Warnings
安全警告
- Sensitive operations require user confirmation before execution
- Passwords are only stored in memory during session
- Blocked commands cannot be bypassed
- 敏感操作需用户确认后方可执行
- 密码仅在会话期间存储于内存中
- 被禁止的命令无法绕过执行
Limitations
限制
- Requires npu-smi or ascend-dmi installed on target machine
- SSH password authentication only (no interactive password prompt)
- 要求目标机器上已安装npu-smi或ascend-dmi
- 仅支持SSH密码认证(无交互式密码提示)
Best Practices
最佳实践
Best Practices
最佳实践指南
-
Connection Mode Selection
- Local direct: For NPU installed on local machine
- SSH remote: For managing remote Ascend servers
-
Command Execution Tips
- Sensitive ops (firmware upgrade, config change) require user confirmation
- Test on single card before batch operations
-
Performance Monitoring
- Regularly check NPU temperature and power
- Monitor HBM usage to avoid OOM
-
Troubleshooting
- First check NPU health:
npu-smi info - View detailed error log:
npu-smi info -t board -i <npu_id> - See troubleshooting.md
- First check NPU health:
-
Trigger Keywords
- Chinese: NPU, 昇腾, 显存, 算力, 温度, 功耗, 固件, 虚拟化
- English: npu, ascend, temperature, power, HBM, firmware, vNPU, FLOPS
-
连接模式选择
- 本地直连:适用于本地安装了NPU的机器
- SSH远程:适用于管理远程Ascend服务器
-
命令执行技巧
- 敏感操作(固件升级、配置修改)需用户确认
- 批量操作前先在单卡上测试
-
性能监控
- 定期检查NPU温度和功耗
- 监控HBM使用率以避免内存溢出(OOM)
-
故障排查
- 首先检查NPU健康状态:
npu-smi info - 查看详细错误日志:
npu-smi info -t board -i <npu_id> - 参考troubleshooting.md
- 首先检查NPU健康状态:
-
触发关键词
- 中文:NPU、昇腾、显存、算力、温度、功耗、固件、虚拟化
- 英文:npu、ascend、temperature、power、HBM、firmware、vNPU、FLOPS
Directory Structure
目录结构
huawei-cloud-ascend-command/
├── SKILL.md # Skill description (required)
├── scripts/ # Scripts directory (required)
│ ├── __init__.py # Module export
│ ├── main.py # Skill entry file (required)
│ ├── executor.py # NPU command executor
│ └── npu_client.py # NPU client
└── references/ # Reference documentation
├── acceptance-criteria.md # Acceptance criteria
├── verification-method.md # Verification steps
├── troubleshooting.md # Troubleshooting guide
├── device-queries.md # Device queries reference
├── configuration.md # Configuration reference
├── firmware-upgrade.md # Firmware upgrade reference
├── virtualization.md # Virtualization reference
└── certificate-management.md # Certificate managementhuawei-cloud-ascend-command/
├── SKILL.md # Skill描述文档(必填)
├── scripts/ # 脚本目录(必填)
│ ├── __init__.py # 模块导出文件
│ ├── main.py # Skill入口文件(必填)
│ ├── executor.py # NPU命令执行器
│ └── npu_client.py # NPU客户端
└── references/ # 参考文档目录
├── acceptance-criteria.md # 验收标准
├── verification-method.md # 验证步骤
├── troubleshooting.md # 故障排查指南
├── device-queries.md # 设备查询参考
├── configuration.md # 配置管理参考
├── firmware-upgrade.md # 固件升级参考
├── virtualization.md # 虚拟化管理参考
└── certificate-management.md # 证书管理参考References
参考资料
| Document | Description |
|---|---|
| acceptance-criteria.md | Acceptance criteria for skill validation |
| verification-method.md | Verification steps and test methods |
| troubleshooting.md | Troubleshooting guide and common issues |
| device-queries.md | Device queries command reference |
| configuration.md | Configuration management reference |
| firmware-upgrade.md | Firmware upgrade reference |
| virtualization.md | Virtualization management reference |
| certificate-management.md | Certificate management reference |
| 文档 | 描述 |
|---|---|
| acceptance-criteria.md | Skill验证验收标准 |
| verification-method.md | 验证步骤与测试方法 |
| troubleshooting.md | 故障排查指南与常见问题 |
| device-queries.md | 设备查询命令参考 |
| configuration.md | 配置管理参考 |
| firmware-upgrade.md | 固件升级参考 |
| virtualization.md | 虚拟化管理参考 |
| certificate-management.md | 证书管理参考 |
Technical Support
技术支持
- Ascend Official Documentation: https://www.hiascend.com/document
- npu-smi Command Reference: https://www.hiascend.com/document/detail/zh/Atlas%20200I%20A2/260RC1/re/npu/npusmi_007.html