Skip to content

Commit

Permalink
[Config] New default config and test config
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Bettini <[email protected]>
  • Loading branch information
matteobettini committed Sep 19, 2023
1 parent eb1cfed commit 63f927c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 54 deletions.
20 changes: 11 additions & 9 deletions benchmarl/conf/experiment/base_experiment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,32 @@ defaults:

sampling_device: "cpu"
train_device: "cpu"

gamma: 0.99
polyak_tau: 0.005
lr: 0.00005
n_optimizer_steps: 45
collected_frames_per_batch: 60_000
n_envs_per_worker: 600
n_iters: 500
prefer_continuous_actions: True
clip_grad_norm: True
clip_grad_val: 40
clip_grad_val: 5
prefer_continuous_actions: True

collected_frames_per_batch: 6000
n_envs_per_worker: 10
n_iters: 500

on_policy_minibatch_size: 4096
on_policy_minibatch_size: 400

off_policy_memory_size: 100_000
off_policy_train_batch_size: 10_000
off_policy_prioritised_alpha: 0.7
off_policy_prioritised_beta: 0.5

evaluation: True
evaluation_interval: 30
evaluation_episodes: 200
evaluation_interval: 20
evaluation_episodes: 10

loggers: [wandb]
create_json: True

restore_file: null
checkpoint_interval: 100
checkpoint_interval: 50
33 changes: 0 additions & 33 deletions test/conf/experiment/base_experiment.yaml

This file was deleted.

20 changes: 20 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest

from benchmarl.experiment import ExperimentConfig


@pytest.fixture
def experiment_config() -> ExperimentConfig:
experiment_config: ExperimentConfig = ExperimentConfig.get_from_yaml()
experiment_config.n_iters = 3
experiment_config.n_optimizer_steps = 2
experiment_config.n_envs_per_worker = 2
experiment_config.collected_frames_per_batch = 100
experiment_config.on_policy_minibatch_size = 10
experiment_config.off_policy_memory_size = 200
experiment_config.off_policy_train_batch_size = 100
experiment_config.evaluation = False
experiment_config.loggers = []
experiment_config.create_json = False
experiment_config.checkpoint_interval = 0
return experiment_config
20 changes: 8 additions & 12 deletions test/test_algorithms.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import pathlib
import importlib

import pytest

from benchmarl.algorithms import algorithm_config_registry

from benchmarl.environments import VmasTask
from benchmarl.experiment import Experiment, ExperimentConfig
from benchmarl.experiment import Experiment
from benchmarl.models.common import SequenceModelConfig
from benchmarl.models.mlp import MlpConfig
from torch import nn


_has_vmas = importlib.util.find_spec("vmas") is not None


@pytest.mark.skipif(not _has_vmas, reason="VMAS not found")
@pytest.mark.parametrize("algo_config", algorithm_config_registry.values())
@pytest.mark.parametrize("continuous", [True, False])
def test_all_algos_balance(algo_config, continuous):
def test_all_algos_vmas(algo_config, continuous, experiment_config):
task = VmasTask.BALANCE.get_from_yaml()
model_config = SequenceModelConfig(
model_configs=[
Expand All @@ -21,14 +25,6 @@ def test_all_algos_balance(algo_config, continuous):
],
intermediate_sizes=[5],
)
experiment_config: ExperimentConfig = ExperimentConfig.get_from_yaml(
str(
pathlib.Path(__file__).parent
/ "conf"
/ "experiment"
/ "base_experiment.yaml"
)
)
experiment_config.prefer_continuous_actions = continuous

experiment = Experiment(
Expand Down

0 comments on commit 63f927c

Please sign in to comment.