Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add distributed mode benchmark #328

Closed
wants to merge 8 commits into from
Closed
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
33 changes: 33 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: AgentScope Benchmark

on: [push, pull_request]
permissions:
contents: write

jobs:
bench:
permissions:
contents: write
runs-on: ${{ matrix.os }}
strategy:
fail-fast: True
matrix:
os: [ubuntu-latest]
env:
OS: ${{ matrix.os }}
PYTHON: '3.9'
steps:
- uses: actions/checkout@master
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: 3.9
- name: Install AgentScope
run: |
pip install -q -e .[distribute]
pip install pytest pytest-benchmark
- name: Run bench
run: |
cd examples/distributed_simulation
pytest bench.py --benchmark-json output.json
cat output.json| jq -r ".benchmarks[] | .stats"
49 changes: 49 additions & 0 deletions examples/distributed_simulation/bench.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
"""Simulation benchmark

Please install pytest and pytest-benchmark to run this benchmark.
"""

import pytest # pylint: disable=W0611
from participant import Moderator, RandomParticipant, LLMParticipant
from main import run_main_process # pylint: disable=E0611
import agentscope
from agentscope.server import RpcAgentServerLauncher


def test_simulation(benchmark): # type: ignore[no-untyped-def]
"""A single benchmark for the simulation"""
base_port = 23300
par_server_num = 4
mod_server_num = 1
agentscope.init(
project="simulation",
name="server",
save_code=False,
save_api_invoke=False,
model_configs="configs/model_configs.json",
use_monitor=False,
)
launchers = []
for i in range(par_server_num + mod_server_num):
launcher = RpcAgentServerLauncher(
host="localhost",
port=base_port + i,
custom_agents=[Moderator, RandomParticipant, LLMParticipant],
)
launcher.launch()
launchers.append(launcher)
benchmark(
run_main_process,
hosts=["localhost"],
base_port=23300,
server_per_host=4,
model_per_host=1,
participant_num=400,
moderator_per_host=1,
agent_type="random",
max_value=100,
sleep_time=1.0,
)
for launcher in launchers:
launcher.shutdown()