Skip to content

fix(gigpo): match anchor states within each task - #637

Open
flyingdoubleG wants to merge 1 commit into
agentscope-ai:mainfrom
flyingdoubleG:fix/gigpo-anchor-per-task
Open

flyingdoubleG wants to merge 1 commit into
agentscope-ai:mainfrom
flyingdoubleG:fix/gigpo-anchor-per-task

Conversation

@flyingdoubleG

Copy link
Copy Markdown

Description

Problem. GiGPO's step-level advantage compares the discounted returns of steps that reach the same anchor state within one group of trajectories of the same task. The reference implementation (build_step_group in gigpo/core_gigpo.py of verl-agent) first groups by episode group (index), then clusters identical observations inside each group.

GiGPOAdvantageFn.process builds the anchor buckets over the whole batch, keyed only by info["env_state_hash"]:

anchor_buckets.setdefault(str(state_hash), []).append((exp, r_t))

The ALFWorld workflow hashes the formatted observation text, so generic observations such as Observation: Nothing happens. (or "On the countertop 1, you see nothing.") get the same hash in every task. Steps from different tasks, whose returns refer to different goals and horizons, are then normalized together, and their A^S depends on which other tasks happen to be in the batch.

Change. Key the buckets by (eid.tid, state_hash), i.e. match anchor states within each task group as in GiGPO. Docstring updated accordingly.

Tests. tests/algorithm/test_gigpo_advantage.py::test_anchor_states_are_not_shared_across_tasks: the same hash appears once in each of two tasks (one run succeeds after it, the other fails); there must be no anchor group of size > 1 and the advantages must equal the episode-only ones (omega=0). It fails before the change; the file passes after (10 tests, CPU).

Checklist

  • Code has passed all tests
  • Docstrings have been added/updated in Google Style
  • Documentation has been updated
  • Code is ready for review

🤖 Generated with Claude Code

GiGPO's step-level advantage compares discounted returns of steps that
reach the same anchor state within one group of trajectories of the
same task (build_step_group in the reference implementation groups by
episode group first, then by observation). GiGPOAdvantageFn bucketed
steps by env_state_hash over the whole batch, so identical observations
from different tasks, e.g. ALFWorld's "Nothing happens." (the hash is
taken over the formatted observation), were normalized together
although their returns refer to different goals.

Key the anchor buckets by (task id, state hash) and add a test with the
same observation in two tasks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant