How do you train a multi-agent swarm with Hugging Face TRL?

Hugging Face's swarm guide trains four Qwen3-0.6B agents to share information with team-level RL in TRL, replicating the s³ paper on two GPUs.

한국어로 읽기

Key takeaways

  • Hugging Face's November 26, 2026 guide trains four Qwen3-0.6B agents to communicate with team-level RL in TRL.
  • Training success rose from 6.6% to 82.3% over 75 updates, with 37.4% fewer tokens per team.
  • The TRL example reached 60.9% held-out success at checkpoint 50, against 4.7% for the base team.
  • The walkthrough runs on two H200s in about five hours for roughly $50.
On this page
  1. What did Hugging Face publish?
  2. How does the swarm training loop work?
  3. What results did the experiment report?
  4. What does this mean for teams running AI agents?
  5. How do you train your own swarm with TRL?
  6. What are the limits and open questions?

Hugging Face's swarm guide, published November 26, 2026, shows how to train a team of small agents to communicate with reinforcement learning, using a TRL example that replicates the s³ paper [1][3]. Four copies of Qwen3-0.6B learn to share private numbers over a message board. In the post's run, training success rose from 6.6% to 82.3% while each team used 37.4% fewer tokens [1].

What did Hugging Face publish?

Hugging Face published "Swarms, Flocks, Gangs: How to build, train, and evaluate multi-agent systems" by Ben Burtenshaw and Kashif Rasul, Part 1 of a series on small multi-agent systems that run on Hugging Face Jobs [1]. The post comes with a runnable example in TRL, examples/async_grpo_s3_aggregation, that trains and evaluates a four-agent team [3].

The question the series asks is whether communication between agents helps, or whether it only spends more compute [1]. The authors point out that four independent attempts beat one attempt simply by having more tries, at four times the cost, so "the fairer comparison is at an equal budget." They treat the number of agents as a scaling dimension next to tokens and model size [1].

The example replicates the information-aggregation experiment from s³ (Simple Scaling of Swarms via Cooperative Multi-agent RL), a paper by Kunal Jha and colleagues submitted to arXiv on November 5, 2026 [2][3]. In s³, agents decide for themselves how long to work alone and when to share findings or read what teammates wrote, with no roles or structure set in advance [2].

How does the swarm training loop work?

Each training rollout is one team episode, and the whole team is rewarded or not as a unit [3]. Four agents each receive a private integer from 1 to 99, written in English words, and the team must return all four numbers in ascending order, duplicates kept [3]. The episode succeeds if at least one agent submits the correct full list, so the agents have to talk: no single agent holds all the numbers [1].

The agents get three tools: message(to, text), read_messages() and check_notifications() [1]. All four run the same Qwen3-0.6B policy with thinking on, but each keeps its own context [1][3]. The post follows the distributed-team pattern from s³, where peers message each other and there is no lead agent, rather than a hierarchy in which an orchestrator assigns work [1].

Flow of one training step: four agents with private numbers share a message board, submit answers, receive one team reward, and eight teams per problem update one shared Qwen3-0.6B policy
One team episode is one rollout; the team reward and group-normalized advantage train a single shared policy (sources [1], [3]).

The reward pays for success and charges a little for tokens. The team allowance is 4 × (8,192 work tokens + 1,024 final-answer tokens), or 36,864 tokens, and the reward is success × (1 − 0.25 × min(1, generated team tokens / 36,864)) [1]. A failed team gets zero, and there is no separate reward for sending messages [1]. A successful team that spends its whole allowance still keeps 75% of the reward, so the token penalty shapes efficiency without overriding the goal.

Training uses GRPO with groups of teams. The trainer runs 8 team attempts on the same problem, normalizes rewards within that group, and gives every agent in a team the same advantage [1]. In TRL, each agent's turns become one training row, the loss follows Eq. 3 of the paper, and PPO clipping is turned off [3]. The post describes this as centralized training with decentralized execution: the team learns from one shared signal, but each agent acts only on what it can see [1].

What results did the experiment report?

The trained team solved far more problems with fewer tokens. Over 75 updates, training success rose from 6.6% to 82.3% (first five updates against last five), and checkpoint 75 solved 26 of 32 held-out problems, or 81.25% [1]. Tokens per team attempt fell from about 13,000 to about 8,000, a 37.4% cut [1].

The agents also changed how they talked. Broadcasts per team rose from 2.38 to 5.73, and the share of teams where every agent broadcast exactly once rose from 4.06% to 18.20% [1]. So the token savings did not come from sending fewer messages.

The budget comparison is the result most worth noting. Given 8 attempts, the untrained team solved 37.5% of problems at about 103,000 tokens per problem; the trained team solved 82.3% in one attempt at about 8,000 tokens [1]. The authors call this an estimate, because it uses training problems rather than held-out ones [1].

RunUpdatesHeld-out successSource
Qwen3-0.6B base team04.7% of 192TRL README [3]
TRL reference run, checkpoint 505060.9% of 192TRL README [3]
Blog run, checkpoint 757581.25% (26 of 32)Hugging Face blog [1]
s³ paper20093.2% reportedTRL README [3]
Bar chart of held-out success: 4.7% for the base team, 60.9% at checkpoint 50, 81.25% at checkpoint 75 and 93.2% reported by the s³ paper after 200 updates
Held-out team success across runs, which differ in updates and sample size (sources [1], [3]).

The s³ paper itself reports larger effects at scale. Under matched training and inference budgets, s³ swarms tested with twice as many agents as in training solved over 25 times more coordination problems than the strongest baseline [2]. In parallel exploration tasks, communicating agents cut repeated work by nearly 50% and beat best-of-N sampling by up to 9.4 percentage points [2].

What does this mean for teams running AI agents?

For teams, the practical lesson is to measure a multi-agent setup against the same budget spent on independent attempts. The post makes that comparison its central question, and cites an Anthropic study in which coordinated agents found more bugs than independent ones but used more tokens, with about the same results per million tokens when limited to the same directories [1]. More agents talking is not free, and it is not automatically better.

The second lesson is that coordination can be learned rather than hand-written. The s³ authors conclude that organization can emerge from a shared goal instead of being designed in advance, and that learned agents developed complementary roles and generalized to larger teams [2]. If you run orchestrator-and-worker pipelines today, the TRL example is a small, cheap place to test whether a trained peer team beats your fixed structure on your own metric.

The metrics the example logs are a useful checklist for any team of agents: team/success, team/reward, team/tokens, team/messages and team/silent_agent_frac, the share of agents that never spoke [3]. In a shared workspace such as Hardi, where several agents post to the same channel, the same counts (who spoke, how much, and whether the work finished) are the ones that tell you if coordination is paying for itself.

How do you train your own swarm with TRL?

You can reproduce the experiment with two GPUs: one serves the model with vLLM and one trains. The post's walkthrough runs on Hugging Face Jobs with the h200x2 flavor, takes about five hours and costs roughly $50; it installs huggingface_hub==2.4.0, uses the vllm/vllm-openai:v0.32.0 image, trains for 50 updates with 128 teams per update, and evaluates the base model and checkpoint 50 on 192 held-out problems [1]. TRL's own reference run took about 4.8 hours on two H100s [1].

To run it on your own machine instead, install TRL from the repository root and start the vLLM server on GPU 0 [3]:

Bash
pip install -e ".[vllm,kernels]" datasets httpx

CUDA_VISIBLE_DEVICES=0 VLLM_SERVER_DEV_MODE=1 vllm serve Qwen/Qwen3-0.6B --port 8000 \
  --max-model-len 40960 --max-num-seqs 512 --enable-prefix-caching \
  --logprobs-mode processed_logprobs --weight-transfer-config '{"backend":"nccl"}'

Then train on GPU 1 [3]:

Bash
CUDA_VISIBLE_DEVICES=1 accelerate launch --num_processes 1 --mixed_precision bf16 \
  examples/async_grpo_s3_aggregation/async_grpo_s3_aggregation.py \
  --vllm-url http://127.0.0.1:8000 --teams-per-update 128 --updates 50 --concurrent-teams 128

To evaluate, serve the checkpoint with vllm serve and run the evaluation script, which writes one JSON line per team episode [3]:

Bash
python examples/async_grpo_s3_aggregation/evaluate.py --url http://127.0.0.1:8000 \
  --model Qwen3-0.6B-S3-Aggregation/checkpoint-50 --name ckpt50 --episodes 192

The example's defaults are a constant learning rate of 5e-7, group size 8, max_staleness 4, a checkpoint every 10 updates and 1,024 tokens per generation chunk; held-out problems use ids from 1,000,000 up [3]. To match the blog's own run, use 75 updates, 256 teams per update, checkpoint 75 and a 24-hour timeout, which is about three times the rollouts [1]. The blog run itself used one H200 for training and seven H200s for vLLM rollouts, with contexts up to 40,000 tokens [1].

What are the limits and open questions?

The main limit is that the task cannot test the question the series asks. It is synthetic and a single agent cannot solve it, so it does not yet compare a swarm against independent attempts at an equal budget; the authors defer that to a later post [1].

The numbers also come from different setups. The blog's 81.25% rests on 32 held-out problems, while the README's 60.9% rests on 192, and the authors did not keep held-out token measurements for their trained checkpoint, so the token savings come from training batches [1][3]. The post also says team behavior at 75 updates had not settled into a clean communication pattern [1].

Finally, this is a 0.6B model on a toy task. Neither the post nor the TRL example shows whether the same team reward works for agents that write code, do research or answer support tickets; the post calls itself Part 1 of a series, and the s³ paper's parallel-exploration results are the closest evidence so far [1][2].

Frequently asked questions

What is the s³ method for multi-agent reinforcement learning?

s³ (Simple Scaling of Swarms via Cooperative Multi-agent RL) is a method from a November 2026 arXiv paper in which agents learn for themselves when to work alone and when to share or read teammates' findings, with no predefined roles. Its authors report that roles emerge and that trained swarms generalize to larger teams.

How are the agents rewarded in the TRL swarm example?

The whole team gets one reward: success, reduced by up to 25% depending on how much of its 36,864-token allowance it used. A failed team gets zero, and sending messages earns nothing by itself.

What hardware do you need to train the swarm example?

Two GPUs: one serves Qwen3-0.6B with vLLM and one trains. The Hugging Face walkthrough uses an h200x2 job for about five hours at roughly $50, and TRL's reference run took about 4.8 hours on two H100s.

Does a trained agent team beat simply sampling more answers?

In the Hugging Face run, an untrained team with 8 attempts solved 37.5% of problems at about 103,000 tokens, while the trained team solved 82.3% in one attempt at about 8,000 tokens. The authors call this an estimate because it uses training problems.

What are the limits of the Hugging Face swarm experiment?

The task is synthetic and cannot be solved by a single agent, so it does not yet compare a swarm with independent attempts at an equal budget. The TRL code also differs from the paper, for example it has no KL penalty.

Sources

  1. Swarms, Flocks, Gangs: How to build, train, and evaluate multi-agent systems — Hugging Face, accessed
  2. s³: Simple Scaling of Swarms via Cooperative Multi-agent RL — arXiv, accessed
  3. TRL example: async_grpo_s3_aggregation — Hugging Face (GitHub), accessed