원클릭으로
msmodeling-optix-param-recommend
当首次使用 msmodeling optix 的用户需要根据硬件、模型、负载和优化目标推荐 MindIE/vLLM 寻优参数、搜索范围、benchmark 侧字段或 config.toml 片段时使用。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
当首次使用 msmodeling optix 的用户需要根据硬件、模型、负载和优化目标推荐 MindIE/vLLM 寻优参数、搜索范围、benchmark 侧字段或 config.toml 片段时使用。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
当用户需要部署 msmodeling optix 服务化自动寻优工具时使用。负责安装与验证。
指导并自动化完成昇腾 NPU 上 MindSpeed-LLM 训练的 Profiling 数据采集。支持配置并运行带 Profiling 的模型训练,包括 CPU 采集、内存采集、不同采集级别(level0/level1/level2)和自定义 step 范围。生成的 Profiling 数据可用 MindStudio Insight 进行性能分析。当用户需要在模型训练中采集 Profiling 数据、进行训练性能分析、或执行 性能数据采集/Profiling采集 时触发。触发关键词:profiling、性能分析、性能数据采集、Profiling采集、训练框架profiling、MindSpeed-LLM profiling。
指导并自动化完成昇腾 NPU 上 MindSpeed-MM 模型训练的 Profiling 数据采集。通过识别训练脚本,自动找到配置文件并启用内置 Profiler,支持静态采集(指定起止 step)和动态采集(运行时动态开关),支持 Megatron 引擎(tools.json)和独立 FSDP2 引擎(YAML)两种配置方式。生成的 Profiling 数据可用 MindStudio Insight 进行性能分析。当用户需要在多模态模型训练中采集 Profiling 数据、进行训练性能分析、或执行 性能数据采集/Profiling采集 时触发。触发关键词:profiling、性能分析、性能数据采集、Profiling采集、多模态训练profiling、MindSpeed-MM profiling。
Skill for analyzing communication performance bottlenecks and detecting slow/fast rank issues in Ascend NPU systems. Use this skill whenever you need to analyze communication efficiency, data transfer bottlenecks, or identify slow/fast rank problems using profiling data.
用于分析Ascend NPU系统中计算性能瓶颈的技能,专注于算子效率和计算优化
分析MindStudio Insight采集的profiling数据识别快慢卡,以及分析系统trace文件识别Host侧进程性能问题。当用户需要分析NPU卡间性能差异或Host侧进程瓶颈时调用。
| name | msmodeling-optix-param-recommend |
| description | 当首次使用 msmodeling optix 的用户需要根据硬件、模型、负载和优化目标推荐 MindIE/vLLM 寻优参数、搜索范围、benchmark 侧字段或 config.toml 片段时使用。 |
| version | 0.1.0 |
| source | local-session-analysis |
为首次使用 msmodeling optix 的用户推荐保守、可解释的 MindIE / vLLM 寻优参数和初始搜索范围。用户不清楚应该调哪些参数、参数范围如何设置、benchmark 参数如何配置时,使用本 skill。
缺少必需信息时,不要输出最终参数范围。
优先级链:
历史经验(references/historical-configs.md) > 通用启发式规则 > 脚本默认值
references/historical-configs.md,逐条比对用户提供的模型、硬件、负载是否命中已有经验配置。命中时:
historical_exp_id,写入 context JSON 供脚本识别。mindie 或 vllmsingle_card_mem_gb、world_size、num_per_nodes、num_nodesconfig.json 路径,或显式模型结构字段throughput、ttft、tpot 或 balancedreferences/historical-configs.md,如果模型名、量化方式、平台等匹配已有经验条目,将匹配的 historical_exp_id 和关键参数写入 context。skills/msmodeling-optix-param-recommend/scripts/recommend_params.py --context <context.json>。status: need_more_info,只询问返回的 next_question,不要给最终范围。status: ok,再总结推荐结果并附上 TOML 片段。如果用户没有指定 benchmark:vLLM 默认使用 vllm_benchmark(random 数据集免配置);MindIE 默认使用 ais_bench。用户显式指定 ais_bench 时才使用 AISBench。
最小 JSON 结构如下:
{
"engine": "vllm",
"hardware": {
"single_card_mem_gb": 64,
"world_size": 8,
"num_per_nodes": 8,
"num_nodes": 1
},
"model": {
"config_path": "/path/to/model/config.json"
},
"workload": {
"input_len_avg": 1024,
"input_len_max": 4096,
"output_len_avg": 256,
"output_len_max": 512
},
"target": "balanced",
"discovery": {
"enabled": false
},
"historical_exp_id": null,
"historical_note": ""
}
完整输入说明见 references/input-schema.md。
核心并行约束是:
DP * TP * PP == world_size
首次使用时,优先推荐在稳定可行的前提下用满卡:
DP * TP * PP == world_size
脚本会根据模型 config、单卡显存、TP、dtype 和业务负载估算模型权重与 KV cache 容量,然后推荐:
max_batch_size、max_prefill_batch_size、max_prefill_token、排队/调度策略参数、tp、dp、MoE 专家并行参数、ais_bench 压测参数。MAX_NUM_SEQS、MAX_NUM_BATCHED_TOKENS、MAX_MODEL_LEN、TP/PP/DP 参数、GPU_MEMORY_UTILIZATION、BLOCK_SIZE、前缀缓存、分块 prefill、编译配置、vllm_benchmark/ais_bench 压测参数。ENABLE_PREFIX_CACHING 和 ENABLE_CHUNKED_PREFILL 默认交给 vLLM 自身的模型感知默认值,不作为搜索维度,也不写入启动命令。只有用户明确要求覆盖默认行为时,才把对应 flag 放进 vllm.command.others。
详细启发式规则见 references/parameter-rules.md。
在运行推荐脚本之前,先检查 references/historical-configs.md 中是否已有与当前场景匹配的经验配置。
references/historical-configs.md,获取所有已记录的经验条目。config.json 中提取 model_type、num_hidden_layers、hidden_size,或从模型名中匹配已知模式(如 Qwen3.5-27B、DeepSeek-V3 等)。historical_exp_id、推荐值写入 context;不完全匹配但部分相似时,引用经验条目中的公式和约束(如 max-model-len 计算公式)。{
"historical_exp_id": "EXP-001",
"historical_note": "匹配到 Qwen3.5-27B-W8A8 Ascend 经验配置,部分参数采用经验值"
}
| 匹配程度 | 处理方式 |
|---|---|
| 完全匹配 | 直接将经验值写入 context 的固定参数;搜索范围参考经验的 推荐搜索维度。 |
| 部分匹配(同模型族但规模不同) | 按比例调整 TP/显存相关参数;保留公式(如 max-model-len 计算规则)但数值重新计算。 |
| 无匹配 | 使用 recommend_params.py 脚本的通用启发式规则,不做经验覆盖。 |
如果用户提供 vLLM 启动命令,把它当作可运行命令骨架,不要当作完整搜索空间。可以执行只读帮助命令:
vllm serve --help
vllm bench serve --help
第一版只把发现到的额外参数作为可选候选。对 MindIE,优先读取 config.json,不要依赖命令行帮助。
如需启用可选发现功能,先执行只读 help 命令,将输出写入 context:
{
"discovery": {
"enabled": true,
"vllm_help_text_path": "/tmp/vllm-serve-help.txt"
}
}
脚本会根据模型和负载决定是否追加 MAX_NUM_PARTIAL_PREFILLS、LONG_PREFILL_TOKEN_THRESHOLD、DISABLE_CHUNKED_MM_INPUT、ENABLE_EXPERT_PARALLEL 等候选。result.discovery.added_parameters 会列出本轮由 help 发现追加的字段。
vLLM 的 presence flag 参数分两类处理:ENABLE_PREFIX_CACHING 和 ENABLE_CHUNKED_PREFILL 使用 vLLM 默认值,不写入命令;COMPILATION_CONFIG 这类需要搜索的字符串枚举才用 $COMPILATION_CONFIG 占位符接入 vllm.command.others。
脚本返回 status: ok 时,输出:
toml_snippet 中的 config.toml 片段。config_skill_handoff:供 auto_config.py 使用的机器可读交接对象。DP * TP * PP == world_size 约束解释。next_command 中的下一步命令。不要静默应用 TOML 片段。修改现有 config.toml 前必须征得用户同意。
推荐完成后,使用 auto_config.py 将结果写入 config.toml。该脚本支持场景模板、参数增改、服务/测评工具配置等操作。
docs/zh/user_guide/optix_user_guide.md 在 OptiX 源码目录执行 pip install -e .)optix/config.toml,也可通过 -c 参数指定其他路径)python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --scenario <场景> --engine <引擎> [选项]
| Scenario | n_particles | iters | sample_size | 适用场景 |
|---|---|---|---|---|
quick-test | 5 | 3 | 100000 | 快速验证,小范围 |
standard | 8 | 4 | 100000 | 标准优化,8×4=32 迭代 |
deep-optimize | 30 | 20 | 300000 | 深度搜索,启用 pso_top_k=3-5 |
ttft-priority | 15 | 10 | 150000 | TTFT 优先,高 ttft_penalty |
tpot-priority | 15 | 10 | 150000 | TPOT 优先,高 tpot_penalty |
throughput | 10 | 5 | 100000 | 吞吐优先,低延迟惩罚 |
时间预算自动计算:
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --scenario deep-optimize --time-budget 8h
# 整数参数
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --add-search-param \
--engine vllm --param-name MAX_BATCH_SIZE \
--min 10 --max 400 --dtype int --value 100
# 浮点参数
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --add-search-param \
--engine vllm --param-name GPU_MEMORY_UTILIZATION \
--min 0.8 --max 0.95 --dtype float --value 0.9
# 枚举参数
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --add-search-param \
--engine vllm --param-name TENSOR_PARALLEL_SIZE \
--dtype enum --enum-values "[1,2,4,8,16]" --value 4
# 比例参数
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --add-search-param \
--engine vllm --param-name MAX_PREFILL_RATIO \
--min 0.1 --max 0.7 --dtype ratio --dtype-param max_batch_size --value 0.3
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --add-fixed-param \
--engine vllm --param-name MAX_MODEL_LEN \
--value 16384 --dtype int
| dtype | 含义 | 必填字段 |
|---|---|---|
int | 整数 | min, max |
float | 浮点 | min, max |
bool | 布尔 | value |
str | 字符串 | value |
enum | 枚举 | enum_values |
ratio | 比例(相对于另一参数) | dtype_param |
factories | 工厂(dp = product / tp) | factories_config |
# VLLM 命令配置(自动同步 model/served_name/port 到 vllm_benchmark)
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --set-vllm-command \
--model /path/to/model \
--served-name my-model \
--host 127.0.0.1 \
--port 8000 \
--others "--trust-remote-code"
# AISBench
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --set-ais-bench \
--models /path/to/models.yaml \
--datasets /path/to/datasets.yaml \
--mode perf \
--ais-num-prompts 150
# vllm_benchmark(自动同步 model/served_name/port 到 vllm.command)
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --set-vllm-benchmark \
--model /path/to/model \
--served-name my-model \
--dataset-name random \
--vllm-num-prompts 100 \
--others "--random-input-len 3000 --random-output-len 1000"
注意:
--others必须由用户根据实际业务负载显式指定,不提供默认值。
所有命令支持 --dry-run 预览,不实际写入:
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --scenario standard --engine vllm --dry-run
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --scenario standard --engine vllm && \
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --set-vllm-command --model /data/model --served-name model && \
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --add-search-param --engine vllm --param-name TP --dtype enum --enum-values "[1,2,4,8]" --value 4 && \
python skills/msmodeling-optix-param-recommend/scripts/auto_config.py --set-vllm-benchmark --model /data/model --dataset-name random --others "--random-input-len 3000 --random-output-len 1000"
脚本输出的 config_skill_handoff 包含:
consumer_skill:固定为 msmodeling-optix-param-recommend。target_fields:规范化后的推荐字段,含 section、name、dtype、min、max、value、dtype_param、search 和推荐理由。vllm_command_others:vLLM 需放入 [vllm.command].others 的片段;可搜索参数用 $VAR 占位符。apply_commands:可审阅执行的 auto_config.py 命令清单。notes:当前 CLI 无法直接覆盖的部分(如 ais_bench section)。交接原则:
toml_snippet 用于人工审阅和精确复制。config_skill_handoff.target_fields 用于自动应用。config_skill_handoff.apply_commands 用于命令式衔接。MAX_NUM_BATCHED_TOKENS 和 MAX_NUM_SEQS 已被框架内置占位符,不追加到 others。vllm.command.others——显式传默认值会触发 rank 范围校验错误。仅在 PP > 1 或 DP > 1 时才需显式传参。ENABLE_PREFIX_CACHING、ENABLE_CHUNKED_PREFILL 不写入 target_field 也不写入 command。ais_bench 的 CONCURRENCY、REQUESTRATE 暂只保留在 JSON handoff 中。COMPILATION_CONFIG 必须用 dtype = "enum"optimizer 无法处理 dtype = "str",字符串枚举参数必须用 dtype = "enum":
# ❌ 错误
[[vllm.target_field]]
name = "COMPILATION_CONFIG"
dtype = "str"
value = "{\"cudagraph_mode\": \"FULL_DECODE_ONLY\"}"
# ✅ 正确
[[vllm.target_field]]
name = "COMPILATION_CONFIG"
dtype = "enum"
min = 0
max = 1
dtype_param = ["{\"cudagraph_mode\": \"FULL_DECODE_ONLY\"}"]
value = "{\"cudagraph_mode\": \"FULL_DECODE_ONLY\"}"
$COMPILATION_CONFIG 占位符展开缺少 flag 前缀(已修复)脚本已修正:COMPILATION_CONFIG 现在生成 --compilation-config $COMPILATION_CONFIG(带 flag 前缀)。
若使用固定值,直接在 others 中写 --compilation-config '<json>' 更加稳妥。
others 遗漏 --max-model-len 导致 OOMvLLM 回退到 max_position_embeddings(如 262144),远超显存容量。确保 others 中包含 --max-model-len $MAX_MODEL_LEN。
--data-parallel-size / --pipeline-parallel-size 触发 rank 校验DP=1 和 PP=1 不应写入 vllm.command.others,仅在 DP > 1 或 PP > 1 时显式传参。
MAX_MODEL_LEN 而缩短 benchmark 长度benchmark 的 I/O 长度必须反映实际业务负载。正确做法是先尝试 MAX_MODEL_LEN = business_max,启动失败再下调并告知用户上下文限制。
target_field 未设 min/max 导致 optimizer 生成随机大值不需要搜索的固定参数不创建 target_field;必须保留的固定参数设 min == max == value。
$VAR 原样传入MAX_NUM_SEQS、MAX_NUM_BATCHED_TOKENS、CONCURRENCY、REQUESTRATE 由框架自动注入,不可删除,也不应在 others 中重复。
⚠️ 特别强调:vLLM 场景下,
CONCURRENCY和REQUESTRATE必须定义在[[vllm.target_field]]中(不是ais_benchsection)。 框架启动vllm bench serve时会自动注入--max-concurrency $CONCURRENCY和--request-rate $REQUESTRATE, 这两个$VAR只能从[[vllm.target_field]]中解析。如果你把它们放在ais_bench或遗漏掉, vLLM 会报invalid int value: '$CONCURRENCY'。
打印 context 模板:
# 打印 context 模板
python skills/msmodeling-optix-param-recommend/scripts/recommend_params.py --print-template
# 执行推荐
python skills/msmodeling-optix-param-recommend/scripts/recommend_params.py --context /path/to/context.json