optimize-musa-training

在摩尔线程 MUSA GPU 上对 AI 训练工作负载进行性能分析、基准测试、调试与优化,同时保持数值行为一致。适用于评估和改进 Torch MUSA、MTT GPU、mthreads-gmi、Moore Perf System (msys)、Moore Perf Compute (mcu)、MFU/HFU、FlashAttention/FA2、SDPA、torch.compile、FSDP/FSDP2、MCCL,以及诊断分布式训练挂起、小批量利用率低、内核启动或数据传输开销、内存压力和从 CUDA 到 MUSA 的性能迁移等场景。

仓库最近推送
GitHub Stars
139
Forks
2
Issues / PRs
0

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "optimize-musa-training":https://skillpi.com/zh/skills/deepskill-23c4142b24efa182e2e5b82197d7f9bd2f4d11df12be025e6eeb79439a6fa9e9。安装前核对上游来源和版本:https://github.com/open-infra-skills/infra-skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

在摩尔线程 MUSA GPU 上对 AI 训练工作负载进行性能分析、基准测试、调试与优化,同时保持数值行为一致。适用于评估和改进 Torch MUSA、MTT GPU、mthreads-gmi、Moore Perf System (msys)、Moore Perf Compute (mcu)、MFU/HFU、FlashAttention/FA2、SDPA、torch.compile、FSDP/FSDP2、MCCL,以及诊断分布式训练挂起、小批量利用率低、内核启动或数据传输开销、内存压力和从 CUDA 到 MUSA 的性能迁移等场景。

0 下载

介绍来源: third_party · open-infra-skills · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: optimize-musa-training
description: Profile, benchmark, debug, and optimize AI training workloads on Moore Threads MUSA GPUs while preserving numerical behavior. Use for Torch MUSA, MTT GPUs, mthreads-gmi, Moore Perf System (msys), Moore Perf Compute (mcu), MFU/HFU, FlashAttention/FA2, SDPA, torch.compile, FSDP/FSDP2, MCCL, distributed hangs, low-batch utilization, kernel launch or transfer overhead, memory pressure, and CUDA-to-MUSA performance migration.

Optimize MUSA Training

Use a measurement-first workflow to improve MUSA training throughput without changing model semantics. Treat framework timing, system traces, and kernel counters as different layers of evidence.

Guardrails

  • Preserve model architecture, data semantics, optimizer math, precision policy, and checkpoint compatibility unless the user explicitly authorizes a change.
  • Establish a versioned baseline before editing code. Compare forward outputs, loss, gradients, memory, and steady-state throughput after every retained change.
  • Keep profiler overhead out of the throughput denominator. Measure FLOPs in a profiled run and steady step time in an otherwise equivalent non-profiled run.
  • Never label profiler-attributed executed FLOPs as model MFU without stating the FLOP definition and coverage. Distinguish useful model FLOPs, executed hardware FLOPs, and profiler-attributed FLOPs.
  • Do not infer MUSA behavior from CUDA behavior. Feature-detect the installed driver, SDK, Torch MUSA, muDNN, muBLAS, MCCL, attention backend, and profiler versions.
  • Keep cluster transport separate from profiling logic. Do not require PowerShell, VS Code, a jump host, a specific scheduler, or a particular client operating system.
  • Keep credentials, internal hostnames, private image registries, dataset paths, and proprietary reports out of public artifacts.

Route The Task

  1. For environment, import, device-selection, or container failures, read environment-and-preflight.md.
  2. For MFU/HFU, PyTorch profiling, timeline analysis, transfers, or kernel counters, read measurement-and-profiling.md.
  3. For FA2, GEMM, compile, launch, memory, dataloader, FSDP, or MCCL optimization, read optimization-playbook.md.
  4. Before retaining any optimization, read correctness-and-experiments.md.
  5. For a real low-batch S5000 case and negative results worth avoiding, read s5000-case-study.md.

Workflow

1. Define The Metric And Invariants

Record:

  • workload, model revision, dataset/sample bucket, precision, sequence shape, batch per device, accumulation, device count, and distributed strategy;
  • useful-model FLOPs, executed FLOPs, or profiler-attributed FLOPs;
  • peak denominator by SKU and precision;
  • model behaviors that must remain unchanged;
  • target metric such as samples/s, tokens/s, MFU, HFU, memory, or time-to-train.

Do not optimize a mixed workload as though every sample has the longest shape. Benchmark each meaningful bucket and the actual weighted mixture.

2. Capture The Environment

Run:

python scripts/musa_env_report.py --output <run-dir>/environment.json

Also save the container image digest, source commit, working-tree diff, launch command, and relevant environment switches. Verify physical device visibility from inside the process rather than trusting shell variables alone.

3. Establish A Steady Baseline

  • Warm up imports, allocator state, compilation, autotuning, dataloader workers, and collectives.
  • Exclude compile steps, epoch boundaries, checkpoint saves, validation, and profiler steps.
  • Capture enough steady steps to expose variance. Reverse A/B order and repeat when the expected gain is below 3%.
  • Keep all ranks on the same shape bucket for a distributed step.

Summarize logs with:

python scripts/summarize_steps.py train.log --skip-first 2 --json

4. Quantify Utilization

For one shape:

python scripts/compute_mfu.py \
  --flops-per-device-step-tflop <F> \
  --step-seconds <T> \
  --peak-tflops-per-device <C> \
  --flops-kind profiler-attributed

For mixed buckets, provide a JSON config with per-bucket FLOPs, time, and either step weight or sample count plus global batch. Use the aggregate total-FLOPs / total-time result, not a naive arithmetic mean.

5. Descend Through Three Profiling Layers

Use the cheapest layer that answers the current question:

  1. Framework layer: separate input pipeline, forward, backward/recompute, optimizer, clipping, and collectives.
  2. System layer: use Moore Perf System to inspect CPU/GPU overlap, launches, copies, synchronization, queues, streams, and rank skew.
  3. Kernel layer: use Moore Perf Compute only on a small reproducible segment to inspect LaunchStats, MemoryWorkloadAnalysis, SpeedOfLight, occupancy, registers, memory pipelines, and Roofline position.

Do not run full end-to-end training under MCU unless the capture is tightly filtered. MCU replays and serializes kernels to collect counters; its duration is not an end-to-end throughput measurement.

6. Form One Evidence-Backed Hypothesis

Examples:

  • FA2 is graph-breaking or poorly tiled for the observed head/sequence shape.
  • GEMM is using a vendor tensor-core kernel but surrounding cast/reduction traffic dominates.
  • repeated static metadata construction creates fill and launch overhead;
  • host reads such as .item(), .cpu(), logging, or metric synchronization serialize the step;
  • FSDP queue time reflects rank skew rather than slow collective kernels;
  • an activation larger than LLC is repeatedly materialized by cat/split/copy operations;
  • short and long buckets need different static compiled policies.

Change one variable at a time. Keep a decision log for both positive and negative experiments.

7. Validate And Decide

Require all of the following before retaining a change:

  • numerical differences are characterized and acceptable for the target dtype;
  • the same checkpoint and data produce finite forward, backward, and optimizer behavior;
  • the gain survives repeated non-profiled A/B runs and exceeds normal variance;
  • peak memory and all supported buckets remain acceptable;
  • the end-to-end result agrees with the microbenchmark direction;
  • distributed scaling and checkpoint load/save still work when affected.

Prefer small stable gains that compose, but keep experimental paths disabled by default until their full-training benefit is repeatable.

Artifact Contract

Create a self-contained run directory with:

run/
  environment.json
  command.txt
  source.txt
  baseline.json
  correctness.json
  profiles/
    framework/
    system/
    compute/
  decisions.md

Record exact versions and commands, but sanitize machine-specific and secret values before sharing.

当前收录版本

0.0.1

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值95/100

亮点

  • 针对摩尔线程MUSA GPU的AI训练性能优化,解决实际工程痛点
  • 涵盖从环境检查到性能分析的完整工作流
  • 提供具体的测量方法和验证机制
触发精准88/100

亮点

  • 触发词覆盖全面,包含Torch MUSA、MTT GPU、mthreads-gmi等具体技术栈
  • 明确区分了不同优化场景和工具链
结构规范85/100

亮点

  • 工作流程分阶段清晰,包含度量定义、环境捕获、基准建立等完整步骤
  • 提供了具体的脚本命令和配置文件结构
执行可靠92/100

亮点

  • 包含完整的正确性验证机制,确保数值行为一致性
  • 提供了详细的artifact contract和版本控制要求
证据可验 (前四项均值)90/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 账号、密钥或授权

    使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。

    主文档提及 · 第 18 行

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。