Relax: Agent for Claude Code

.opencode/agents/fsdp-expert.md

fsdp-expert is an agent for Claude Code, OpenCode from redai-infra/Relax. It costs 38 tokens per session (919 once invoked), scanned A, original, Apache-2.0.

A specialist guide for FSDP, a PyTorch method that splits a model’s parameters across GPUs during machine-learning training. It covers setup, weight updates, memory options, and troubleshooting.

In plain words
What is it for?
Use it when working with FSDP-based training, parameter sharding, CPU offloading, shared training and inference GPUs, or FSDP weight-update problems.
Why use it?
It helps developers diagnose and configure distributed training when model parameters, GPU memory, or weight updates are difficult to manage.

Agent for Claude CodeOpenCode

Written for OpenCode and Claude Code: installed under .opencode/, but also a Claude Code subagent (agents/*.md). Also seen: mentions subagents; mentions AGENTS.md.

This is redai-infra/Relax's own configuration. It tells Claude Code and OpenCode how to work on Relax itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything Relax configures →

Reuse

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.

Copy the file
curl -O https://raw.githubusercontent.com/redai-infra/Relax/main/.opencode/agents/fsdp-expert.md
Clone the repo
git clone --depth 1 https://github.com/redai-infra/Relax

Made for: Claude Code, OpenCode.

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

agentmods badge for fsdp-expert

README.md
[![agentmods](https://agentmods.dev/badge/agents/redai-infra/relax/fsdp-expert.svg)](https://agentmods.dev/agents/redai-infra/relax/fsdp-expert)
Your own site
<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>
Per session 38 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 919 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 8d ago against content hash 140ad9d39398, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

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.

.opencode/agents/fsdp-expert.md · 85 lines

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():

  1. _setup_device_mesh() — 创建 DP/TP 进程组
  2. Sequential load — HF config + tokenizer(避免竞态)
  3. apply_fsdp2() — 参数分片
  4. Load HuggingFace state dict
  5. 初始化 AdamW 优化器
  6. 创建 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 Packingrelax/backends/fsdp/data_packing.pypack_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 配置

Read the full file on GitHub · 85 lines

Changes

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.

  1. 8d ago First seen · 85 lines · 38 tokens per session scan A 140ad9d39398

Subscribe to this mod's changes

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.

Related

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.

avelikiy/great_cto · 41 tokens

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…

avelikiy/great_cto · 112 tokens

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"…

frankxai/agentic-creator-os · 131 tokens

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…

frankxai/agentic-creator-os · 138 tokens

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…

frankxai/agentic-creator-os · 152 tokens

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…

frankxai/agentic-creator-os · 114 tokens