Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 0 additions & 10 deletions apps/rl/llama3_8b.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ trainer:
flavor: 8B
tokenizer_path: /tmp/Meta-Llama-3.1-8B-Instruct

processes:
scheduler: local # local | mast (not supported yet)
num_hosts: 1
with_gpus: True
num_procs: 4

optimizer:
name: AdamW
Expand Down Expand Up @@ -65,11 +60,6 @@ replay_buffer:
batch_size: 2
max_policy_age: 2
seed: None
processes:
scheduler: local # local | mast (not supported yet)
num_hosts: 1
with_gpus: False
num_procs: 1

# policy:
# scheduler:
Expand Down
37 changes: 13 additions & 24 deletions apps/rl/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,31 @@
import sys

from forge.actors import ReplayBuffer, RLTrainer

from forge.cli.config import parse
from forge.controller import spawn_actors
from forge.controller.service import ServiceConfig, shutdown_service, spawn_service
from omegaconf import DictConfig

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


async def run(cfg: DictConfig):
trainer, buffer = await asyncio.gather(
spawn_actors(
name="trainer",
actor_cls=RLTrainer,
cfg=cfg.trainer,
processes=cfg.trainer.pop("processes"),
set_address=True,
),
spawn_actors(
name="replay_buffer",
actor_cls=ReplayBuffer,
cfg=cfg.replay_buffer,
processes=cfg.replay_buffer.pop("processes"),
),
)
print("Actors spawned")

# Initialize everything
await asyncio.gather(
buffer.setup.call(),
trainer.setup.call(),
trainer = await spawn_service(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should still be in a asyncio.gather

ServiceConfig(procs_per_replica=1, with_gpus=True, num_replicas=4),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still could have been sourced from the config with ServiceConfig(**cfg.trainer.pop("service")) but we don't have to change that for this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add as part of next integration test PR. Did not occur to me that the yaml obj get parsed into a regular python dict. thanks.

RLTrainer,
**cfg.trainer,
)
replay_buffer = await spawn_service(
ServiceConfig(procs_per_replica=1, num_replicas=1),
ReplayBuffer,
**cfg.replay_buffer,
)
print("Setup done")
print("Services initialized....")

print("shutting down...")
await asyncio.gather(*[a.mesh.stop() for a in [trainer]])
await shutdown_service(trainer)
await shutdown_service(replay_buffer)


@parse
Expand Down
Loading