Optimize Musa Training logo

Optimize Musa Training

Organization
open-infra-skills
optimize-musa-training

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.

Overview

Publisheropen-infra-skills
Repositoryinfra-skills
Skill nameoptimize-musa-training
Stars
140
Forks
2
Bundled files
9
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 9 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by open-infra-skills on GitHub. Read the source before you install it.

Installation

Install the Optimize Musa Training AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/open-infra-skills/infra-skills/tree/main/skills/accelerators/optimize-musa-training
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/open-infra-skills/infra-skills.git /tmp/infra-skills
mkdir -p .claude/skills
cp -r /tmp/infra-skills/skills/accelerators/optimize-musa-training .claude/skills/optimize-musa-training
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Optimize Musa Training in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Optimize Musa Training on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Optimize Musa Training is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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:

bash
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:

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

4. Quantify Utilization

For one shape:

bash
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:

text
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.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Optimize Musa Training AI skill do?

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.

Why use Optimize Musa Training on TypingMind?

Because you install it once and use it with any model. Optimize Musa Training is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Optimize Musa Training in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/open-infra-skills/infra-skills/tree/main/skills/accelerators/optimize-musa-training. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Optimize Musa Training?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Optimize Musa Training?

As many as you like. As long as a model supports skills, you can use Optimize Musa Training with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Optimize Musa Training AI skill free?

Yes. It is published on GitHub by open-infra-skills under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇