From bbbf51e6a0f258ed33a8114a0a7dfb285c0686dd Mon Sep 17 00:00:00 2001 From: Sven Mika Date: Mon, 27 May 2024 10:12:35 +0200 Subject: [PATCH] [RLlib] Fix metrics bug (wrt individual agent returns) in `MultiAgentEnvRunner`. (#45543) --- rllib/env/multi_agent_env_runner.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rllib/env/multi_agent_env_runner.py b/rllib/env/multi_agent_env_runner.py index 043083aaa11a..ddad8b123815 100644 --- a/rllib/env/multi_agent_env_runner.py +++ b/rllib/env/multi_agent_env_runner.py @@ -610,8 +610,9 @@ def get_metrics(self) -> ResultDict: episode_return += return_eps2 episode_duration_s += eps2.get_duration_s() for sa_eps in eps2.agent_episodes.values(): - agent_episode_returns[str(sa_eps.agent_id)] += return_eps2 - module_episode_returns[sa_eps.module_id] += return_eps2 + return_sa = sa_eps.get_return() + agent_episode_returns[str(sa_eps.agent_id)] += return_sa + module_episode_returns[sa_eps.module_id] += return_sa del self._ongoing_episodes_for_metrics[eps.id_] self._log_episode_metrics(