第一部分:理解群体智能与训练通信能力
这是一篇面向有抱负读者的愿景型博客系列。我们(包括社区中的你我)希望构建自己的智能体集群,因为它们令人兴奋、充满挑战,且能力日益增强。此外,如果我们能训练自己的智能体以集群方式协同工作,那将非常酷;而如果这些集群使用的是小型且负担得起的模型,那就更加酷炫了。
这正是本系列要做的事情!每篇博客文章都将包含关于构建集群的背景知识,以及你可以在 Hugging Face Jobs 上运行的可复现示例。本文的示例在两块 H200 GPU 上运行大约需要五小时,成本约为 50 美元。
多智能体系统很难实现有效运作。增加智能体会改变智能体的上下文、预算,进而影响整个系统的复杂性。通过通信混合智能体的上下文,并不必然带来相对于单一智能体的性能提升。模型需要通过训练来学习如何通信。我们该如何定义模型应该学习的内容?当我们面对众多智能体时,又该更新哪些模型权重呢?
在本系列中,我们将通过教育性的概述和实际示例来解决这些问题。每篇文章将引入一个问题,构建一个小型系统,并考察发生的情况以及如何复现它。这个第一个示例从四个智能体、一个共享的语言模型和一个简单的可验证任务开始。它非常适合你自己实现、 tinkering(折腾)和学习。
首先,我们将从关于集群的一些背景知识开始。
集群的兴起
在过去几个月里,我们听到了大量关于集群的报道,既有好消息也有坏消息。今年九月,OpenAI 宣布一个由大约 10,000 个智能体组成的集群在纳维-斯托克斯(Navier-Stokes)方程的三维情形中找到了奇点,这是千禧年大奖难题之一。一个规模较小、近 100 个智能体的组已经证明了无外力驱动的三维欧拉方程的正则性不成立,这是一个密切相关且尚未解决的开放性问题。
但是,集群并不总是能解决我们希望它们解决的问题。METR 对 Hugging Face 事件的调查发现,大约 1,200 个本应隔离的 OpenAI 智能体找到了一种交换超过 70,000 条消息和文件的方法。大约 700 个智能体在寻找欺骗其基准测试评分器的方法时,加入了针对 Hugging Face 的攻击,而它们并没有被指示这样做。
一个大型集群本身并不能证明合作带来了帮助。Noam Brown 估计,纳维-斯托克斯方程的结果中,不到 10% 来自多智能体合作。在 Anthropic 的漏洞发现实验中,协调的智能体比独立的智能体发现了更多的漏洞,但也搜索了更多的代码并使用了更多的 token。当比较范围限制在相同的目录时,每百万 token 的结果大致相同。
是合作带来了帮助,还是我们只是花费了更多?
从最简单的情况开始。如果四个智能体各自独立尝试一项任务,只要我们能判断哪个答案是正确的,那么至少有一个成功的概率就高于单次尝试。这为多智能体系统提供了一个有用的基线,但它并不能证明智能体之间相互帮助。它们可能仅仅是拥有了更多的尝试机会。
四次尝试的成本也是四倍。因此,更公平的比较是在同等预算下进行的:如果四个智能体中的每一个都获得总 token 量的四分之一,它们是否仍然能击败花费所有 token 的一个智能体?我们只能通过测试来找出答案,因为结果取决于任务、模型以及工作是如何分配的。
本系列不断追问一个问题:当智能体进行通信时,它真的有帮助吗,还是我们只是在消耗更多的计算资源?
我们通过一个简单的期望来理解这个问题。
图 1. 我们要测试的期望示意图:在匹配的预算下比较通信智能体与独立智能体。
我们将把智能体数量视为一个扩展维度,与令牌(tokens)和模型规模并列。有时增加智能体会有所帮助;有时协调过程会消耗我们原本希望节省的预算。关键在于对两者进行测量。我们不会从一万个智能体开始,而是从一个小型团队着手,处理一项我们可以轻松检查的任务。
多智能体系统与强化学习
在多语言模型被称为“群体”之前,多智能体强化学习就已经研究了合作与竞争。
单个智能体的任务是一个马尔可夫决策过程:观察、行动、获得奖励。在团队中,所有人共享奖励,但每个智能体只能看到世界的一部分。这是一个去中心化的部分可观测马尔可夫决策过程:队友之间协作,但没有人能看到全貌。
这带来了三个实际问题。首先,队友在不断变化,而每个智能体都在学习。其次,信用分配:当团队取得成功时,哪些行动值得归功于它们?一个获胜的团队可能包含微弱的行动,而我们可能会错误地奖励这些行动。第三,一条消息会改变其他智能体的观察结果,因此通信是我们正在训练的策略的一部分。
常见的解决方案是集中式训练与去中心化执行:训练使用来自整个团队的信息,但每个智能体仅根据自身的观察采取行动。我们的第一个示例遵循这一模式,采用共享的团队奖励。
智能体也可以以不同的方式组织。两个有用的起点是:
层级结构。一个主导智能体将工作分配给工作人员并收集他们的结果。Anthropic 的研究系统就是这样工作的,每个工作人员都有独立的上下文。Kimi K2.5 的 PARL 仅训练编排者(orchestrator),并保持子智能体冻结,因此训练多智能体系统并不意味着更新每个组件。请参阅 Anthropic 的系统描述和 Kimi 的技术博客。
分布式团队。对等方互相发送消息并决定何时查看收件箱。没有主导智能体分配行动。这正是我们将在此处使用的设置,遵循 s³: Simple Scaling of Swarms via Cooperative Multi-agent RL 中的信息聚合任务。
我们的第一个实验:四个智能体对数字排序
我们将复现《Simple Scaling of Swarms》中的信息共享任务,因为该任务具有可解释性且易于实现。四个智能体共享一个小型语言模型,并学习整合各自掌握的信息。
每个智能体接收一个从 1 到 99 的整数。它知道自己的分配结果以及队友的名字。它最初并不知道其他智能体的数字。例如,四个私密分配结果可能是“五”、“二十六”、“五”和“七十八”。重复的数字会保留在列表中,因此正确的最终答案是:
当至少有一个智能体提交完整且正确排序的列表时,团队即告成功。一个正确答案就足够了;成功并不要求所有四个智能体都回答正确。如果没有来自队友的信息,智能体无法可靠地推断出其他私密分配结果。
这意味着该任务尚未直接测试图 1。每个智能体都持有他人所需的信息,因此无论重试多少次,单个智能体或没有消息传递功能的团队都无法成功。相反,该任务测试的是图 1 背后的前提条件:一个小型共享策略能否学会通信,以及这需要多少令牌成本?后续文章将转向一项单个智能体可以独立解决的任务,其中匹配预算的比较才具有意义。
主要的通信工具是 message(to, text)、read_messages() 和 check_notifications()。通知告知智能体存在未读消息;查看收件箱可使消息内容可用。智能体可以发送私信或向所有人广播。
我们定义了一个四智能体系统,使用一个共享的 Qwen3-0.6B 策略,具有独立的上下文和私密输入。我们并没有训练四个不同的模型。提示词解释了任务以及工具,包括需要共享分配结果。
图2。任务与训练循环。私有数字描绘了一个可能的成功回合;该图形并非录制的对话,也不代表对第75次更新时所学协议的断言。
团队奖励与每个问题的八次尝试
在本文中,“团队”指一个回合:四个智能体各尝试解决一个问题一次。成功的团队会获得奖励,但该奖励会根据其使用的令牌数量进行缩减。失败的团队则获得零分:
团队配额 = 4 × (8,192 工作令牌 + 1,024 最终答案令牌)
= 36,864 个令牌
奖励 = 成功 × (1 − 0.25 × min(1, 生成的团队令牌 / 36,864))
举例来说,一个正确解答但仅使用了一半配额的团队将获得 0.875 的奖励。发送消息没有单独的奖励。其激励机制在于以更少的生成令牌完成任务。
对于每个训练问题,我们收集八次独立的团队尝试。它们的奖励会在该组内进行归一化。表现优于组平均值的尝试获得正向优势;表现较差的尝试则获得负向优势。同一团队中的每个智能体都会获得该团队的优势值,即使某个智能体的最终答案是错误的。
在 TRL 中,每个智能体采样的令牌构成一个训练行。其接收到的消息和工具结果提供上下文。损失在每个团队内平均计算,然后在团队间进一步平均,因此较长的对话不会赋予团队更高的权重。
我们的结果来自原始实验,该实验每次更新使用 256 次团队尝试(32 个问题,每个问题八次尝试)。本指南使用 TRL 的默认值 --teams-per-update 128 ,相当于每次更新约 150 次团队尝试。
我们的结果
在 75 个步骤中,训练成功率从 6.6% 上升至 82.3% ,这是比较前五次和最后五次更新的结果。在第 75 次检查点时,四智能体团队解决了 32 个保留问题中的 26 个(81.25%)。论文报告称,经过 200 次更新后,四智能体的成功率达到了 93.2%。
该团队每次尝试使用的令牌也减少了 37.4%,从约 13k 降至 8k。这一改进伴随着更活跃的信息共享:广播次数从每团队 2.38 次增加到 5.73 次,尽管总令牌使用量有所下降。
图3。蓝色曲线描述了在每次更新前收集的包含 256 次团队尝试的训练批次。橙色点表示在指定更新后的保留检查。
该团队在训练后期使用的令牌也更少。比较前五次更新与第 71–75 次更新:
训练指标
更新 1–5,平均值
更新 71–75,平均值
成功率
6.56%
82.34%
每团队生成的令牌数
12,826.9
8,026.0
每团队的对话数
3.48
6.28
每团队的广播次数
2.38
5.73
每个智能体恰好一次广播的团队比例
4.06%
18.20%
在这两个时间窗口之间,每个训练团队生成的令牌减少了 37.4%。在第 75 个批次本身,平均每团队为 7,624 个令牌。这些是训练测量数据;我们没有保留已训练检查点的保留令牌效率测量数据。
请注意,更少的令牌并不意味着更少的消息。更多的智能体开始参与,但广播变得更为普遍,而非直接消息。生成的令牌包括推理、工具调用以及消息正文,因此仅凭消息数量无法告诉我们团队产生了多少文本。
图4。顶部:训练令牌使用量及最近五次更新的平均值。底部:互斥的通信类别,基于发送消息事件。团队的分类首先依据是否有智能体从未发送消息,其次依据是否发生任何直接消息,再次依据是否每个智能体恰好发送一次广播;其余团队则重复广播。
更多的重试次数还是经过训练的团队?
没有任何智能体能单独解决问题,因此“拥有更多重试次数的单个智能体”最接近的等效对象是拥有更多重试次数的未训练团队。训练数据中已经包含了这一比较。每次更新针对每个问题收集八次尝试,且任务的答案易于检查,因此当任何一次尝试成功时,我们可以将该问题计为已解决。在训练早期,该计数给出了未训练团队的最佳-8 成功率:
成功
每个问题的生成令牌数
未训练团队,8次尝试中最佳结果(第1–5次更新)
37.5%
约 103,000
训练后团队,1次尝试(第71–75次更新)
82.3%
约 8,000
通过8次重试,未训练团队解决的问题不到一半,且消耗的令牌数量约为训练后团队单次尝试的13倍。请将其视为估算值。两行数据均使用训练问题而非保留测试集,且第2–5次更新已从经过轻微训练的模型中采样。
基础设施
该模型较小,但 rollout(推理生成)过程并不轻量。每次更新都会生成数百万个令牌,涉及长达 40k 令牌的上下文中的智能体对话。我们使用一个 H200 GPU 作为训练器,并部署了七个运行 vLLM rollout 引擎的 H200 GPU 以快速完成这些 rollout,同时保持每个工作节点的八次尝试在一起。以下演示任务在两块 GPU 上运行。以下是基础设施详情:
设置
记录的实验
共享策略
Qwen3-0.6B
每队逻辑智能体数
4
每次更新的问题数
32
每问题团队尝试次数
8
每个智能体的工作/最终令牌数
8,192 / 1,024
学习率/温度
5e-7 / 1.0
训练问题池
1,024 个生成问题
报告端点
保留检查点 75
执行
1 个训练 GPU + 7 个 rollout GPU
实际示例:训练您自己的群体智能
上述图表描述了我们原始的 75 次更新实验。在本演示中,我们将在 Hugging Face Jobs 上运行 TRL 的 swarm(群体)示例。一个 H200 通过 vLLM 提供共享的 Qwen3-0.6B 策略服务,第二个 H200 对其进行训练。
使用能够运行 Jobs 和创建存储桶的 Hugging Face 账户登录。将 YOUR_USERNAME 替换为您的 Hub 用户名。
每次运行使用一个新的存储桶,以便保留之前的测量数据。
uv tool install 'huggingface_hub==2.4.0'
hf auth login
BUCKET="YOUR_USERNAME/swarm-trl-$(date -u +%Y%m%d-%H%M%S)"
hf buckets create "$BUCKET"
将以下脚本保存为当前目录下的 train-swarm.sh。
train-swarm.sh
set -eu
git clone --depth 1 https://github.com/huggingface/trl /tmp/trl
cd /tmp/trl
example=examples/async_grpo_s3_aggregation
if [ ! -f "$example/async_grpo_s3_aggregation.py" ]; then
git fetch --depth 1 origin refs/pull/8424/head
git checkout --detach FETCH_HEAD
fi
git rev-parse HEAD > /results/trl-revision.txt
python -m pip install -e ".[vllm,kernels]" "vllm==0.32.0" datasets httpx trackio
base=Qwen/Qwen3-0.6B
url=http://127.0.0.1:8000
export TRACKIO_DIR=/tmp/trackio
serve () {
CUDA_VISIBLE_DEVICES=0 VLLM_SERVER_DEV_MODE=1 vllm serve "$@" \
--host 127.0.0.1 --max-model-len 40960 --max-num-seqs 512 --enable-prefix-caching &
server=$!
until curl -fs "$url/health" >/dev/null; do kill -0 "$server" ; sleep 5; done
}
evaluate () {
python "$example/evaluate.py" --url "$url" --model "$1" --name "$2" \
--episodes 192 --concurrency 64 --out "/results/$2.jsonl"
}
serve "$base" --logprobs-mode processed_logprobs --weight-transfer-config "{\"backend\":\"nccl\"}"
evaluate "$base" base
CUDA_VISIBLE_DEVICES=1 accelerate launch --num_processes 1 --mixed_precision bf16 \
"$example/async_grpo_s3_aggregation.py" --vllm-url "$url" \
--updates 50 --teams-per-update 128 --concurrent-teams 128 \
--report-to trackio --output-dir /tmp/swarm
cp -r "$TRACKIO_DIR" /tmp/swarm/checkpoint-50 /results/
kill "$server"
wait "$server" || true
serve /tmp/swarm/checkpoint-50 --logprobs-mode processed_logprobs
evaluate /tmp/swarm/checkpoint-50 trained
以下命令将其内容发送至作业。在作业内部,vLLM 在 GPU 0 上提供共享策略服务。GPU 1 使用 Trackio 运行 TRL 的 async_grpo_s3_aggregation.py 进行 50 次更新。TRL 的 evaluate.py 在同一组 192 个保留问题上对基础模型和检查点 50 进行评分。这比结果中使用的 32 个问题检查集更大,从而提供更紧密的误差范围。作业会将两项评分、检查点、Trackio 数据以及确切的 Git 提交记录保存到您的存储桶中。
hf jobs run --detach --flavor h200x2 --timeout 12h \
--volume "hf://buckets/$BUCKET:/results" \
-vllm/vllm-openai:v0.32.0 bash -c "$(cat train-swarm.sh)"
一次 TRL rollout 包含整个团队的对话。训练者会对比同一问题的八次尝试,并将结果反馈给每次尝试中的全部四个智能体
Part 1: Understanding swarms and training to communicate
This is an aspirational blog series for aspirational readers. We (us, the community, you) want to build our own agent swarms because they're exciting, challenging, and increasingly capable. Furthermore, it would be extremely cool if we could train our own agents to work in a swarm. And exponentially cool if those swarms used small and affordable models.
That's what we'll do in this series! Each blog post will include some context on building swarms, alongside reproducible examples that you can run on Hugging Face Jobs. This post's example takes about five hours on two H200s, which costs roughly $50.
Multi-Agent Systems are hard to get working. Adding agents changes the agent's context, the budget, and in turn the complexity of the whole system. Mixing agents' context together through communication is not an inherent performance boost compared to a single agent. The model needs to learn to communicate through training. How do we define what models should learn? And which model weights do we update when we're dealing with many agents?
In this series, we'll work through those problems with an educational overview and practical examples. Each post will introduce a question, build a small system, and examine what happens and how you can reproduce it. This first example starts with four agents, a shared language model, and a simple verifiable task. It's ideal to implement yourself, to tinker with, and to learn from.
First, we'll start off with some context on swarms.
The rise of the swarms
We've heard a lot about swarms over the past few months, both good and bad. In September this year, OpenAI announced that a swarm of roughly 10,000 agents had found a singularity in the 3D Navier-Stokes equations, one of the Millennium Prize problems. A smaller group of nearly 100 agents had already disproved regularity for the unforced 3D Euler equations, a closely related open problem.
But swarms don't always work on the problems we want them to. METR's investigation of the Hugging Face incident found that around 1,200 OpenAI agents, which were supposed to be isolated, had found a way to exchange over 70,000 messages and files. Around 700 joined an attack on Hugging Face while looking for ways to fool their benchmark's scorer, without instruction to do so.
A big swarm isn't, by itself, evidence that cooperation helped. Noam Brown estimates that less than 10% of the Navier-Stokes result came from multi-agent cooperation. In Anthropic's vulnerability-finding experiment , coordinated agents found more bugs than independent agents, but also searched more code and used more tokens. When the comparison was restricted to the same directories, the results per million tokens were about the same.
Did cooperation help, or did we just spend more?
Start with the simplest case. If four agents each try a task independently, the chance that at least one gets it right is higher than with a single attempt, as long as we can tell which answer is correct. That makes a useful baseline for a multi-agent system, but it doesn't show that the agents helped each other. They may simply have had more tries.
Four attempts also cost four times as much. So the fairer comparison is at an equal budget: if each of four agents gets a quarter of the total tokens, can they still beat one agent that spends all of them? We can only find out by testing, because the answer depends on the task, the model and how the work is divided.
This series keeps asking one question: when agents communicate, does it actually help, or are we just spending more compute?
We understand that question through this simple expectation.
Figure 1. Sketch of the expectation we want to test: compare communicating and independent agents at matched budgets.
We'll treat agent count as a scaling dimension, alongside tokens and model size. Sometimes adding agents will help. Sometimes coordination will consume the budget we hoped to save. The point is to measure both. We won't start with 10,000 agents. We'll start with a small team on a task that we can check easily.
Multi-agent Systems and Reinforcement Learning
Multi-agent reinforcement learning has studied cooperation and competition long before language models were called swarms.
A single agent's task is a Markov decision process: observe, act, get a reward. In a team, everyone shares the reward, but each agent sees only part of the world. This is a decentralized partially observable Markov decision process: teammates, but no one sees the whole picture.
This creates three practical problems. First, teammates keep changing while each agent learns. Second, credit assignment: when the team succeeds, which actions deserve the credit? A winning team can include weak actions, and we may end up rewarding them. Third, a message changes what other agents observe, so communication is part of the policy we're training.
A common solution is centralized training with decentralized execution: training uses information from the whole team, but each agent acts only on its own observations. Our first example follows this pattern with a shared team reward.
Agents can also be organized in different ways. Two useful starting points are:
A hierarchy. A lead agent assigns work to workers and collects their results. Anthropic's Research system works this way, with a separate context for each worker. Kimi K2.5's PARL trains only the orchestrator and keeps the subagents frozen, so training a multi-agent system doesn't mean updating every component. See Anthropic's system description and Kimi's technical blog .
A distributed team. Peers send each other messages and decide when to read their inboxes. No lead agent assigns the actions. This is the setup we'll use here, following the information-aggregation task in s³: Simple Scaling of Swarms via Cooperative Multi-agent RL .
Our first experiment: four agents ordering numbers
We'll reproduce the information-sharing task from Simple Scaling of Swarms because it's interpretable and straightforward to implement. Four agents share a small language model and learn to pool what each of them knows.
Each agent receives one integer from 1 to 99. It knows its own assignment and its teammates' names. It does not initially know the other agents' numbers. For example, four private assignments might be "five", "twenty-six", "five" and "seventy-eight". Duplicates stay in the list, so a correct final answer is:
The team succeeds when at least one agent submits the complete, correctly sorted list . One correct answer is enough; success does not require all four agents to answer correctly. An agent cannot reliably infer the other private assignments without information from its teammates.
This means the task does not yet test Figure 1 directly. Each agent holds information the others need, so a single agent, or a team without messaging, cannot succeed however many retries it gets. Instead, the task tests the precondition behind Figure 1: can a small shared policy learn to communicate at all, and how many tokens does that cost? A later post moves to a task that a single agent can solve alone, where the matched-budget comparison is meaningful.
The main communication tools are message(to, text) , read_messages() , and check_notifications() . A notification tells an agent that unread messages exist; reading its inbox makes their contents available. Agents can send direct messages or broadcast to everyone.
We defined a four-agent system using one shared Qwen3-0.6B policy , with separate contexts and private inputs. We are not training four different models. The prompt explains the task and the tools, including the need to share assignments.
Figure 2. The task and training loop. The private numbers illustrate a possible successful episode; this graphic is not a recorded conversation or a claim about the learned protocol at update 75.
A team reward and eight attempts at each problem
In this post, a team means one episode: four agents attempting one problem once. A successful team receives a reward reduced by the tokens it uses. A failed team receives zero:
team allowance = 4 × (8,192 work tokens + 1,024 final-answer tokens)
= 36,864 tokens
reward = success × (1 − 0.25 × min(1, generated team tokens / 36,864))
For illustration, a correct team using half its allowance receives 0.875. There is no separate reward for sending messages. The incentive is to solve the task while using fewer generated tokens.
For every training problem, we collect eight independent team attempts. Their rewards are normalized within that group. An attempt that does better than its group average gets a positive advantage; one that does worse gets a negative advantage. Every agent in the same team receives that team's advantage, including an agent whose own final answer was wrong.
In TRL , each agent's sampled tokens form a training row. Its incoming messages and tool results provide context. The loss is averaged within each team and then across teams, so longer conversations do not give a team more weight.
Our results come from the original experiment, which used 256 team attempts per update (32 problems with eight attempts each). The walkthrough uses TRL's default of --teams-per-update 128 , which works out to about 150 team attempts per update.
Our Results
Over 75 steps, training success rose from 6.6% to 82.3% , comparing the first and last five updates. At checkpoint 75, the four-agent team solved 26 of 32 held-out problems (81.25%) . The paper reports 93.2% four-agent success after 200 updates.
The team also used 37.4% fewer tokens per attempt , falling from about 13k to 8k. This improvement accompanied more active information sharing: broadcasts increased from 2.38 to 5.73 per team, even as total token use fell.
Figure 3. The blue curve describes training batches of 256 team attempts, collected before each update. Orange points are held-out checks after the indicated update.
The team also used fewer tokens later in training. Comparing the first five updates with updates 71–75:
Training metric
Updates 1–5, mean
Updates 71–75, mean
Success
6.56%
82.34%
Generated tokens per team
12,826.9
8,026.0
Messages per team
3.48
6.28
Broadcasts per team
2.38
5.73
Teams with one broadcast per agent
4.06%
18.20%
That is a 37.4% reduction in generated tokens per training team between those windows. At batch 75 itself, the mean was 7,624 tokens per team. These are training measurements; we did not retain held-out token-efficiency measurements for the trained checkpoint.
Notice that fewer tokens did not mean fewer messages. More agents began participating but broadcasting became more common, rather than direct messaging. Generated tokens include reasoning and tool calls as well as message bodies, so message count alone does not tell us how much text the team produced.
Figure 4. Top: training token use and a trailing five-update mean. Bottom: mutually exclusive communication classes, based on sent-message events. A team is classified first by whether some agent never sends, then whether any direct message occurs, then whether every agent sends exactly one broadcast; the remaining teams repeat broadcasts.
More retries or a trained team?
No agent can solve the problem alone, so the closest equivalent of "a single agent with more retries" is the untrained team with more retries. The training data already contains this comparison. Each update collects eight attempts per problem, and the task's answers are easy to check, so we can count a problem as solved when any of its eight attempts succeeded. Early in training, that count gives the untrained team's best-of-8 success rate:
Success
Generated tokens per problem
Untrained team, best of 8 attempts (updates 1–5)
37.5%
about 103,000
Trained team, one attempt (updates 71–75)
82.3%
about 8,000
With eight retries, the untrained team solves fewer than half the problems and spends about 13 times as many tokens as one attempt from the trained team. Read this as an estimate. Both rows use training problems rather than held-out ones, and updates 2–5 already sample from a slightly trained policy.
Infrastructure
The model is small, but the rollouts are not. Each update generates millions of tokens of agent conversation at contexts of up to 40k tokens. We used one H200 for the trainer and seven H200s running vLLM rollout engines to get through those rollouts quickly, and kept each worker's eight attempts together. The walkthrough below runs the same task on two GPUs. Here are the infra details:
Setting
Recorded experiment
Shared policy
Qwen3-0.6B
Logical agents per team
4
Problems per update
32
Team attempts per problem
8
Work / final tokens per agent
8,192 / 1,024
Learning rate / temperature
5e-7 / 1.0
Training problem pool
1,024 generated problems
Reporting endpoint
Preserved checkpoint 75
Execution
1 trainer GPU + 7 rollout GPUs
Practical example: Train your own swarm
The figures above describe our original 75-update experiment. In this walkthrough we'll run TRL's swarm example on Hugging Face Jobs. One H200 serves the shared Qwen3-0.6B policy with vLLM and a second H200 trains it.
Sign in with a Hugging Face account that can run Jobs and create buckets. Replace YOUR_USERNAME with your Hub username.
Use a fresh bucket for each run so earlier measurements stay available.
uv tool install 'huggingface_hub==2.4.0'
hf auth login
BUCKET= "YOUR_USERNAME/swarm-trl- $(date -u +%Y%m%d-%H%M%S) "
hf buckets create " $BUCKET "
Save the script below as train-swarm.sh in your current directory.
train-swarm.sh
set -eu
git clone --depth 1 https://github.com/huggingface/trl /tmp/trl
cd /tmp/trl
example=examples/async_grpo_s3_aggregation
if [ ! -f " $example /async_grpo_s3_aggregation.py" ]; then
git fetch --depth 1 origin refs/pull/8424/head
git checkout --detach FETCH_HEAD
fi
git rev-parse HEAD > /results/trl-revision.txt
python -m pip install -e ".[vllm,kernels]" "vllm==0.32.0" datasets httpx trackio
base=Qwen/Qwen3-0.6B
url=http://127.0.0.1:8000
export TRACKIO_DIR=/tmp/trackio
serve () {
CUDA_VISIBLE_DEVICES=0 VLLM_SERVER_DEV_MODE=1 vllm serve " $@ " \
--host 127.0.0.1 --max-model-len 40960 --max-num-seqs 512 --enable-prefix-caching &
server=$!
until curl -fs " $url /health" >/dev/null; do kill -0 " $server " ; sleep 5; done
}
evaluate () {
python " $example /evaluate.py" --url " $url " --model " $1 " --name " $2 " \
--episodes 192 --concurrency 64 --out "/results/ $2 .jsonl"
}
serve " $base " --logprobs-mode processed_logprobs --weight-transfer-config "{\"backend\":\"nccl\"}"
evaluate " $base " base
CUDA_VISIBLE_DEVICES=1 accelerate launch --num_processes 1 --mixed_precision bf16 \
" $example /async_grpo_s3_aggregation.py" --vllm-url " $url " \
--updates 50 --teams-per-update 128 --concurrent-teams 128 \
--report-to trackio --output-dir /tmp/swarm
cp -r " $TRACKIO_DIR " /tmp/swarm/checkpoint-50 /results/
kill " $server "
wait " $server " || true
serve /tmp/swarm/checkpoint-50 --logprobs-mode processed_logprobs
evaluate /tmp/swarm/checkpoint-50 trained
The command below sends its contents to the job. Inside the job, vLLM serves the shared policy on GPU 0. GPU 1 runs TRL's async_grpo_s3_aggregation.py for 50 updates with Trackio. TRL's evaluate.py scores the base model and checkpoint 50 on the same 192 held-out problems. That is a larger set than the 32-problem checks in our results, which gives tighter error bars. The job saves both scores, the checkpoint, Trackio data and the exact Git commit to your bucket.
hf jobs run --detach --flavor h200x2 -- timeout 12h \
--volume "hf://buckets/ $BUCKET :/results" \
-- vllm/vllm-openai:v0.32.0 bash -c " $(cat train-swarm.sh) "
One TRL rollout contains a whole team conversation. The trainer compares eight attempts at the same problem and gives all four agents in an attempt the
| 刊期 | 得分 | 排名 | 结果 |
|---|---|---|---|
| 2026-11-28 | 9.22 | 19 | 入选 |
| 2026-11-27 | 9.95 | 18 | 未入选 |