[问题/Issue] 章节11.1.5:GRPO batch_size=2 的整除关系注释有误

Author: welkinhuangCreated Sep 1, 2026Updated Sep 1, 2026
Labelsdocumentation

1. 遇到问题的章节 / Affected Chapter

Chapter11.1.5

2. 问题类型 / Issue Type

内容错误 / Content Error

3. 具体问题描述 / Problem Description

在第 11.1.5 节的 GRPO 示例中:

"batch_size": 2, # 必须能被num_generations(8)整除,使用2

这里的注释表述似乎有误。按字面理解是 batch_size 需要能被 num_generations 整除,但 2 % 8 != 0。

实际应当是 effective batch size 满足与 num_generations 的整除关系。当前配置下,由于还存在 gradient_accumulation_steps,batch_size=2 本身可以是合理的

4. 问题重现材料 / Reproduction Materials

import sys import json

from hello_agents.tools import RLTrainingTool

创建RL训练工具

rl_tool = RLTrainingTool()

1. 快速测试:SFT训练(10个样本,1个epoch)

sft_result_str = rl_tool.run({ "action": "train", "algorithm": "sft", "model_name": "Qwen/Qwen3-0.6B", "output_dir": "./models/quick_test_sft", "max_samples": 10, # 只用10个样本快速测试 "num_epochs": 1, # 只训练1轮 "batch_size": 2, "use_lora": True # 使用LoRA加速训练 })

sft_result = json.loads(sft_result_str) print(f"\n✓ SFT训练完成,模型保存在: {sft_result['output_dir']}")

2. GRPO训练(5个样本,1个epoch)

grpo_result_str = rl_tool.run({ "action": "train", "algorithm": "grpo", "model_name": "Qwen/Qwen3-0.6B", # 使用基础模型 "output_dir": "./models/quick_test_grpo", "max_samples": 5, # 只用5个样本快速测试 "num_epochs": 1, "batch_size": 2, # 必须能被num_generations(8)整除,使用2 #######issue提及问题在此处####### "use_lora": True })

5. 补充信息 / Additional Information

No response

确认事项 / Verification

  • 我已阅读过相关章节的文档 / I have read the relevant chapter documentation
  • 我已搜索过现有的Issues,确认此问题未被报告 / I have searched existing Issues and confirmed this hasn't been reported
  • 我已尝试过基本的故障排除(如重启、重新安装依赖等) / I have tried basic troubleshooting (restart, reinstall dependencies, etc.)

Source: datawhalechina/hello-agents