Skip to content

Async rl - #273

Draft
meichangsu1 wants to merge 19 commits into
modelscope:mainfrom
meichangsu1:async-rl
Draft

Async rl#273
meichangsu1 wants to merge 19 commits into
modelscope:mainfrom
meichangsu1:async-rl

Conversation

@meichangsu1

Copy link
Copy Markdown
Collaborator

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

本 PR 新增多租户异步 RL 能力,同时支持 YAML 管理的 CLI 模式和客户端编排的 C/S 模式。

主要改动如下:

  • 新增 YAML 管理的异步多 LoRA GRPO 流程:

    • 多个租户共享训练模型、vLLM Sampler 和 TransferQueue 数据面。
    • Rollout、Advantage 计算和训练由独立 Worker 异步执行。
    • 每个租户可独立配置 Dataset、Reward、Optimizer、Scheduler 和 Rollout 参数。
    • 支持 Partition admission 和可配置的 Policy Staleness。
    • 一个完整 Prompt Group 生成后即可进入训练,无需等待整个 Partition 完成。
    • Partition 内全部 Mini-batch 训练完成后,统一发布新的 Policy Version。
  • 新增客户端编排的异步 GRPO:

    • 通过 Client SDK 暴露异步 Sampler 和 Model 操作。
    • 增加 DataPlane 和 DataRef API,用于传递 Rollout 与训练数据。
    • 复用服务端 TaskQueue 完成多租户任务准入和调度。
    • 支持同一客户端的 Rollout 和训练任务并发执行。
    • 每次 Optimizer Step 后打印 Loss、Gradient Norm 等训练指标。
  • 新增 Dynamic Micro-batching:

    • 支持按样本数量或 Token 数量切分 Micro-batch。
    • 通过 micro_batch_scale() 保持不同 Loss 的归约语义。
    • 支持 GRPO、DPO、Cross Entropy 和 Chunked Cross Entropy Loss。
    • 保证开启或关闭 Dynamic Batching 时,最终 Loss 定义保持一致。
  • 新增异步 RL 运行组件:

    • LoRA Context 和 Policy Version 管理。
    • Rollout、Advantage 和 Trainer Worker。
    • 原生 TransferQueue 集成。
    • 多租户 Scheduler 和 Staleness 控制。
    • 异步训练指标采集与输出。
    • vLLM 异步生成和 LoRA Policy Snapshot 加载。
  • 新增 C/S 服务端能力:

    • DataPlane Deployment 和 Proxy。
    • 基于 DataPlane 的 Model 和 Sampler 接口。
    • TaskQueue 异步任务执行与结果查询。
    • 公共的 Rollout Row 和 Tensor 转换工具。
  • 改进 Ray GPU 资源管理:

    • 正确发现 Placement Group 预留的 GPU。
    • 避免额外申请 Fractional GPU 导致设备编号被二次转换。
    • 减少 GPU Placement Group 不必要的 CPU 资源预留。
  • 新增 Reward 和 Metrics:

    • GSM8K Accuracy Reward。
    • Boxed Math 和 DAPO Math Reward。
    • Buffered JSONL 和可选 SwanLab 指标上报。
  • 新增 Cookbook 示例:

    • cookbook/rl/async_rl:YAML 管理的多 LoRA 异步 GRPO。
    • cookbook/client/async_rl:基于 Qwen3.5-4B 的客户端编排异步 GRPO。
    • 配套的 Server 配置、启动脚本和使用文档。

Experiment results

功能测试结果:

- Rename low-level component methods to match new API (e.g., `submit_sample` → `sample_to_data_plane`, `submit_forward_only` → `forward_only`)
- Clarify that token tensors and log-probabilities remain server-side in async RL flow
- Add `TWINKLE_TEMPLATE_MODEL_ID` environment variable for DPO template configuration
- Remove `_extract_ref_outputs` helper as it's no longer needed with updated API
…trated-async-rl

# Conflicts:
#	src/twinkle/metric/__init__.py
#	src/twinkle/model/__init__.py
#	src/twinkle/sampler/vllm_sampler/vllm_sampler.py
#	src/twinkle/server/model/twinkle_handlers.py
#	src/twinkle/server/sampler/tinker_handlers.py
@meichangsu1
meichangsu1 marked this pull request as draft August 24, 2026 06:46
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