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
36 changes: 36 additions & 0 deletions .github/workflows/unit_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Unit Test

on:
pull_request:


jobs:
unit_tests:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Setup conda env
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
miniconda-version: "latest"
activate-environment: test
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: |
python -m pip install -e ".[dev]"
# Will have to pin until monarch wheel is reasonable
pip install torch==2.9.0.dev20250815+cpu --index-url https://download.pytorch.org/whl/nightly/cpu
python -m pip install --no-build-isolation --verbose assets/wheels/monarch_no_torch-0.1.0.dev20250815-py3-none-any.whl
- name: Run unit tests with coverage
# TODO add all tests
run: pytest tests/unit_tests --cov=. --cov-report=xml --durations=20 -vv
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
Expand Down
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ repos:
- id: check-merge-conflict
- id: no-commit-to-branch
args: ['--branch=main']
- id: check-added-large-files
args: ['--maxkb=1000']
- id: end-of-file-fixer
exclude: '^(.*\.svg)$'

Expand Down
38 changes: 3 additions & 35 deletions apps/toy_rl/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import torch
from forge.actors.collector import Collector

from forge.controller.stack import stack
from forge.data.replay_buffer import ReplayBuffer
from forge.interfaces import Environment, Policy
from forge.types import Action, Observation, State
Expand Down Expand Up @@ -150,7 +149,8 @@ async def main():
# This policy just generates something between -2. and 2.
policy = await policy_procs.spawn("policy", ToyPolicy, action_range=(-2.0, 2.0))

browser_collectors = await browser_procs.spawn(
# TODO - replace multiple collectors with a service.
collectors = await browser_procs.spawn(
"browser",
Collector,
max_collector_steps=5,
Expand All @@ -162,29 +162,6 @@ async def main():
# to do it this way.
environment_creator=partial(ToyEnvironment, name="browser", max_steps=5),
)
deep_research_collectors = await deep_research_procs.spawn(
"deep_research",
Collector,
max_collector_steps=5,
policy=policy,
replay_buffer=replay_buffer,
environment_creator=partial(ToyEnvironment, name="deep_research", max_steps=5),
)
coding_collectors = await coder_procs.spawn(
"coding",
Collector,
max_collector_steps=5,
policy=policy,
replay_buffer=replay_buffer,
environment_creator=partial(ToyEnvironment, name="coding", max_steps=5),
)

collectors = stack(
browser_collectors,
deep_research_collectors,
coding_collectors,
interface=Collector,
)

# Create two async tasks
async def episode_collector_task():
Expand All @@ -193,16 +170,7 @@ async def episode_collector_task():
while True:
try:
print(f"🎮 Running episode {episode_count + 1}...")

# call() is essentially our "map" - every collector runs their own
# episode loop.
# What's pretty elegant here is if we wanted to control off policiness, we could
# easily counter on steps and call policy.update_weights.call() at our desired
# frequency.
results = collectors.run_episode.call()

# Temporary hack due to Monarch changes - ideally you could just await results
results = [await r for r in results]
results = await collectors.run_episode.call()
num_trajectories = sum([len(r._values) for r in results])
episode_count += 1
print(
Expand Down
1 change: 1 addition & 0 deletions assets/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
Binary file not shown.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies = [
# PyTorch
"torchdata>=0.8.0",
"torchtitan",
"torchao",
# vLLM
# TODO: pin specific vllm version
#"vllm==0.10.0",
Expand All @@ -36,6 +37,7 @@ dev = [
"pytest-cov",
"pytest-timeout",
"tensorboard",
"expecttest",
"tomli>=1.1.0",
"anyio",
"pytest-asyncio",
Expand Down
3 changes: 1 addition & 2 deletions src/forge/actors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
# LICENSE file in the root directory of this source tree.

from .collector import Collector
from .policy import Policy, PolicyRouter

__all__ = ["Collector", "Policy", "PolicyRouter"]
__all__ = ["Collector"]
2 changes: 0 additions & 2 deletions src/forge/controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from .recoverable_mesh import RecoverableProcMesh
from .service import AutoscalingConfig, Service, ServiceConfig
from .spawn import spawn_service
from .stack import stack

__all__ = [
"AutoscalingConfig",
Expand All @@ -19,5 +18,4 @@
"get_proc_mesh",
"ForgeActor",
"RecoverableProcMesh",
"stack",
]
237 changes: 0 additions & 237 deletions src/forge/controller/stack.py

This file was deleted.

Loading
Loading