trainer.rollout_data_dir: TypeError: Object of type bool_ is not JSON serializable
System Info
When enabling trainer.rollout_data_dir, error happened in dumping data TypeError: Object of type bool_ is not JSON serializable
Information
- [ ] The official example scripts
- [ ] My own modified scripts
Tasks
- [ ] An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below)
Reproduction
verl main (dcb871f3) sglang v0.5.7
Expected behavior
TypeError: Object of type bool_ is not JSON serializable
I fixed this and opened PR #5810: https://github.com/verl-project/verl/pull/5810
The fix normalizes numpy-backed rollout metadata before writing rollout_data_dir JSONL entries, so values like numpy.bool_, np.int64, and nested ndarray content no longer fail json.dumps(...).
I also added CPU tests covering both the recursive conversion helper and _dump_generations writing a real JSONL file with numpy metadata.
中文:这个 issue 中报告的 trainer.rollout_data_dir 写 JSONL 时遇到 numpy.bool_ 无法序列化的问题,当前看起来已经由后续合并的修复覆盖了。
证据:
- #6062 已合并,并明确说明为
json.dumps增加default=strfallback,用于修复 numpy 2.x 下numpy.bool_不再是 Pythonbool子类导致的 JSON 序列化崩溃:https://github.com/verl-project/verl/pull/6062 - #6167 已合并,并在
RayPPOTrainer._log_rollout_data边界将 numpy-backedreward_extra_infos_dict转为 native/list 数据,避免 numpy typed values 直接进入 rollout JSON dump:https://github.com/verl-project/verl/pull/6167 - 当前
verl/trainer/ppo/ray_trainer.py中,rollout dump 路径已经包含.tolist()转换和json.dumps(..., default=str)fallback。
因此我认为这个 issue 可以按已修复关闭。如果仍然需要保证嵌套 numpy 标量/数组在 JSONL 中保持原生 bool/int/list 类型而不是 fallback 字符串,可以继续在 #5810 跟进更严格的递归转换和测试:https://github.com/verl-project/verl/pull/5810
English: The trainer.rollout_data_dir JSONL dumping failure reported here appears to be covered by later merged fixes.
Evidence:
- #6062 was merged and explicitly added a
default=strfallback tojson.dumpsfor the numpy 2.xnumpy.bool_serialization crash: https://github.com/verl-project/verl/pull/6062 - #6167 was merged and converts numpy-backed
reward_extra_infos_dictvalues at theRayPPOTrainer._log_rollout_databoundary before rollout JSON dumping: https://github.com/verl-project/verl/pull/6167 - The current
verl/trainer/ppo/ray_trainer.pyrollout dump path now contains both the.tolist()boundary conversion and thejson.dumps(..., default=str)fallback.
So this issue looks safe to close as fixed. If stricter native-type preservation for nested numpy scalars/arrays is still desired, that can continue in #5810: https://github.com/verl-project/verl/pull/5810
This response was generated by a scheduled Codex GPT5.5 issue processing task.