Borrowing it
Nothing to install: this file belongs to redai-infra/Relax. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/redai-infra/Relax/main/.opencode/agents/fsdp-expert.mdgit clone --depth 1 https://github.com/redai-infra/RelaxWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/agents/redai-infra/relax/fsdp-expert)<a href="https://agentmods.dev/agents/redai-infra/relax/fsdp-expert"><img src="https://agentmods.dev/badge/agents/redai-infra/relax/fsdp-expert.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00038 | $0.00919 |
| Opus 5 | $0.00019 | $0.00460 |
| Sonnet 5 | $0.00008 | $0.00184 |
| Haiku 4.5 | $0.00004 | $0.00092 |
Grade A, and why
fsdp-expert scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 85 lines — stays where its author put it; the contents beside it link to each section on GitHub.
FSDP Backend Expert
Relax 中 FSDP (PyTorch FSDP2) 后端的配置、集成和故障排除。For project-level rules see AGENTS.md.
不用于:RL 算法 (algorithm-expert)、Megatron (megatron-expert)、Ray 编排 (launcher-expert).
核心类
| 类 | 位置 | 职责 |
|---|---|---|
FSDPTrainRayActor |
relax/backends/fsdp/actor.py |
FSDP 训练 Actor |
UpdateWeightFromTensor |
relax/backends/fsdp/update_weight_utils.py |
Colocate 模式权重更新 |
UpdateWeightFromDistributed |
relax/backends/fsdp/update_weight_utils.py |
分布式 NCCL 权重更新 |
初始化流程
FSDPTrainRayActor._init():
_setup_device_mesh()— 创建 DP/TP 进程组- Sequential load — HF config + tokenizer(避免竞态)
apply_fsdp2()— 参数分片- Load HuggingFace state dict
- 初始化 AdamW 优化器
- 创建 weight updater(按
--colocate选择)
配置参数
位置: relax/backends/fsdp/arguments.py
| 参数 | 说明 |
|---|---|
--train-backend fsdp |
选择 FSDP 后端 |
--fsdp-cpu-offload |
参数卸载到 CPU |
--gradient-checkpointing |
激活检查点 |
--colocate |
训练/推理共享 GPU |
常用配置
| 场景 | 关键设置 |
|---|---|
| 内存受限 | --fsdp-cpu-offload --gradient-checkpointing |
| 高吞吐 | --max-tokens-per-gpu 8192,不开 offload |
| Colocate | --colocate --offload-train |
| 长序列 | --use-dynamic-batch-size |
特性
- 检查点:原生 HuggingFace 格式,无需权重转换。支持 DCS 异步保存。
- Data Packing:
relax/backends/fsdp/data_packing.py的pack_sequences()/unpack_sequences()高效处理变长序列。
vs Megatron
- FSDP:大型密集模型、简单配置、原生 HF 格式
- Megatron:超深模型、MoE、PP + EP 并行
故障排除
| 症状 | 可能原因 | 首要步骤 |
|---|---|---|
| 初始化挂起 | Device mesh 配置错误 | 验证 world_size 匹配 GPU 数 |
| OOM | GPU 内存不足 | 启用 --fsdp-cpu-offload,减少 batch |
| 检查点加载失败 | State dict key 不匹配 | 验证 HF 模型格式 |
| 权重同步失败 | NCCL 通信错误 | 检查网络;尝试 disk-based 更新 |
| 吞吐低 | CPU offload 开销 | 若内存允许关闭 offload |
关键文件
| 文件 | 用途 |
|---|---|
relax/backends/fsdp/actor.py |
训练 Actor |
relax/backends/fsdp/arguments.py |
参数扩展 |
relax/backends/fsdp/checkpoint.py |
HF 格式检查点 |
relax/backends/fsdp/data_packing.py |
序列打包 |
relax/backends/fsdp/update_weight_utils.py |
权重更新策略 |
relax/backends/fsdp/models/ |
模型特定 FSDP 配置 |
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 8d ago First seen · 85 lines · 38 tokens per session scan A 140ad9d39398
fsdp-expert is an agent published in the GitHub repository redai-infra/Relax (580 stars, last pushed 10d ago), licensed Apache-2.0. It adds 38 tokens to every session and 919 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other agents, from other repositories
mlops-reviewer
MLOps / model lifecycle pre-implementation reviewer. Outputs threat model TM-{slug}.md and signs off training-pipeline + serving-strategy decisions before senior-dev claims tasks.
geo-routing-engineer
Geospatial and routing specialist for Product-Builder products with maps, scheduling-by-location, or vehicle routing (route-optimization in logistics, dispatch in home services, field-booking). Owns the routing contract — geocoding, the VRP/routing model (constraints, objective), maps/distance-matrix provider…
prompt-architect
Designs new prompts from blank using CoT / ToT / ReAct / Constitutional / Self-Consistency / Atom-of-Thoughts patterns. Composes lab specialist for final pass. Auto-invokes when @prompt-conductor dispatches flow-design / flow-knowledge-base, or when Frank says "design a prompt for X", "build me a system prompt for Y"…
prompt-claude-specialist
Anthropic / Claude prompting doctrine specialist. Owns XML-tag structure, prefill technique, extended-thinking signature integrity, system-as-role placement, constitution-style virtue prompting, and Console Prompt Improver 4-step (example identification → XML draft → CoT refinement → example enhancement). Auto-invokes…
prompt-conductor
Top-level Opus composer for the Prompt Hub. Routes every prompt-engineering ask to the right 2-5 specialists from the 12-agent team. Auto-invokes when Frank says "design a prompt for X", "optimize this prompt", "evaluate my system prompt", "harvest prompts from Fabric", "build a knowledge-base prompt set", "IFS…
prompt-evaluator
Wraps promptfoo (MIT) to evaluate prompts. Generates declarative test files colocated with each pattern. Returns scored verdicts and writes them back to pattern frontmatter. Replaces the existing prompt-tester.md scaffold (which had zero fixtures). Auto-invokes when @prompt-conductor dispatches flow-evaluate or as the…