composer
Use MosaicML Composer for PyTorch training loops, speedup methods, loggers, checkpoints, distributed launch, profiling, and model export.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- composer
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use MosaicML Composer for PyTorch training loops, speedup methods, loggers, checkpoints, distributed launch, profiling, and model export.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/installation-and-package-map.md3.8 KB
- 参考文档references/repo-provenance.md2.2 KB
- 参考文档references/repo-routing-metadata.json532 B
- 参考文档references/troubleshooting.md4.7 KB
- 脚本scripts/check_import.py3.2 KB
- 脚本scripts/run_smokes.py3.7 KB
03 SKILL.md 正文
MosaicML Composer Repo Skill
Use this repo skill when a task involves MosaicML Composer, the mosaicml Python distribution, or the importable composer package for PyTorch training engines, efficient training methods, callbacks/loggers, checkpoints, distributed launch, profiling, or model export.
Public install:
pip install mosaicml
Minimal import check:
python - <<'PY'
import composer
print(composer.__version__)
from composer import Trainer
print(Trainer)
PY
For optional integrations, read installation and package map before adding extras.
Route by task
- Build, run, resume, or debug a training workflow: read training.
This route owns
Trainer,ComposerModel,ComposerClassifier,DataSpec,Evaluator,Time,State, manual checkpoint load, autoresume, and basic device/precision choices. - Add or debug Composer speedup methods: read methods.
This route owns
composer.algorithms,composer.functional, MixUp/CutMix/LabelSmoothing, model surgery, batch-key routing, and method recipe placement. - Make run state visible: read observability.
This route owns loggers, monitoring callbacks, local/remote file upload, profiler traces,
composer_collect_env, and observability troubleshooting. - Launch or reason about distributed/backend workflows: read distributed.
This route owns the
composerlauncher, rank/world-size helpers, distributed samplers,get_device, FSDP/FSDP2/TP basics, and auto microbatching caveats. - Export models for inference: read inference-export.
This route owns
export_for_inference,ExportForInferenceCallback, TorchScript/ONNX validation, checkpoint-backed export, and optional HuggingFace/PEFT caveats.
Root references and scripts
- Installation and package map: distribution/import names, optional extras, top-level namespaces, console entry points, and first checks.
- Troubleshooting: cross-cutting install/import, backend, optional dependency, CLI, and package-surface failures.
- Repo provenance: source commit, branch, package version, dirty-state baseline, and relative evidence paths.
- Routing metadata: structured scenario placement for managed repo-skill import.
- check_import.py: safe JSON import/backend probe for Composer and PyTorch.
- run_smokes.py: runs bundled sub-skill smoke scripts with the current Python.
Fast operating workflow
- Verify installation with
python scripts/check_import.pyfrom this skill root. - Pick the closest sub-skill route from the task wording and load only the references/scripts it names.
- Start with CPU/tiny-data scripts when debugging model, data, or API issues.
- Add optional extras only for the integration in use; do not install
mosaicml[all]unless the task truly spans many optional backends. - For GPU/distributed issues, run the distributed
device_probe.pybefore launching training. - For checkpoint/export issues, decide whether the task is about training-state resume or inference artifact export; route accordingly.
- Keep generated project code independent of this skill's source provenance and do not copy private machine paths into user scripts.
Composer concepts to recognize
Traineris the high-level training loop that manages fit/eval/predict, checkpoint save/load, callbacks, algorithms, logging, precision, devices, and distributed integration.ComposerModelis the model contract for batches;ComposerClassifierwraps simple(input, target)classification modules.Algorithmclasses integrate methods through Trainer events;composer.functionalhelpers are for custom loops or one-off model/batch mutation.LoggerDestinationsubclasses receive metrics and uploaded files; callbacks and trace handlers generate many of those files.- The
composerconsole entry point launches multi-process distributed jobs and configures rank environment variables. export_for_inferenceandExportForInferenceCallbackproduce TorchScript or ONNX artifacts after optional load/surgery/transform steps.
Avoid using this skill when
- The task is ordinary PyTorch with no Composer APIs, errors, configs, or artifacts.
- The user is actually using PyTorch Lightning, Accelerate, DeepSpeed, or another training framework without Composer.
- The task is model-family-specific and only incidentally mentions a project that once used Composer.
- The user asks to edit the Composer repository itself rather than operate the package; this skill is for package/runtime use, not maintainer development.
Verification posture
The generated skill favors CPU-safe, no-download workflows first and documents CUDA/distributed behavior with backend caveats. Optional CUDA was available during construction and a PyTorch CUDA smoke passed, but production-scale multi-rank training should still be verified in the user's target environment before relying on it.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).