Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 6 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
</p> -->

<h1 align="center">
Dr. MAS: Stable Reinforcement Learning for Multi-Agent LLM Systems</b>
Dr. MAS: Stable Reinforcement Learning for Multi-Agent LLM Systems
</h1>


<p align="center">
<!-- <a href="https://arxiv.org/abs/2505.10978">
<img src="https://img.shields.io/badge/arXiv-Paper-red?style=flat-square&logo=arxiv" alt="arXiv Paper"></a>
&nbsp; -->
<a href="https://github.com/langfengQ/DrMAS">
<img src="https://img.shields.io/badge/arXiv-Coming%20Soon-red?style=flat-square&logo=arxiv" alt="arXiv Coming Soon"></a>
&nbsp;
<a href="https://github.com/langfengQ/DrMAS">
<img src="https://img.shields.io/badge/GitHub-Project-181717?style=flat-square&logo=github" alt="GitHub Project"></a>
&nbsp;
Expand Down Expand Up @@ -50,7 +50,7 @@ This framework features **flexible agent registry**, **customizable multi-agent
- [Run Examples](#run-examples)
- [Search](#search)
- [Math](#math)
- [Usage Guide](#usage-guide)
- [Multi-Agent Development Guide](#multi-agent-development-guide)
- [Acknowledgement](#acknowledgement)

# Installation
Expand Down Expand Up @@ -172,7 +172,7 @@ bash examples/drmas_trainer/run_math.sh eval # Dr.MAS
bash examples/grpo_trainer/run_math.sh eval # GRPO
```

# Usage Guide
# Multi-Agent Development Guide

For a **comprehensive guide** on developing custom multi-agent LLM systems, including detailed examples and best practices, see the **[Multi-Agent Development Guide](./docs/MULTI_AGENT_DEVELOPMENT_GUIDE.md)**.

Expand All @@ -181,70 +181,7 @@ The guide covers:
- Step-by-step agent creation and registration
- Orchestra development patterns
- Configuration options and per-agent parameter overrides
<!--
## Quick Start: Register Custom Agents

1. **Create Agent Class**: Inherit from [BaseAgent](./agent_system/agent/agents/base.py#L13) and implement the `call` method:

```python
@AgentRegistry.register("Custom Agent")
class CustomAgent(BaseAgent):
def __init__(self, wg_id: str, tokenizer, processor, config):
super().__init__("Custom Agent", MY_PROMPT, wg_id, tokenizer, processor, config)

def call(self, gen_batch: DataProto, env_obs: Dict[str, Any],
team_context: List[str], actor_rollout_wg,
agent_active_mask, step: int) -> Tuple[DataProto, List[str]]:
# Build prompt, generate with LLM, parse output
...
```

2. **Import Agent Module** in the orchestra's `__init__`:

```python
import importlib
importlib.import_module("agent_system.agent.agents.my_agent_module")
```

## Quick Start: Create Custom Orchestras

1. **Create Orchestra Class**: Inherit from [BaseOrchestra](./agent_system/agent/orchestra/base.py#L53):

```python
class MyOrchestra(BaseOrchestra):
def __init__(self, agent_ids, model_ids, agents_to_wg_mapping, tokenizers, processors, config):
importlib.import_module("agent_system.agent.agents.my_agents")
super().__init__(agent_ids, model_ids, agents_to_wg_mapping, tokenizers, processors, config)

def run(self, gen_batch, env_obs, actor_rollout_wgs, active_masks, step):
# Define the execution flow of agents
...
```

2. **Register Orchestra** in [rollout_loop.py](./agent_system/multi_turn_rollout/rollout_loop.py#L381):

```python
if orchestra_type == "my_orchestra":
from agent_system.agent.orchestra.my_orchestra import MyOrchestra as orchestra
```

## Agent Configuration

```yaml
agent:
multi_agent: True
agent_ids: ["Agent 1", "Agent 2", "Agent 3"]
model_ids: ["model/path/1", "model/path/2", "model/path/3"]
model_sharing: False # False = dedicated LLM per agent
orchestra_type: search # "search", "math", or your custom type

# Per-agent parameter overrides (order matches agent_ids)
agent_specific_parameters:
actor.optim.lr: [1e-6, 1e-6, 1e-7]
actor.ppo_micro_batch_size_per_gpu: [4, 8, 8]
```

For detailed examples and advanced patterns, see the **[Multi-Agent Development Guide](./docs/MULTI_AGENT_DEVELOPMENT_GUIDE.md)**. -->

# Acknowledgement

Expand Down
2 changes: 1 addition & 1 deletion examples/dapo_trainer/run_math.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ max_loop_num=2

# Agent-specific parameter override (only support actor_rollout_ref)
actor_optim_lr='[1e-6,1e-6]'
actor_ppo_micro_batch_size_per_gpu='[2,2]'
actor_ppo_micro_batch_size_per_gpu='[4,4]'

####################### Other Configurations #####################

Expand Down
5 changes: 2 additions & 3 deletions examples/drmas_trainer/run_math.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ max_loop_num=2

# Agent-specific parameter override (only support actor_rollout_ref)
actor_optim_lr='[1e-6,1e-6]'
actor_ppo_micro_batch_size_per_gpu='[2,2]'

actor_ppo_micro_batch_size_per_gpu='[4,4]'

model_name_tag=$(jq -r '.[]' <<< "$model_ids" | awk -F/ '{print $NF}' | tr '[:upper:]' '[:lower:]' | tr '-' '_' | paste -sd_)

Expand Down Expand Up @@ -69,7 +68,7 @@ python3 -m verl.trainer.main_ppo \
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=8 \
actor_rollout_ref.rollout.tensor_model_parallel_size=1 \
actor_rollout_ref.rollout.name=sglang \
actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \
actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
actor_rollout_ref.rollout.enable_chunked_prefill=False \
actor_rollout_ref.rollout.enforce_eager=False \
actor_rollout_ref.rollout.free_cache_engine=False \
Expand Down
2 changes: 1 addition & 1 deletion examples/gigpo_trainer/run_math.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ max_loop_num=2

# Agent-specific parameter override (only support actor_rollout_ref)
actor_optim_lr='[1e-6,1e-6]'
actor_ppo_micro_batch_size_per_gpu='[2,2]'
actor_ppo_micro_batch_size_per_gpu='[4,4]'

####################### Other Configurations #####################

Expand Down
4 changes: 2 additions & 2 deletions examples/grpo_trainer/run_math.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ max_loop_num=2

# Agent-specific parameter override (only support actor_rollout_ref)
actor_optim_lr='[1e-6,1e-6]'
actor_ppo_micro_batch_size_per_gpu='[2,2]'
actor_ppo_micro_batch_size_per_gpu='[4,4]'

####################### Other Configurations #####################

Expand Down Expand Up @@ -69,7 +69,7 @@ python3 -m verl.trainer.main_ppo \
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=8 \
actor_rollout_ref.rollout.tensor_model_parallel_size=1 \
actor_rollout_ref.rollout.name=sglang \
actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \
actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
actor_rollout_ref.rollout.enable_chunked_prefill=False \
actor_rollout_ref.rollout.enforce_eager=False \
actor_rollout_ref.rollout.free_cache_engine=False \
Expand Down
2 changes: 1 addition & 1 deletion examples/ppo_trainer/run_math.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ max_loop_num=2

# Agent-specific parameter override (only support actor_rollout_ref)
actor_optim_lr='[1e-6,1e-6]'
actor_ppo_micro_batch_size_per_gpu='[2,2]'
actor_ppo_micro_batch_size_per_gpu='[4,4]'

####################### Other Configurations #####################

Expand Down
2 changes: 1 addition & 1 deletion examples/rloo_trainer/run_math.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ max_loop_num=2

# Agent-specific parameter override (only support actor_rollout_ref)
actor_optim_lr='[1e-6,1e-6]'
actor_ppo_micro_batch_size_per_gpu='[2,2]'
actor_ppo_micro_batch_size_per_gpu='[4,4]'

####################### Other Configurations #####################

Expand Down
1 change: 1 addition & 0 deletions verl/trainer/ppo/core_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ def compute_grpo_outcome_advantage(
Returns: `(torch.Tensor)`
shape is (bs, response_length)
"""
print("group_by_agent_id: ", group_by_agent_id)
scores = token_level_rewards.sum(dim=-1)

id2score = defaultdict(list)
Expand Down