Add GSM8KEnv and GSM8KAgent for Tunix agentic RL - #2022
Open
andytwigg wants to merge 2 commits into
Open
Conversation
Introduce a modular, self-contained GSM8K environment and agent implementation
for the Tunix Agentic RL framework, following the pattern in FrozenLakeEnv:
- examples/math_gsm8k/env.py: Implements GSM8KEnv (subclassing BaseTaskEnv)
with problem prompt formatting, bracket-matching answer extraction, XML
reasoning/answer tag validation, and composite rewards (format + accuracy).
- examples/math_gsm8k/agent.py: Implements GSM8KAgent (subclassing
ConversationAgentBase) managing dialogue history and step trajectories.
- examples/math_gsm8k/data.py: Provides GSM8K dataset loaders supporting
Hugging Face ('openai/gsm8k'), TFDS, and smoke test fallback.
- examples/math_gsm8k/env_test.py: Comprehensive unit tests covering answer
extraction, format scoring, environment lifecycle, and agent interaction.
TAG=agy
CONV=2907f211-714a-4e9c-b009-de21347c291a
andytwigg
requested review from
abheesht17,
hgao327,
jiangyangmu,
lc5211,
s-noghabi,
sizhit2,
tianshub and
wang2yn84
as code owners
August 28, 2026 00:01
Adds an agentic GRPO training entrypoint script for GSM8K on TPU using Qwen3-1.7B, following the pattern of train_frozenlake_qwen3.py: - Integrates GSM8KEnv and GSM8KAgent with GRPOLearner and RLEngine. - Configures ModelConfig.qwen3_1p7b() with bf16 reference and fp32 actor. - Supports both full-parameter and LoRA fine-tuning. - Supports vLLM and vanilla rollout engines on shared or distributed mesh. - Logs step-by-step math reasoning metrics (solve ratio, format ratio, reward). TAG=agy CONV=2907f211-714a-4e9c-b009-de21347c291a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a modular
GSM8KEnvenvironment,GSM8KAgentagent, and an end-to-end training entrypoint scripttrain_gsm8k_qwen3.pyfor Qwen3-1.7B for the Tunix Agentic RL framework, matching the architecture and conventions established inexamples/frozenlake/.Changes Included
examples/math_gsm8k/env.py:GSM8KEnv: SubclassesBaseTaskEnvto manage mathematical reasoning tasks.extract_hash_answer(... #### <num>).\boxed{...}answers using stack-based bracket matching with robust fallbacks.from_dict().examples/math_gsm8k/agent.py:GSM8KAgent: SubclassesConversationAgentBaseto maintain dialogue history and step-by-step reasoning trajectories for GRPO training.examples/math_gsm8k/data.py:openai/gsm8k), TFDS, and in-memory smoke-testing.examples/math_gsm8k/env_test.py:examples/math_gsm8k/train_gsm8k_qwen3.py:GSM8KEnvandGSM8KAgentwithGRPOLearnerandRLEngine.ModelConfig.qwen3_1p7b()with bf16 reference and fp32 actor (supporting full fine-tuning and LoRA).TAG=agy
CONV=2907f211-714a-4e9c-b009-de21347c291a