Skip to content

Add comprehensive ReplyBuffer analysis with class diagrams and sequence diagrams#1

Draft
zhshgmail with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-46af864a-4a9a-449f-a5c8-cdfefab99f48
Draft

Add comprehensive ReplyBuffer analysis with class diagrams and sequence diagrams#1
zhshgmail with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-46af864a-4a9a-449f-a5c8-cdfefab99f48

Conversation

Copilot AI commented Jul 8, 2025

Copy link
Copy Markdown

This PR provides a detailed analysis of the ReplyBuffer (AsyncIOSequenceBuffer) implementation in AReaL, including comprehensive class diagrams and sequence diagrams to illustrate its architecture and behavior.

📋 Analysis Overview

The ReplyBuffer is a critical component in AReaL's asynchronous reinforcement learning system, managing data flow between rollout workers, reward services, and trainer workers. This analysis documents its sophisticated design and operation.

🏗️ Architecture Highlights

The ReplyBuffer implementation features a three-tier architecture:

  1. AsyncIOSequenceBuffer - Public async interface with concurrency control
  2. _TensorDictSequenceBuffer - Internal storage implementation
  3. _ReplayEntry - Individual data entry structure

🔄 Key Features Documented

  • Asynchronous Operations: Full async/await support using asyncio.Condition
  • Concurrent Access: Multiple readers and writers with sophisticated state management
  • Memory Efficiency: Fixed-size buffers with reuse counting mechanism
  • RPC Integration: Intelligent dependency resolution for multiple RPC operations
  • State Management: Five mutually exclusive states ensuring thread safety

📊 Documentation Created

Analysis Documents

  • docs/buffer_analysis.md - Comprehensive Chinese analysis
  • docs/buffer_analysis_en.md - Comprehensive English analysis
  • BUFFER_ANALYSIS_SUMMARY.md - Executive summary

Visual Diagrams

  • Class Diagram: Shows relationships between AsyncIOSequenceBuffer, _TensorDictSequenceBuffer, and _ReplayEntry
  • Sequence Diagrams: Detailed flows for:
    • put_batch - Data insertion workflow
    • amend_batch - Data modification workflow
    • get_batch_for_rpc - Data retrieval for RPC operations

Diagram Formats

  • Mermaid: Embedded in markdown for GitHub viewing
  • PlantUML: Standalone files for external rendering

🎯 Key Operations Documented

Buffer State Management

The buffer maintains five mutually exclusive states using numpy arrays:

  • _is_being_put - Entry being written
  • _is_being_amended - Entry being modified
  • _is_being_read - Entry being read
  • _is_idle - Entry available for operations
  • _is_empty - Entry slot is empty

Concurrency Control

  • Uses asyncio.Condition for asynchronous synchronization
  • Supports concurrent readers and amenders through reference counting
  • FIFO data processing based on birth timestamps

💡 Design Benefits

  1. High Performance: O(1) state operations with numpy arrays
  2. Thread Safety: Comprehensive state validation and atomic operations
  3. Scalability: Support for multiple concurrent RPC operations
  4. Memory Efficiency: Automatic cleanup based on reuse counting

This documentation provides both Chinese and English comprehensive analysis suitable for developers working with AReaL's buffer system.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: zhshgmail <126103537+zhshgmail@users.noreply.github.com>
Copilot AI changed the title [WIP] 请分析下ReplyBuffer在Areal中的实现,画出类图和时序图 Add comprehensive ReplyBuffer analysis with class diagrams and sequence diagrams Jul 8, 2025
Copilot AI requested a review from zhshgmail July 8, 2025 21:59
zhshgmail pushed a commit that referenced this pull request Aug 6, 2025
* PullRequest: 293 fix get_param_realloc_path

Merge branch xss/debug of git@code.alipay.com:inclusionAI/AReaL.git into gh
https://code.alipay.com/inclusionAI/AReaL/pull_requests/293

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* fix get_param_realloc_path

* PullRequest: 297 bugfix: reward is always -5

Merge branch xss/debug of git@code.alipay.com:inclusionAI/AReaL.git into gh
https://code.alipay.com/inclusionAI/AReaL/pull_requests/297

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* bugfix: reward is always -5

* PullRequest: 321 fix checkpoint save dir

Merge branch xss/debug of git@code.alipay.com:inclusionAI/AReaL.git into gh
https://code.alipay.com/inclusionAI/AReaL/pull_requests/321

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* fix checkpoint save dir

* add api

* add directory structure

* add tests template

* format

* checkout previous impl

* checkout previous implementations

* checkout prev impl

* add remote sglang engine

* format

* add readme

* PullRequest: 331 [lite] Support remote sglang engine with corresponding testcases.

Merge branch fw/lite of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/331

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* add test for sglang remote engine
* fix

* PullRequest: 336 add wrapper

Merge branch lite-util-wrapper of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/336

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add wrapper

* PullRequest: 332 [lite] Support FSDP engines

Merge branch mzy/lite/engines of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/332

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* fsdp2 engine
* fix utils
* add fsdp engine test
* .
* fsdp engine test passed
* unsqueeze immediately before model inputs and after model outputts
* add optimizer save/load, add position id calculation for input
* .
* format
* not to squeeze
* add train and eval api
* .
* .
* improve fsdp engine data preprocessing
* format
* PullRequest: 337 [lite] Add SFT trainer example.
* trainer log
* minor changes
* add update weights from disk
* fix type annotation

* PullRequest: 339 [Fix] Fix some minor issues to pass all tests.

Merge branch fw/lite of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/339

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* support fsdp engine and sglang remote engine
* minor fix
* .

* chore: empty commit

* ci: build images on demand

* ci: fix on demand condition

* ci: fix env sha

* PullRequest: 340 [lite] Refactor trainer API into utilities and remove mb_spec in engine methods

Merge branch fw/lite-dev of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/340

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* support fsdp engine and sglang remote engine
* minor fix
* .
* refactor trainer
* add close
* rm mb_spec
* fix

* [Fix] Merge previous contributions from fw/refactor to lite (#163)

* initial proposal

* add arealite

* .

* change api

* .

* remove LOG_ROOT

* remove MODEL_SAVE_PATH

* remove PARAM_REALLOC_PATH, DATASET_CACHE

* prepare for testing

* prepare for testing

* ready for run

* local run

* tests mainly pass

* format

* .

* amend cluster.py

* .

* .

* client test pass

* pass rollout test

* remove unused imports

* add arealite readme

* change api

* .

* .

* .

* .

* .

* .

* .

* .

* format

* .

* implement iteraptable generation (#112)

Co-authored-by: zhaochenyang <zhaochenyang20@gmail.com>

* .

* fix

* .

* .

* .

* pass controller generate batch test

* .

* refactor rollout controller into worker and controller

* .

* .

* .

* change to async rollout

* pass rollout controller test

* pass test

* .

* update readme

* .

* sft debug

* .

* add lisence

* remove unused files

* remove unsed args in ppo

* add hf engine wrapper  (#116)

* add hf engine

* fix issues

* fix ppo bugs and add test

* add hf client interface and modify cli args

* fix bugs

* fix issues

* Merge fw/refactor

* Finish hf wrapper test

* add test

---------

Co-authored-by: Wei Fu <36355462+garrett4wade@users.noreply.github.com>

* format

* format

* .

* refine hf engine

* .

* fix

* add fsdp engine and sft tests

* .

* .

* .

* pass ppo unittest

* pass ppo and rollout controller tests

* clear unused imports

* rename ppo to grpo

* change reward function organization

* reorganize code

* add dataset api

* .

* .

* .

* format

* chmod fix

* .

* rename workflow to collector

* refactor llm_client location

* .

* .

* fix llm server api

* refactor config structure

* .

* fix tests

* .

* .

* .

* Fix unresolved issue in SFTTrainer PR (#139)

* .

* .

* efficient loading

* format

* .

* .

* .

* .

* .

* .

* Add CI for testing AReaLite (#150)

* ci: add test-arealite

* ci: add checkout before running test-arealite

* ci: add USERNAME

* ci: add test script

* ci: add GitHub mirror

* ci: fix typo

* ci: clone one commit

* ci: fix condition

* ci: set command timeout to 60m

* ci: enable pip cache

* ci: optimize container lifecycle

* ci: split into many stages

* ci(test-arealite): fix typo

* ci: fix wrong env

* ci: fix pytest

* ci: uninstall transformer-engine

* ci: uninstall transformer-engine

* ci: fix model paths

* ci: show stdout/stderr

* ci: fix not clean up

* ci: backup sglang

* ci: remove tmp repo dir when run

* ci: fix docker run exit 1 condition

* ci(test-arealite): limit the concurrency and extend command timeout

* .

* merge fw/refactor

* revert some changes

* fix

---------

Co-authored-by: meizhiyu.mzy <meizhiyu.mzy@antgroup.com>
Co-authored-by: Chayenne <zhaochen20@outlook.com>
Co-authored-by: zhaochenyang <zhaochenyang20@gmail.com>
Co-authored-by: Jayon02 <qiujiangc@outlook.com>
Co-authored-by: root <meizhiyu.mzy>
Co-authored-by: Zijian Zhang <futrime@outlook.com>

* [Doc] Add an instruction about how to run the SFT example. (#164)

* [Fix] Fix CI running condition for lite. (#172)

* .

* fix

* .

* .

* fix

* fix

* fix

* added LocalSGlangEngine and test (#170)

* added LocalSGLangEngine

* upload test file

* add build args

* fix sgl_local generate

* improved sgl local robustness

* test

* test updated

* added fallback when sgl engine isn't initialized

* finish test local engine

* added LocalSGlangEngine and test

* format and fix

format and fix, raise when generate missing field

format

* change cli_args.py

* add comment header

format

---------

Co-authored-by: ChangyiYang <changyiyang2023@gmail.com>

* format (#174)

* [Feat][Refactor]Support DeepSpeed AutoTP; Refactor hf_engine.py and unit test. (#161)

* refactor hf engine

* format file

* revert file format

* Squashed commit of the following:

commit 8d4b8dc90fceb144bf00f8125f938b57f696e166
Author: Wei Fu <36355462+garrett4wade@users.noreply.github.com>
Date:   Thu Jul 10 13:14:10 2025 +0800

    [Doc] Add an instruction about how to run the SFT example. (#164)

commit 3bf9c85e400a2fe1c6a1e488d27d458ede8cea45
Author: Wei Fu <36355462+garrett4wade@users.noreply.github.com>
Date:   Thu Jul 10 12:56:24 2025 +0800

    [Fix] Merge previous contributions from fw/refactor to lite (#163)

    * initial proposal

    * add arealite

    * .

    * change api

    * .

    * remove LOG_ROOT

    * remove MODEL_SAVE_PATH

    * remove PARAM_REALLOC_PATH, DATASET_CACHE

    * prepare for testing

    * prepare for testing

    * ready for run

    * local run

    * tests mainly pass

    * format

    * .

    * amend cluster.py

    * .

    * .

    * client test pass

    * pass rollout test

    * remove unused imports

    * add arealite readme

    * change api

    * .

    * .

    * .

    * .

    * .

    * .

    * .

    * .

    * format

    * .

    * implement iteraptable generation (#112)

    Co-authored-by: zhaochenyang <zhaochenyang20@gmail.com>

    * .

    * fix

    * .

    * .

    * .

    * pass controller generate batch test

    * .

    * refactor rollout controller into worker and controller

    * .

    * .

    * .

    * change to async rollout

    * pass rollout controller test

    * pass test

    * .

    * update readme

    * .

    * sft debug

    * .

    * add lisence

    * remove unused files

    * remove unsed args in ppo

    * add hf engine wrapper  (#116)

    * add hf engine

    * fix issues

    * fix ppo bugs and add test

    * add hf client interface and modify cli args

    * fix bugs

    * fix issues

    * Merge fw/refactor

    * Finish hf wrapper test

    * add test

    ---------

    Co-authored-by: Wei Fu <36355462+garrett4wade@users.noreply.github.com>

    * format

    * format

    * .

    * refine hf engine

    * .

    * fix

    * add fsdp engine and sft tests

    * .

    * .

    * .

    * pass ppo unittest

    * pass ppo and rollout controller tests

    * clear unused imports

    * rename ppo to grpo

    * change reward function organization

    * reorganize code

    * add dataset api

    * .

    * .

    * .

    * format

    * chmod fix

    * .

    * rename workflow to collector

    * refactor llm_client location

    * .

    * .

    * fix llm server api

    * refactor config structure

    * .

    * fix tests

    * .

    * .

    * .

    * Fix unresolved issue in SFTTrainer PR (#139)

    * .

    * .

    * efficient loading

    * format

    * .

    * .

    * .

    * .

    * .

    * .

    * Add CI for testing AReaLite (#150)

    * ci: add test-arealite

    * ci: add checkout before running test-arealite

    * ci: add USERNAME

    * ci: add test script

    * ci: add GitHub mirror

    * ci: fix typo

    * ci: clone one commit

    * ci: fix condition

    * ci: set command timeout to 60m

    * ci: enable pip cache

    * ci: optimize container lifecycle

    * ci: split into many stages

    * ci(test-arealite): fix typo

    * ci: fix wrong env

    * ci: fix pytest

    * ci: uninstall transformer-engine

    * ci: uninstall transformer-engine

    * ci: fix model paths

    * ci: show stdout/stderr

    * ci: fix not clean up

    * ci: backup sglang

    * ci: remove tmp repo dir when run

    * ci: fix docker run exit 1 condition

    * ci(test-arealite): limit the concurrency and extend command timeout

    * .

    * merge fw/refactor

    * revert some changes

    * fix

    ---------

    Co-authored-by: meizhiyu.mzy <meizhiyu.mzy@antgroup.com>
    Co-authored-by: Chayenne <zhaochen20@outlook.com>
    Co-authored-by: zhaochenyang <zhaochenyang20@gmail.com>
    Co-authored-by: Jayon02 <qiujiangc@outlook.com>
    Co-authored-by: root <meizhiyu.mzy>
    Co-authored-by: Zijian Zhang <futrime@outlook.com>

commit d48bf007cfb0821c35a18a673f3c2e8f51a8ee45
Merge: 42c717b b9dbd4a
Author: 博惟 <bowei.fw@antgroup.com>
Date:   Thu Jul 10 12:53:30 2025 +0800

    Merge branch 'main' of https://github.com/inclusionAI/AReaL into lite

commit 42c717b6e45b3b345f29cff5882ba5374b79faee
Merge: c38cffc a203c7c
Author: 博惟 <bowei.fw@antgroup.com>
Date:   Thu Jul 10 11:15:01 2025 +0800

    Merge branch 'lite' of https://github.com/inclusionAI/AReaL into lite

commit c38cffc02385acf382196ba6b720b2d8b91a5675
Author: 博惟 <bowei.fw@antgroup.com>
Date:   Thu Jul 10 11:10:10 2025 +0800

    PullRequest: 340 [lite] Refactor trainer API into utilities and remove mb_spec in engine methods

    Merge branch fw/lite-dev of git@code.alipay.com:inclusionAI/AReaL.git into lite
    https://code.alipay.com/inclusionAI/AReaL/pull_requests/340

    Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>

    * support fsdp engine and sglang remote engine
    * minor fix
    * .
    * refactor trainer
    * add close
    * rm mb_spec
    * fix

commit b9dbd4a2c18539648dca373c9c8c1347e4e9db68
Author: Wei Fu <36355462+garrett4wade@users.noreply.github.com>
Date:   Wed Jul 9 10:50:19 2025 +0800

    Update to persistent wechat QR code. (#159)

commit 17ea7fe94dc0bd9299082a069383d7372ed13ac9
Author: xssstory <33601810+xssstory@users.noreply.github.com>
Date:   Mon Jul 7 15:49:13 2025 +0800

    fix math reward verifier (#156)

    * PullRequest: 293 fix get_param_realloc_path

    Merge branch xss/debug of git@code.alipay.com:inclusionAI/AReaL.git into gh
    https://code.alipay.com/inclusionAI/AReaL/pull_requests/293

    Reviewed-by: 博惟 <bowei.fw@antgroup.com>

    * fix get_param_realloc_path

    * PullRequest: 297 bugfix: reward is always -5

    Merge branch xss/debug of git@code.alipay.com:inclusionAI/AReaL.git into gh
    https://code.alipay.com/inclusionAI/AReaL/pull_requests/297

    Reviewed-by: 博惟 <bowei.fw@antgroup.com>

    * bugfix: reward is always -5

    * PullRequest: 321 fix checkpoint save dir

    Merge branch xss/debug of git@code.alipay.com:inclusionAI/AReaL.git into gh
    https://code.alipay.com/inclusionAI/AReaL/pull_requests/321

    Reviewed-by: 博惟 <bowei.fw@antgroup.com>

    * fix checkpoint save dir

    * PullRequest: 328 [Doc] update installation

    Merge branch sxj/doc of git@code.alipay.com:inclusionAI/AReaL.git into gh
    https://code.alipay.com/inclusionAI/AReaL/pull_requests/328

    Reviewed-by: 博惟 <bowei.fw@antgroup.com>

    * [Doc] update installation

    * PullRequest: 329 bugfix: math verifier blocks the async training

    Merge branch xss/debug of git@code.alipay.com:inclusionAI/AReaL.git into gh
    https://code.alipay.com/inclusionAI/AReaL/pull_requests/329

    Reviewed-by: 博惟 <bowei.fw@antgroup.com>

    * bugfix: math verifier block the async training

    * format

    ---------

    Co-authored-by: 冰临 <shenxujie.sxj@antgroup.com>
    Co-authored-by: garrett4wade <fuwth17@gmail.com>

* add autotp for hf

* refactor test

* fix bugs

* fix issues

* format files

* Squashed commit of the following:

commit 9ed043f6ab83cf9c9b38e0251ad08009a73243e8
Author: Wei Fu <36355462+garrett4wade@users.noreply.github.com>
Date:   Tue Jul 15 10:24:48 2025 +0800

    format (#174)

commit 8cc9b1feb5ed03cfa42f3ed588dd5f6ec16e5e55
Author: Night <32424487+PrinsYin@users.noreply.github.com>
Date:   Mon Jul 14 19:22:00 2025 -0700

    added LocalSGlangEngine and test (#170)

    * added LocalSGLangEngine

    * upload test file

    * add build args

    * fix sgl_local generate

    * improved sgl local robustness

    * test

    * test updated

    * added fallback when sgl engine isn't initialized

    * finish test local engine

    * added LocalSGlangEngine and test

    * format and fix

    format and fix, raise when generate missing field

    format

    * change cli_args.py

    * add comment header

    format

    ---------

    Co-authored-by: ChangyiYang <changyiyang2023@gmail.com>

---------

Co-authored-by: Jayon02 <12012211@mail..sustech.edu.cn>
Co-authored-by: Wei Fu <36355462+garrett4wade@users.noreply.github.com>

* fix ci (#175)

* [Feature] Add pre-commit (#178)

* fix ci

* .

* .

* .

* [lite] [refactor] Add GSM8k GRPO example. (#179)

* PullRequest: 353 [Lite] Add gradient checkpointing to FSDPEngine

Merge branch mzy/add-gradient-ckpt of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/353

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add gradient checkpointing

* PullRequest: 354 [lite] GRPO pre-commit: minor changes in FSDP  engine

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/354

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .

* PullRequest: 355 [Lite] GRPO pre-commit 2: Refactor RemoteSGLangEngine thread and SGLang configuration

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/355?tab=commit

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* .
* fix
* .

* PullRequest: 357 [lite] GRPO pre-commit 3: Fix typos and experiment utilities

Merge branch fw/lite-fix2 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/357?tab=comment

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* fix destroy process group

* fix ci

* PullRequest: 358 [lite] Support GRPO training locally with the GSM8k dataset

Merge branch fw/lite-fix3 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/358

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* fix loss mask
* fix
* .

---------

Co-authored-by: 晓雷 <meizhiyu.mzy@antgroup.com>

* change doc (#180)

* [Fix] [lite] Merge from the internal repo to fix GRPO bugs and refactor the train engine (#181)

* PullRequest: 353 [Lite] Add gradient checkpointing to FSDPEngine

Merge branch mzy/add-gradient-ckpt of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/353

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add gradient checkpointing

* PullRequest: 354 [lite] GRPO pre-commit: minor changes in FSDP  engine

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/354

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .

* PullRequest: 355 [Lite] GRPO pre-commit 2: Refactor RemoteSGLangEngine thread and SGLang configuration

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/355?tab=commit

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* .
* fix
* .

* PullRequest: 357 [lite] GRPO pre-commit 3: Fix typos and experiment utilities

Merge branch fw/lite-fix2 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/357?tab=comment

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* fix destroy process group

* PullRequest: 358 [lite] Support GRPO training locally with the GSM8k dataset

Merge branch fw/lite-fix3 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/358

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* fix loss mask
* fix
* .

* PullRequest: 368 [lite] Refactor train engine after merging contributions from GitHub

Merge branch fw/lite-train-engine of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/368

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* PullRequest: 371 [lite] [fix] fix misc bugs in GRPO implementation

Merge branch fw/lite-fix0716 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/371

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .

---------

Co-authored-by: 晓雷 <meizhiyu.mzy@antgroup.com>

* Implement fsdp distributed update (#183)

* PullRequest: 353 [Lite] Add gradient checkpointing to FSDPEngine

Merge branch mzy/add-gradient-ckpt of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/353

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add gradient checkpointing

* PullRequest: 354 [lite] GRPO pre-commit: minor changes in FSDP  engine

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/354

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .

* PullRequest: 355 [Lite] GRPO pre-commit 2: Refactor RemoteSGLangEngine thread and SGLang configuration

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/355?tab=commit

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* .
* fix
* .

* PullRequest: 357 [lite] GRPO pre-commit 3: Fix typos and experiment utilities

Merge branch fw/lite-fix2 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/357?tab=comment

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* fix destroy process group

* PullRequest: 358 [lite] Support GRPO training locally with the GSM8k dataset

Merge branch fw/lite-fix3 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/358

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* fix loss mask
* fix
* .

* PullRequest: 368 [lite] Refactor train engine after merging contributions from GitHub

Merge branch fw/lite-train-engine of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/368

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* PullRequest: 371 [lite] [fix] fix misc bugs in GRPO implementation

Merge branch fw/lite-fix0716 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/371

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .

* added remote nccl weight update

feat: implement update_weights_from_distributed in fsdp_engine.py

unfinishd test, raise PR first

coroutine for each server

chore: change uploads weights behavior, change test order

fix small bug

fixed test

* fix rebase

* add test.sh

* updated, test stil fails

* .

* .

* .

* fix: full_tensor() should happen in all rank (#187)

Co-authored-by: ChangyiYang <changyiyang2023@gmail.com>

---------

Co-authored-by: 晓雷 <meizhiyu.mzy@antgroup.com>
Co-authored-by: 博惟 <bowei.fw@antgroup.com>
Co-authored-by: ChangyiYang <changyiyang2023@gmail.com>
Co-authored-by: ChangyiYang <112288487+ChangyiYang@users.noreply.github.com>

* [Feature] [lite] Merge from internal dev repo (#189)

* PullRequest: 353 [Lite] Add gradient checkpointing to FSDPEngine

Merge branch mzy/add-gradient-ckpt of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/353

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add gradient checkpointing

* PullRequest: 354 [lite] GRPO pre-commit: minor changes in FSDP  engine

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/354

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .

* PullRequest: 355 [Lite] GRPO pre-commit 2: Refactor RemoteSGLangEngine thread and SGLang configuration

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/355?tab=commit

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* .
* fix
* .

* PullRequest: 357 [lite] GRPO pre-commit 3: Fix typos and experiment utilities

Merge branch fw/lite-fix2 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/357?tab=comment

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* fix destroy process group

* PullRequest: 358 [lite] Support GRPO training locally with the GSM8k dataset

Merge branch fw/lite-fix3 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/358

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* fix loss mask
* fix
* .

* PullRequest: 368 [lite] Refactor train engine after merging contributions from GitHub

Merge branch fw/lite-train-engine of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/368

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* PullRequest: 371 [lite] [fix] fix misc bugs in GRPO implementation

Merge branch fw/lite-fix0716 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/371

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .

* PullRequest: 370 [lite] Add Slurm Launcher and Ray Launcher

Merge branch mzy/lite/launcher of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/370

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* .
* .
* .
* fix

* PullRequest: 392 [lite] Fix several bugs regarding RL learning and add an example to reproduce boba-math results.

Merge branch fw/lite-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/392

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* support fsdp engine and sglang remote engine
* minor fix
* .
* refactor trainer
* add close
* rm mb_spec
* .
* fix
* .
* qwen2 grpo works
* fix
* fix
* async works
* fix
* slurm launcher not tested
* fix arg parse
* .
* sglang server wrapper
* .
* .
* slurm run
* ready for boba
* debug
* 32k run
* .
* .
* fix
* .
* .
* .
* .
* .
* fix
* .
* fix
* .
* .
* .
* .
* fix
* .
* .
* .
* .
* .
* .
* .
* refactor train engine
* refactor train engine
* .
* fix update weight error
* .
* .
* match train
* format
* .
* fix
* seems to work
* .
* .
* .
* .

* format

* format

* .

---------

Co-authored-by: 晓雷 <meizhiyu.mzy@antgroup.com>

* [Refactor] Rename files in arealite before release. (#190)

* PullRequest: 353 [Lite] Add gradient checkpointing to FSDPEngine

Merge branch mzy/add-gradient-ckpt of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/353

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add gradient checkpointing

* PullRequest: 354 [lite] GRPO pre-commit: minor changes in FSDP  engine

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/354

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .

* PullRequest: 355 [Lite] GRPO pre-commit 2: Refactor RemoteSGLangEngine thread and SGLang configuration

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/355?tab=commit

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* .
* fix
* .

* PullRequest: 357 [lite] GRPO pre-commit 3: Fix typos and experiment utilities

Merge branch fw/lite-fix2 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/357?tab=comment

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* fix destroy process group

* PullRequest: 358 [lite] Support GRPO training locally with the GSM8k dataset

Merge branch fw/lite-fix3 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/358

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* fix loss mask
* fix
* .

* PullRequest: 368 [lite] Refactor train engine after merging contributions from GitHub

Merge branch fw/lite-train-engine of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/368

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* PullRequest: 371 [lite] [fix] fix misc bugs in GRPO implementation

Merge branch fw/lite-fix0716 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/371

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .

* PullRequest: 370 [lite] Add Slurm Launcher and Ray Launcher

Merge branch mzy/lite/launcher of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/370

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* .
* .
* .
* fix

* PullRequest: 392 [lite] Fix several bugs regarding RL learning and add an example to reproduce boba-math results.

Merge branch fw/lite-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/392

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* support fsdp engine and sglang remote engine
* minor fix
* .
* refactor trainer
* add close
* rm mb_spec
* .
* fix
* .
* qwen2 grpo works
* fix
* fix
* async works
* fix
* slurm launcher not tested
* fix arg parse
* .
* sglang server wrapper
* .
* .
* slurm run
* ready for boba
* debug
* 32k run
* .
* .
* fix
* .
* .
* .
* .
* .
* fix
* .
* fix
* .
* .
* .
* .
* fix
* .
* .
* .
* .
* .
* .
* .
* refactor train engine
* refactor train engine
* .
* fix update weight error
* .
* .
* match train
* format
* .
* fix
* seems to work
* .
* .
* .
* .

* format

* format

* .

* rename

* rename

---------

Co-authored-by: 晓雷 <meizhiyu.mzy@antgroup.com>

* add quickstart (#194)

* [doc] [lite] Add customization docs for AReaLite. (#191)

* PullRequest: 353 [Lite] Add gradient checkpointing to FSDPEngine

Merge branch mzy/add-gradient-ckpt of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/353

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add gradient checkpointing

* PullRequest: 354 [lite] GRPO pre-commit: minor changes in FSDP  engine

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/354

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .

* PullRequest: 355 [Lite] GRPO pre-commit 2: Refactor RemoteSGLangEngine thread and SGLang configuration

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/355?tab=commit

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* .
* fix
* .

* PullRequest: 357 [lite] GRPO pre-commit 3: Fix typos and experiment utilities

Merge branch fw/lite-fix2 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/357?tab=comment

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* fix destroy process group

* PullRequest: 358 [lite] Support GRPO training locally with the GSM8k dataset

Merge branch fw/lite-fix3 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/358

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* fix loss mask
* fix
* .

* PullRequest: 368 [lite] Refactor train engine after merging contributions from GitHub

Merge branch fw/lite-train-engine of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/368

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* PullRequest: 371 [lite] [fix] fix misc bugs in GRPO implementation

Merge branch fw/lite-fix0716 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/371

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .

* PullRequest: 370 [lite] Add Slurm Launcher and Ray Launcher

Merge branch mzy/lite/launcher of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/370

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* .
* .
* .
* fix

* PullRequest: 392 [lite] Fix several bugs regarding RL learning and add an example to reproduce boba-math results.

Merge branch fw/lite-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/392

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* support fsdp engine and sglang remote engine
* minor fix
* .
* refactor trainer
* add close
* rm mb_spec
* .
* fix
* .
* qwen2 grpo works
* fix
* fix
* async works
* fix
* slurm launcher not tested
* fix arg parse
* .
* sglang server wrapper
* .
* .
* slurm run
* ready for boba
* debug
* 32k run
* .
* .
* fix
* .
* .
* .
* .
* .
* fix
* .
* fix
* .
* .
* .
* .
* fix
* .
* .
* .
* .
* .
* .
* .
* refactor train engine
* refactor train engine
* .
* fix update weight error
* .
* .
* match train
* format
* .
* fix
* seems to work
* .
* .
* .
* .

* .

* .

* .

* .

* .

* .

* .

---------

Co-authored-by: 晓雷 <meizhiyu.mzy@antgroup.com>

* [lite] [feature] Bump to SGLang v0.4.9.post2 and use NCCL to update weights (#196)

* PullRequest: 353 [Lite] Add gradient checkpointing to FSDPEngine

Merge branch mzy/add-gradient-ckpt of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/353

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add gradient checkpointing

* PullRequest: 354 [lite] GRPO pre-commit: minor changes in FSDP  engine

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/354

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .

* PullRequest: 355 [Lite] GRPO pre-commit 2: Refactor RemoteSGLangEngine thread and SGLang configuration

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/355?tab=commit

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* .
* fix
* .

* PullRequest: 357 [lite] GRPO pre-commit 3: Fix typos and experiment utilities

Merge branch fw/lite-fix2 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/357?tab=comment

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* fix destroy process group

* PullRequest: 358 [lite] Support GRPO training locally with the GSM8k dataset

Merge branch fw/lite-fix3 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/358

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* fix loss mask
* fix
* .

* PullRequest: 368 [lite] Refactor train engine after merging contributions from GitHub

Merge branch fw/lite-train-engine of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/368

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* PullRequest: 371 [lite] [fix] fix misc bugs in GRPO implementation

Merge branch fw/lite-fix0716 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/371

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .

* PullRequest: 370 [lite] Add Slurm Launcher and Ray Launcher

Merge branch mzy/lite/launcher of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/370

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* .
* .
* .
* fix

* PullRequest: 392 [lite] Fix several bugs regarding RL learning and add an example to reproduce boba-math results.

Merge branch fw/lite-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/392

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* support fsdp engine and sglang remote engine
* minor fix
* .
* refactor trainer
* add close
* rm mb_spec
* .
* fix
* .
* qwen2 grpo works
* fix
* fix
* async works
* fix
* slurm launcher not tested
* fix arg parse
* .
* sglang server wrapper
* .
* .
* slurm run
* ready for boba
* debug
* 32k run
* .
* .
* fix
* .
* .
* .
* .
* .
* fix
* .
* fix
* .
* .
* .
* .
* fix
* .
* .
* .
* .
* .
* .
* .
* refactor train engine
* refactor train engine
* .
* fix update weight error
* .
* .
* match train
* format
* .
* fix
* seems to work
* .
* .
* .
* .

* .

* PullRequest: 408 [Feature] Bump SGLang version to v0.4.9.post2

Merge branch fw/sgl049 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/408

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* bump arealite to sglang 0.4.9.post2
* .
* PullRequest: 412 [lite] Minor refactor on `UpdateWeightMeta`

* PullRequest: 422 [lite] Fix tests and scripts after updating sgl to 0.4.9

Merge branch fw/sgl049 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/422

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* bump arealite to sglang 0.4.9.post2
* .
* PullRequest: 412 [lite] Minor refactor on `UpdateWeightMeta`
* .

* PullRequest: 423 [lite] Remove the boba example for github release.

Merge branch fw/remove-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/423

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

---------

Co-authored-by: 晓雷 <meizhiyu.mzy@antgroup.com>

* [Docs] [lite] Add example code walkthrough documentation. (#197)

* .

* .

* fix grammar and minor revise

* [lite] [doc] Add AReaLite design doc as README (#198)

* PullRequest: 353 [Lite] Add gradient checkpointing to FSDPEngine

Merge branch mzy/add-gradient-ckpt of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/353

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add gradient checkpointing

* PullRequest: 354 [lite] GRPO pre-commit: minor changes in FSDP  engine

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/354

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .

* PullRequest: 355 [Lite] GRPO pre-commit 2: Refactor RemoteSGLangEngine thread and SGLang configuration

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/355?tab=commit

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* .
* fix
* .

* PullRequest: 357 [lite] GRPO pre-commit 3: Fix typos and experiment utilities

Merge branch fw/lite-fix2 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/357?tab=comment

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* fix destroy process group

* PullRequest: 358 [lite] Support GRPO training locally with the GSM8k dataset

Merge branch fw/lite-fix3 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/358

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* fix loss mask
* fix
* .

* PullRequest: 368 [lite] Refactor train engine after merging contributions from GitHub

Merge branch fw/lite-train-engine of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/368

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* PullRequest: 371 [lite] [fix] fix misc bugs in GRPO implementation

Merge branch fw/lite-fix0716 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/371

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .

* PullRequest: 370 [lite] Add Slurm Launcher and Ray Launcher

Merge branch mzy/lite/launcher of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/370

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* .
* .
* .
* fix

* PullRequest: 392 [lite] Fix several bugs regarding RL learning and add an example to reproduce boba-math results.

Merge branch fw/lite-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/392

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* support fsdp engine and sglang remote engine
* minor fix
* .
* refactor trainer
* add close
* rm mb_spec
* .
* fix
* .
* qwen2 grpo works
* fix
* fix
* async works
* fix
* slurm launcher not tested
* fix arg parse
* .
* sglang server wrapper
* .
* .
* slurm run
* ready for boba
* debug
* 32k run
* .
* .
* fix
* .
* .
* .
* .
* .
* fix
* .
* fix
* .
* .
* .
* .
* fix
* .
* .
* .
* .
* .
* .
* .
* refactor train engine
* refactor train engine
* .
* fix update weight error
* .
* .
* match train
* format
* .
* fix
* seems to work
* .
* .
* .
* .

* .

* PullRequest: 408 [Feature] Bump SGLang version to v0.4.9.post2

Merge branch fw/sgl049 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/408

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* bump arealite to sglang 0.4.9.post2
* .
* PullRequest: 412 [lite] Minor refactor on `UpdateWeightMeta`

* PullRequest: 422 [lite] Fix tests and scripts after updating sgl to 0.4.9

Merge branch fw/sgl049 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/422

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* bump arealite to sglang 0.4.9.post2
* .
* PullRequest: 412 [lite] Minor refactor on `UpdateWeightMeta`
* .

* PullRequest: 423 [lite] Remove the boba example for github release.

Merge branch fw/remove-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/423

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* update readme

* .

---------

Co-authored-by: 晓雷 <meizhiyu.mzy@antgroup.com>

* Add self-hosted runner support (#199)

* ci: add testsz for self hosted runner

* ci: use self-hosted runner

* ci: run ci on push

* ci: remove cd to tmp dir

* ci: fix

* ci: add environment back

* ci: set concurrency

* ci: fix build env image

* Update .github/workflows/test-arealite.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update ci/build_env_image.sh

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* ci: add some test code

* ci: simplify

* ci: try to fix

* ci: test

* ci: test2

* ci: test3

* ci: test3

* ci: tidy up

* ci: simplify

* ci: do not trigger on push

* ci: test arealite/tests/

* ci: use UUID as run id

* ci: use openssl rand to genreate run id

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* [WIP][feat] Initial support for VLMs, add Qwen2VL SFT test and Qwen2.5VL GRPO test (#188)

* vlm_sft_test

* vlm_sft_test

* .

* .

* Fix unresolved issue in SFTTrainer PR (#139)

* .

* .

* efficient loading

* format

* .

* .

* Fix unresolved issue in SFTTrainer PR (#139)

* .

* .

* efficient loading

* format

* .

* .

* image_process0701

* image_process0701

* image_process0701_2

* image_process0701_2

* image_process0701_3

* image_process0701_3

* .

* .

* .

* .

* .

* .

* imageprocess0702

* imageprocess0702

* image_process0702_2

* image_process0702_2

* image_process0702_3

* image_process0702_3

* image_process0702_4

* image_process0702_4

* image_process0702_5

* image_process0702_5

* image_process0703_1

* image_process0703_1

* 0703_2

* 0703_2

* 0703_3

* 0703_3

* 0703_4

* 0703_4

* 0703_4

* 0703_4

* 0703_5

* 0703_5

* 0703_6

* 0703_6

* 0703_7

* 0703_7

* 0703_8

* 0703_8

* 0703_9

* 0703_9

* 0703_11

* 0703_11

* 0703_12

* 0703_12

* 0703_13

* 0703_13

* 0703_14

* 0703_14

* 0703_15

* 0703_15

* 0703_16

* 0703_16

* 0703-17

* 0703-17

* 0703_18

* 0703_18

* 0703_18

* 0703_18

* 0703_19

* 0703_19

* 0704_1

* 0704_1

* 0704_2

* 0704_2

* 0704_3

* 0704_3

* .

* .

* 0707_1

* 0707_1

* 0707_2

* 0707_2

* 0703_3

* 0703_3

* r

* p

* fix

* fix

* refactor

* 0707_6

* 0707_7

* refactor1

* 0707_undone

* 0708_1

* 0708_2

* 0708_3

* 0708_7

* 0708_4

* 0709_1

* 0709_2

* 0709_3

* 0709_4

* 0709_5

* 0709_

* 0709_6

* 0709_7

* 0709_7

* 0709_8

* 0709_9

* 0710_1

* 0710_2

* 0710_2

* 0710_3

* 0710_3

* 0710_3

* 0710_5

* 0710_4

* merge_2

* merge_3

* 0711_1

* 0711_2

* 0711_3

* 0711_4

* 0711_6

* 0711_7

* 0711_8

* 0711_8

* 0711_9

* 0711_10

* 0711-11

* PullRequest: 353 [Lite] Add gradient checkpointing to FSDPEngine

Merge branch mzy/add-gradient-ckpt of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/353

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add gradient checkpointing

* PullRequest: 354 [lite] GRPO pre-commit: minor changes in FSDP  engine

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/354

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .

* 0714_1

* 0714_2

* 0714_3

* 0714_3

* 0714_5

* PullRequest: 355 [Lite] GRPO pre-commit 2: Refactor RemoteSGLangEngine thread and SGLang configuration

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/355?tab=commit

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* .
* fix
* .

* PullRequest: 357 [lite] GRPO pre-commit 3: Fix typos and experiment utilities

Merge branch fw/lite-fix2 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/357?tab=comment

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* fix destroy process group

* PullRequest: 358 [lite] Support GRPO training locally with the GSM8k dataset

Merge branch fw/lite-fix3 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/358

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* fix loss mask
* fix
* .

* 0715_1

* 0715_2

* 0715_2

* 0716_1

* 0716_2

* PullRequest: 368 [lite] Refactor train engine after merging contributions from GitHub

Merge branch fw/lite-train-engine of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/368

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* PullRequest: 371 [lite] [fix] fix misc bugs in GRPO implementation

Merge branch fw/lite-fix0716 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/371

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .

* 0716_3

* 0716_4

* 0716_4

* 0716_5

* 0717_1

* 0717_3

* 0717_3

* 0717_4

* 0717_5

* 0717_6

* 0717_6

* 0717_6

* 0718_2

* 0718_4

* 0718_5

* PullRequest: 370 [lite] Add Slurm Launcher and Ray Launcher

Merge branch mzy/lite/launcher of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/370

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* .
* .
* .
* fix

* merge_0721

* 0721_1

* PullRequest: 392 [lite] Fix several bugs regarding RL learning and add an example to reproduce boba-math results.

Merge branch fw/lite-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/392

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* support fsdp engine and sglang remote engine
* minor fix
* .
* refactor trainer
* add close
* rm mb_spec
* .
* fix
* .
* qwen2 grpo works
* fix
* fix
* async works
* fix
* slurm launcher not tested
* fix arg parse
* .
* sglang server wrapper
* .
* .
* slurm run
* ready for boba
* debug
* 32k run
* .
* .
* fix
* .
* .
* .
* .
* .
* fix
* .
* fix
* .
* .
* .
* .
* fix
* .
* .
* .
* .
* .
* .
* .
* refactor train engine
* refactor train engine
* .
* fix update weight error
* .
* .
* match train
* format
* .
* fix
* seems to work
* .
* .
* .
* .

* 0721_2

* 0721_3

* 0721_4

* .

* 0721_formal

* 0721_formal

* 0721_merge4

* 0721_merge5

* 0721_6

* 0721_merge6

* 0721_merge7

* 0721_8

* 0722_1

* 0722_2

* 0722_3

* 0722_4

* 0722_4

* 0722_5

* 0722_6

* 0722_7

* 0723_1

* reformatted

* clang-reformatted

* clang-reformatted2

* 0723_1

* 0723_1

* 0723_1

* 0723_merge3

* 0723_4

* 0723_reformatted_5

* 0724_1

* 0724_1

* 0724_merge1

* 0724_merge2

* 0724_merge3

* 0724_merge3

* 0724_merge4

* 0724_merge5

* 0724_merge6

* 0724_merge7

* 0724_4

* 0724-merge8

* 0724_merge8

* 0725_1

* 0725_6

* 0725_7

* 0725_4padded_image

* 0725_9padded_image

* 0725_10padded_image

* 0725

* 0725_12

* 0725_format

---------

Co-authored-by: bowei.fw <bowei.fw@antgroup.com>
Co-authored-by: nuzant <meizhiyu.mzy@antgroup.com>
Co-authored-by: 朱晗 <lichangye.lcy@antgroup.com>

* [lite] [fix] Fix a performance issue and several minor issues before release (#203)

* PullRequest: 353 [Lite] Add gradient checkpointing to FSDPEngine

Merge branch mzy/add-gradient-ckpt of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/353

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add gradient checkpointing

* PullRequest: 354 [lite] GRPO pre-commit: minor changes in FSDP  engine

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/354

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .

* PullRequest: 355 [Lite] GRPO pre-commit 2: Refactor RemoteSGLangEngine thread and SGLang configuration

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/355?tab=commit

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* .
* fix
* .

* PullRequest: 357 [lite] GRPO pre-commit 3: Fix typos and experiment utilities

Merge branch fw/lite-fix2 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/357?tab=comment

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* fix destroy process group

* PullRequest: 358 [lite] Support GRPO training locally with the GSM8k dataset

Merge branch fw/lite-fix3 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/358

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* fix loss mask
* fix
* .

* PullRequest: 368 [lite] Refactor train engine after merging contributions from GitHub

Merge branch fw/lite-train-engine of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/368

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* PullRequest: 371 [lite] [fix] fix misc bugs in GRPO implementation

Merge branch fw/lite-fix0716 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/371

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .

* PullRequest: 370 [lite] Add Slurm Launcher and Ray Launcher

Merge branch mzy/lite/launcher of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/370

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* .
* .
* .
* fix

* PullRequest: 392 [lite] Fix several bugs regarding RL learning and add an example to reproduce boba-math results.

Merge branch fw/lite-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/392

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* support fsdp engine and sglang remote engine
* minor fix
* .
* refactor trainer
* add close
* rm mb_spec
* .
* fix
* .
* qwen2 grpo works
* fix
* fix
* async works
* fix
* slurm launcher not tested
* fix arg parse
* .
* sglang server wrapper
* .
* .
* slurm run
* ready for boba
* debug
* 32k run
* .
* .
* fix
* .
* .
* .
* .
* .
* fix
* .
* fix
* .
* .
* .
* .
* fix
* .
* .
* .
* .
* .
* .
* .
* refactor train engine
* refactor train engine
* .
* fix update weight error
* .
* .
* match train
* format
* .
* fix
* seems to work
* .
* .
* .
* .

* .

* PullRequest: 408 [Feature] Bump SGLang version to v0.4.9.post2

Merge branch fw/sgl049 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/408

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* bump arealite to sglang 0.4.9.post2
* .
* PullRequest: 412 [lite] Minor refactor on `UpdateWeightMeta`

* PullRequest: 422 [lite] Fix tests and scripts after updating sgl to 0.4.9

Merge branch fw/sgl049 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/422

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* bump arealite to sglang 0.4.9.post2
* .
* PullRequest: 412 [lite] Minor refactor on `UpdateWeightMeta`
* .

* PullRequest: 423 [lite] Remove the boba example for github release.

Merge branch fw/remove-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/423

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* update readme

* PullRequest: 431 [Fix] Fix environment of lite

Merge branch fw/lite-dev of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/431

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* change requirements
* .
* .
* .

* PullRequest: 440 [FIX] fix update weight from disk

Merge branch sxj/lite-fix-disk-update of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/440

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* [FIX] fix update weight from disk

* PullRequest: 442 [lite] Refactor `RemoteSGLangEngine` into two parts: `RemoteSGLangEngine` and `WorkflowExecutor`.

Merge branch mzy/workflow-executor of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/442

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* refactor workflow executor
* .
* fix tests and eval
* .
* .
* revert workflow executor into remote sglang engine
* .

* PullRequest: 456 [lite] [Bug] Use `ProcessPoolExecutor` to calculate reward to avoid rollout slow down

Merge branch mzy/lite/fix-reward of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/456?tab=comment

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* fix reward
* .
* .
* .

* PullRequest: 460 [lite][fix] add a warning when reward computation timeout

Merge branch fw/lite-fix of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/460

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* add a warning when reward computation timeout

* PullRequest: 465 [lite][fix] Fix issues raised by tsao

Merge branch fw/lite-fix of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/465

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* fix

---------

Co-authored-by: 晓雷 <meizhiyu.mzy@antgroup.com>
Co-authored-by: 冰临 <shenxujie.sxj@antgroup.com>

* [lite] [refactor] Rename the `arealite` folder to `areal` (#205)

* PullRequest: 353 [Lite] Add gradient checkpointing to FSDPEngine

Merge branch mzy/add-gradient-ckpt of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/353

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add gradient checkpointing

* PullRequest: 354 [lite] GRPO pre-commit: minor changes in FSDP  engine

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/354

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .

* PullRequest: 355 [Lite] GRPO pre-commit 2: Refactor RemoteSGLangEngine thread and SGLang configuration

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/355?tab=commit

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* .
* fix
* .

* PullRequest: 357 [lite] GRPO pre-commit 3: Fix typos and experiment utilities

Merge branch fw/lite-fix2 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/357?tab=comment

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* fix destroy process group

* PullRequest: 358 [lite] Support GRPO training locally with the GSM8k dataset

Merge branch fw/lite-fix3 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/358

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* fix loss mask
* fix
* .

* PullRequest: 368 [lite] Refactor train engine after merging contributions from GitHub

Merge branch fw/lite-train-engine of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/368

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* PullRequest: 371 [lite] [fix] fix misc bugs in GRPO implementation

Merge branch fw/lite-fix0716 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/371

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .

* PullRequest: 370 [lite] Add Slurm Launcher and Ray Launcher

Merge branch mzy/lite/launcher of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/370

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* .
* .
* .
* fix

* PullRequest: 392 [lite] Fix several bugs regarding RL learning and add an example to reproduce boba-math results.

Merge branch fw/lite-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/392

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* support fsdp engine and sglang remote engine
* minor fix
* .
* refactor trainer
* add close
* rm mb_spec
* .
* fix
* .
* qwen2 grpo works
* fix
* fix
* async works
* fix
* slurm launcher not tested
* fix arg parse
* .
* sglang server wrapper
* .
* .
* slurm run
* ready for boba
* debug
* 32k run
* .
* .
* fix
* .
* .
* .
* .
* .
* fix
* .
* fix
* .
* .
* .
* .
* fix
* .
* .
* .
* .
* .
* .
* .
* refactor train engine
* refactor train engine
* .
* fix update weight error
* .
* .
* match train
* format
* .
* fix
* seems to work
* .
* .
* .
* .

* .

* PullRequest: 408 [Feature] Bump SGLang version to v0.4.9.post2

Merge branch fw/sgl049 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/408

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* bump arealite to sglang 0.4.9.post2
* .
* PullRequest: 412 [lite] Minor refactor on `UpdateWeightMeta`

* PullRequest: 422 [lite] Fix tests and scripts after updating sgl to 0.4.9

Merge branch fw/sgl049 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/422

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* bump arealite to sglang 0.4.9.post2
* .
* PullRequest: 412 [lite] Minor refactor on `UpdateWeightMeta`
* .

* PullRequest: 423 [lite] Remove the boba example for github release.

Merge branch fw/remove-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/423

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* update readme

* PullRequest: 431 [Fix] Fix environment of lite

Merge branch fw/lite-dev of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/431

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* change requirements
* .
* .
* .

* PullRequest: 440 [FIX] fix update weight from disk

Merge branch sxj/lite-fix-disk-update of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/440

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* [FIX] fix update weight from disk

* PullRequest: 442 [lite] Refactor `RemoteSGLangEngine` into two parts: `RemoteSGLangEngine` and `WorkflowExecutor`.

Merge branch mzy/workflow-executor of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/442

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* refactor workflow executor
* .
* fix tests and eval
* .
* .
* revert workflow executor into remote sglang engine
* .

* PullRequest: 456 [lite] [Bug] Use `ProcessPoolExecutor` to calculate reward to avoid rollout slow down

Merge branch mzy/lite/fix-reward of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/456?tab=comment

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* fix reward
* .
* .
* .

* PullRequest: 460 [lite][fix] add a warning when reward computation timeout

Merge branch fw/lite-fix of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/460

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* add a warning when reward computation timeout

* PullRequest: 465 [lite][fix] Fix issues raised by tsao

Merge branch fw/lite-fix of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/465

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* fix

* PullRequest: 463 [FEAT] add config converter

Merge branch sxj/lite-add-converter of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/463

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* [FEAT] add config converter
* [FIX] fix bugs
* [FIX] fix typos
* [FIX] fix cpu allocation
* [FIX] del vllm

* PullRequest: 466 [lite] Add seeding in training scripts and pad to max_tokens_per_mb to avoid memory fragmentation

Merge branch fw/lite-fix of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/466

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* add seed
* .
* add option for pad to max len
* .

* PullRequest: 467 [lite][fix] remove logging functionality in stats_logger

Merge branch fw/lite-fix of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/467

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* remove logging functionality in stats_logger
* .

* rename arealite to areal

* rename arealite to areal

* .

* local experiment run

* .

---------

Co-authored-by: 晓雷 <meizhiyu.mzy@antgroup.com>
Co-authored-by: 冰临 <shenxujie.sxj@antgroup.com>

* [lite] [fix] Fix running the legacy experiment in the v0.4.9.post2 sglang environment (#207)

* PullRequest: 353 [Lite] Add gradient checkpointing to FSDPEngine

Merge branch mzy/add-gradient-ckpt of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/353

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* add gradient checkpointing

* PullRequest: 354 [lite] GRPO pre-commit: minor changes in FSDP  engine

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/354

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .

* PullRequest: 355 [Lite] GRPO pre-commit 2: Refactor RemoteSGLangEngine thread and SGLang configuration

Merge branch fw/lite-fix1 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/355?tab=commit

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* .
* fix
* .

* PullRequest: 357 [lite] GRPO pre-commit 3: Fix typos and experiment utilities

Merge branch fw/lite-fix2 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/357?tab=comment

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* .
* fix destroy process group

* PullRequest: 358 [lite] Support GRPO training locally with the GSM8k dataset

Merge branch fw/lite-fix3 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/358

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .
* .
* .
* fix loss mask
* fix
* .

* PullRequest: 368 [lite] Refactor train engine after merging contributions from GitHub

Merge branch fw/lite-train-engine of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/368

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .
* .

* PullRequest: 371 [lite] [fix] fix misc bugs in GRPO implementation

Merge branch fw/lite-fix0716 of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/371

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* .

* PullRequest: 370 [lite] Add Slurm Launcher and Ray Launcher

Merge branch mzy/lite/launcher of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/370

Reviewed-by: 博惟 <bowei.fw@antgroup.com>


* .
* .
* .
* fix

* PullRequest: 392 [lite] Fix several bugs regarding RL learning and add an example to reproduce boba-math results.

Merge branch fw/lite-boba of git@code.alipay.com:inclusionAI/AReaL.git into lite
https://code.alipay.com/inclusionAI/AReaL/pull_requests/392

Reviewed-by: 晓雷 <meizhiyu.mzy@antgroup.com>


* support fsdp engine and sglang remote engine
* minor fix
* .
* refactor trainer
* add close
* rm mb_spec
* .
* fix
* .
* qwen2 grpo works
* fix
* fix
* async works
* fix
* slurm launcher not tested
* fix arg parse
* .
* sglang server wrapper
* .
* .
* slurm run
* ready for boba
* debug
* 32k run
* .
* .
* fix
* .
* .
* .
* .
* .
* fix
* .
* fix
* .
* .
* .
* .
* fix
* .
* .
* .
* .
* .
* .
* .
* refactor train engine
* refactor train engine
* .
* fix update we…
zhshgmail pushed a commit that referenced this pull request Aug 14, 2025
* support vllm

* support vllm

* support vllm v3

* fix vllm v3

* support vllm restart.

* support vllm restart.

---------

Co-authored-by: Ginray <546307259@qq.com>
Co-authored-by: sunyinlei <sunyinlei@huawei.com>
zhshgmail pushed a commit that referenced this pull request Oct 8, 2025
## Bugs Fixed

### Bug #1: Incorrect proximal_logprobs_t Length (CRITICAL)
- File: areal/engine/sglang_remote.py
- Issue: Length mismatch causing crashes during abort-resume
- Fix: Changed EXTEND to REPLACE logic for previous tokens
- Impact: Prevents crashes like "len(proximal_t)=7 vs len(output)=3"

### Bug #2: Misaligned Tensor Roll (CRITICAL)
- File: areal/engine/ppo/actor.py
- Issue: Off-by-one misalignment in loss computation
- Fix: Added roll operation for old_logp to align with proximal_logprobs_t
- Impact: Ensures correct importance weight calculation

## Changes
- Modified: areal/engine/sglang_remote.py (lines 183, 240-282)
- Modified: areal/engine/ppo/actor.py (lines 322-327)
- Modified: areal/api/workflow_api.py (added recompute_all_proximal_t method)
- Added: test_proximal_t_generation_simple.py (5 unit tests for Bug #1)
- Added: test_recompute_timing.py (11 tests for recompute logic)
- Added: CHANGES_SUMMARY.md (quick reference)
- Added: docs/PROXIMAL_T_BUGS_COMPLETE_ANALYSIS.md (comprehensive documentation)

## Test Results
All 42 tests pass:
- test_proximal_t_generation_simple.py: 5/5 ✓
- test_recompute_timing.py: 11/11 ✓
- test_workflow_executor_wait.py: 26/26 ✓

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
zhshgmail pushed a commit that referenced this pull request Oct 8, 2025
This commit fixes critical bugs in segment-wise decoupled PPO and adds
symmetric importance weight clipping capability.

## Bug Fixes

### Bug #1: Incorrect proximal_logprobs_t Length (CRITICAL)
- **File**: areal/engine/sglang_remote.py (lines 183, 240-282)
- **Issue**: Length mismatch during abort-resume causing crashes
- **Root cause**: Used EXTEND instead of REPLACE, duplicating values
- **Fix**: Changed to REPLACE logic for previous tokens
- **Impact**: Prevents crashes like "len(proximal_t)=7 vs len(output)=3"

### Bug #2: Incorrect old_logp Rolling (CRITICAL)
- **File**: areal/engine/ppo/actor.py
- **Issue**: old_logp was double-rolled causing misalignment
- **Root cause**: old_logp already rolled in compute_logp() at line 93
- **Fix**: Removed incorrect second roll in grpo_loss_fn()
- **Impact**: Ensures correct alignment for loss computation

## New Features

### behav_imp_weight_floor Parameter
- **Motivation**: Original behav_imp_weight_cap only bounds high ratios,
  but stable importance sampling needs symmetric bounds
- **Implementation**: Optional floor parameter for lower bound clipping
- **Backward compatible**: floor=None maintains original behavior
- **Usage**:
  - Symmetric: cap=10.0, floor=0.1 creates trust region [0.1, 10.0]
  - Asymmetric: Custom cap/floor ratios supported

### Files Modified
**Config parameters:**
- areal/api/cli_args.py: Added behav_imp_weight_floor
- realhf/api/cli_args.py: Added behav_imp_weight_floor

**Loss functions:**
- areal/utils/functional.py: Updated ppo_actor_loss_fn
- areal/engine/ppo/actor.py: Updated grpo_loss_fn (bug fix + floor)
- realhf/impl/model/utils/ppo_functional.py: Updated actor_loss_fn
- realhf/impl/model/interface/ppo_interface.py: Updated PPOInterface

**Workflow infrastructure:**
- areal/api/workflow_api.py: Added recompute_all_proximal_t() method

## Tests

### New Test Files
- **test_proximal_t_generation_simple.py**: 5 tests for Bug #1
- **test_recompute_timing.py**: 11 tests for recompute logic
- **test_behav_imp_weight_floor.py**: 10 tests for floor parameter
- **test_grpo_loss_logp_alignment.py**: 4 tests guarding against Bug #2

### Test Results
All 56 tests pass:
- test_workflow_executor_wait.py: 26/26 ✓
- test_proximal_t_generation_simple.py: 5/5 ✓
- test_recompute_timing.py: 11/11 ✓
- test_behav_imp_weight_floor.py: 10/10 ✓
- test_grpo_loss_logp_alignment.py: 4/4 ✓

## Documentation
- CHANGES_SUMMARY.md: Quick reference for all changes
- docs/PROXIMAL_T_BUGS_COMPLETE_ANALYSIS.md: Comprehensive analysis

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
zhshgmail pushed a commit that referenced this pull request Oct 9, 2025
This commit fixes critical bugs in segment-wise decoupled PPO and adds
symmetric importance weight clipping capability.

## Bug Fixes

### Bug #1: Incorrect proximal_logprobs_t Length (CRITICAL)
- **File**: areal/engine/sglang_remote.py (lines 183, 240-282)
- **Issue**: Length mismatch during abort-resume causing crashes
- **Root cause**: Used EXTEND instead of REPLACE, duplicating values
- **Fix**: Changed to REPLACE logic for previous tokens
- **Impact**: Prevents crashes like "len(proximal_t)=7 vs len(output)=3"

### Bug #2: Incorrect old_logp Rolling (CRITICAL)
- **File**: areal/engine/ppo/actor.py
- **Issue**: old_logp was double-rolled causing misalignment
- **Root cause**: old_logp already rolled in compute_logp() at line 93
- **Fix**: Removed incorrect second roll in grpo_loss_fn()
- **Impact**: Ensures correct alignment for loss computation

## New Features

### behav_imp_weight_floor Parameter
- **Motivation**: Original behav_imp_weight_cap only bounds high ratios,
  but stable importance sampling needs symmetric bounds
- **Implementation**: Optional floor parameter for lower bound clipping
- **Backward compatible**: floor=None maintains original behavior
- **Usage**:
  - Symmetric: cap=10.0, floor=0.1 creates trust region [0.1, 10.0]
  - Asymmetric: Custom cap/floor ratios supported

### Files Modified
**Config parameters:**
- areal/api/cli_args.py: Added behav_imp_weight_floor
- realhf/api/cli_args.py: Added behav_imp_weight_floor

**Loss functions:**
- areal/utils/functional.py: Updated ppo_actor_loss_fn
- areal/engine/ppo/actor.py: Updated grpo_loss_fn (bug fix + floor)
- realhf/impl/model/utils/ppo_functional.py: Updated actor_loss_fn
- realhf/impl/model/interface/ppo_interface.py: Updated PPOInterface

**Workflow infrastructure:**
- areal/api/workflow_api.py: Added recompute_all_proximal_t() method

## Tests

### New Test Files
- **test_proximal_t_generation_simple.py**: 5 tests for Bug #1
- **test_recompute_timing.py**: 11 tests for recompute logic
- **test_behav_imp_weight_floor.py**: 10 tests for floor parameter
- **test_grpo_loss_logp_alignment.py**: 4 tests guarding against Bug #2

### Test Results
All 56 tests pass:
- test_workflow_executor_wait.py: 26/26 ✓
- test_proximal_t_generation_simple.py: 5/5 ✓
- test_recompute_timing.py: 11/11 ✓
- test_behav_imp_weight_floor.py: 10/10 ✓
- test_grpo_loss_logp_alignment.py: 4/4 ✓

## Documentation
- CHANGES_SUMMARY.md: Quick reference for all changes
- docs/PROXIMAL_T_BUGS_COMPLETE_ANALYSIS.md: Comprehensive analysis

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
zhshgmail pushed a commit that referenced this pull request Oct 10, 2025
Implement segment-wise decoupled PPO algorithm that reduces variance in importance
ratios by introducing per-token proximal policy logprobs (π_proximal_t) to replace
global π_proximal in the AReaL objective function. This enables fine-grained
importance sampling correction when different sequence segments are generated
under different policy versions during asynchronous training.

**Core Algorithm**:
- Original: importance_ratio = π_proximal / π_behave
- Segment-wise: importance_ratio[i] = π_proximal_t[i] / π_behave[i]
- Reduces variance by tracking per-token policy versions during generation
- Supports abort-resume with proximal_t updates when policy changes mid-generation

**Key Components**:

1. **Generation Engine** (areal/engine/sglang_remote.py):
   - Track per-token policy versions during generation
   - Maintain proximal_logprobs_t aligned with output tokens
   - Recompute proximal_t for previous tokens after abort-resume
   - Add recompute_output_logprobs_sync() API for cache recomputation

2. **PPO Loss** (realhf/impl/model/utils/ppo_functional.py):
   - Add behav_imp_weight_floor parameter for symmetric/asymmetric clipping
   - Support both cap and floor for behav_imp_weight filtering
   - Compute segment-wise importance weights: exp(proximal_t - old_logprobs)

3. **Actor Interface** (areal/engine/ppo/actor.py):
   - Roll old_logp to align with rolled proximal_t and prox_logp
   - Fix tensor misalignment bug in loss computation

4. **Workflow API** (areal/api/workflow_api.py):
   - Add recompute_all_proximal_t() to update cached samples before weight sync
   - Track recompute version (RECOMPUTE_VERSION_KEY) to avoid redundant work
   - Thread-safe queue recompute with drain-putback pattern

5. **Model API** (realhf/api/core/model_api.py):
   - Add proximal_logprobs_t field to ModelResponse
   - Extend version tracking for per-token policy versions

**Critical Bug Fixes**:

Bug #1: Incorrect proximal_logprobs_t length (CRITICAL)
- **Issue**: Extended with prompt logprobs and duplicated during abort-resume
- **Impact**: Length mismatch causing crashes (proximal_t.len != output_tokens.len)
- **Fix**: Changed EXTEND to REPLACE logic for abort-resume iterations
- **Location**: areal/engine/sglang_remote.py:240-282

Bug #2: Misaligned tensor roll (CRITICAL)
- **Issue**: proximal_t rolled but old_logp not rolled before loss computation
- **Impact**: Off-by-one misalignment causing wrong importance weights
- **Fix**: Added roll operation for old_logp before ppo_actor_loss_fn()
- **Location**: areal/engine/ppo/actor.py:322-327

**Test Coverage** (19 CPU-only tests, all passing):

Core functionality:
- test_behav_imp_weight_floor.py (10 tests): Cap/floor clipping, symmetric/asymmetric
- test_grpo_loss_logp_alignment.py (4 tests): Tensor rolling behavior, alignment
- test_proximal_t_generation_simple.py (5 tests): Generation, abort-resume, integration

Workflow tests (require einops):
- test_recompute_timing.py (11 tests): Cache/queue recompute, drain-putback
- test_workflow_executor_wait.py (26 tests): Wait behavior, version purge, caching
- test_workflow_helper_functions.py: Helper function unit tests
- test_workflow_wait_bugfixes.py: Edge cases and concurrency

**Files Modified** (29 files):
- Core implementation: 8 files (engine, loss, workflow, API)
- Tests: 7 new test files
- Documentation: CHANGES_SUMMARY.md, PROXIMAL_T_BUGS_COMPLETE_ANALYSIS.md
- Evaluation: eval scripts and configs
- Examples: gsm8k_grpo.py, gsm8k_grpo.yaml

**Design Decisions**:
- Per-token version tracking for fine-grained importance sampling
- Abort-resume pattern for policy updates during generation
- Recompute-before-sync to ensure proximal_t freshness
- Symmetric/asymmetric clipping via cap+floor parameters
- Thread-safe drain-putback for queue recompute

**Validation**:
- All 19 CPU tests pass ✓
- Integration tested with gsm8k_grpo.py (requires GPU)
- Documented in docs/PROXIMAL_T_BUGS_COMPLETE_ANALYSIS.md

**References**:
- AReaL paper (arXiv:2505.24298): Decoupled PPO objective
- This implementation: Extends to segment-wise per-token tracking

Co-Authored-By: Claude <noreply@anthropic.com>
zhshgmail pushed a commit that referenced this pull request Oct 10, 2025
Implement segment-wise decoupled PPO algorithm that reduces variance in importance
ratios by introducing per-token proximal policy logprobs (π_proximal_t) to replace
global π_proximal in the AReaL objective function. This enables fine-grained
importance sampling correction when different sequence segments are generated
under different policy versions during asynchronous training.

**Core Algorithm**:
- Original: importance_ratio = π_proximal / π_behave
- Segment-wise: importance_ratio[i] = π_proximal_t[i] / π_behave[i]
- Reduces variance by tracking per-token policy versions during generation
- Supports abort-resume with proximal_t updates when policy changes mid-generation

**Key Components**:

1. **Generation Engine** (areal/engine/sglang_remote.py):
   - Track per-token policy versions during generation
   - Maintain proximal_logprobs_t aligned with output tokens
   - Recompute proximal_t for previous tokens after abort-resume
   - Add recompute_output_logprobs_sync() API for cache recomputation

2. **PPO Loss** (realhf/impl/model/utils/ppo_functional.py):
   - Add behav_imp_weight_floor parameter for symmetric/asymmetric clipping
   - Support both cap and floor for behav_imp_weight filtering
   - Compute segment-wise importance weights: exp(proximal_t - old_logprobs)

3. **Actor Interface** (areal/engine/ppo/actor.py):
   - Roll old_logp to align with rolled proximal_t and prox_logp
   - Fix tensor misalignment bug in loss computation

4. **Workflow API** (areal/api/workflow_api.py):
   - Add recompute_all_proximal_t() to update cached samples before weight sync
   - Track recompute version (RECOMPUTE_VERSION_KEY) to avoid redundant work
   - Thread-safe queue recompute with drain-putback pattern

5. **Model API** (realhf/api/core/model_api.py):
   - Add proximal_logprobs_t field to ModelResponse
   - Extend version tracking for per-token policy versions

**Critical Bug Fixes**:

Bug #1: Incorrect proximal_logprobs_t length (CRITICAL)
- **Issue**: Extended with prompt logprobs and duplicated during abort-resume
- **Impact**: Length mismatch causing crashes (proximal_t.len != output_tokens.len)
- **Fix**: Changed EXTEND to REPLACE logic for abort-resume iterations
- **Location**: areal/engine/sglang_remote.py:240-282

Bug #2: Misaligned tensor roll (CRITICAL)
- **Issue**: proximal_t rolled but old_logp not rolled before loss computation
- **Impact**: Off-by-one misalignment causing wrong importance weights
- **Fix**: Added roll operation for old_logp before ppo_actor_loss_fn()
- **Location**: areal/engine/ppo/actor.py:322-327

**Test Coverage** (19 CPU-only tests, all passing):

Core functionality:
- test_behav_imp_weight_floor.py (10 tests): Cap/floor clipping, symmetric/asymmetric
- test_grpo_loss_logp_alignment.py (4 tests): Tensor rolling behavior, alignment
- test_proximal_t_generation_simple.py (5 tests): Generation, abort-resume, integration

Workflow tests (require einops):
- test_recompute_timing.py (11 tests): Cache/queue recompute, drain-putback
- test_workflow_executor_wait.py (26 tests): Wait behavior, version purge, caching
- test_workflow_helper_functions.py: Helper function unit tests
- test_workflow_wait_bugfixes.py: Edge cases and concurrency

**Files Modified** (29 files):
- Core implementation: 8 files (engine, loss, workflow, API)
- Tests: 7 new test files
- Documentation: CHANGES_SUMMARY.md, PROXIMAL_T_BUGS_COMPLETE_ANALYSIS.md
- Evaluation: eval scripts and configs
- Examples: gsm8k_grpo.py, gsm8k_grpo.yaml

**Design Decisions**:
- Per-token version tracking for fine-grained importance sampling
- Abort-resume pattern for policy updates during generation
- Recompute-before-sync to ensure proximal_t freshness
- Symmetric/asymmetric clipping via cap+floor parameters
- Thread-safe drain-putback for queue recompute

**Validation**:
- All 19 CPU tests pass ✓
- Integration tested with gsm8k_grpo.py (requires GPU)
- Documented in docs/PROXIMAL_T_BUGS_COMPLETE_ANALYSIS.md

**References**:
- AReaL paper (arXiv:2505.24298): Decoupled PPO objective
- This implementation: Extends to segment-wise per-token tracking

Co-Authored-By: Claude <noreply@anthropic.com>
zhshgmail pushed a commit that referenced this pull request Oct 10, 2025
Implement segment-wise decoupled PPO algorithm that reduces variance in importance
ratios by introducing per-token proximal policy logprobs (π_proximal_t) to replace
global π_proximal in the AReaL objective function. This enables fine-grained
importance sampling correction when different sequence segments are generated
under different policy versions during asynchronous training.

**Core Algorithm**:
- Original: importance_ratio = π_proximal / π_behave
- Segment-wise: importance_ratio[i] = π_proximal_t[i] / π_behave[i]
- Reduces variance by tracking per-token policy versions during generation
- Supports abort-resume with proximal_t updates when policy changes mid-generation

**Key Components**:

1. **Generation Engine** (areal/engine/sglang_remote.py):
   - Track per-token policy versions during generation
   - Maintain proximal_logprobs_t aligned with output tokens
   - Recompute proximal_t for previous tokens after abort-resume
   - Add recompute_output_logprobs_sync() API for cache recomputation

2. **PPO Loss** (realhf/impl/model/utils/ppo_functional.py):
   - Add behav_imp_weight_floor parameter for symmetric/asymmetric clipping
   - Support both cap and floor for behav_imp_weight filtering
   - Compute segment-wise importance weights: exp(proximal_t - old_logprobs)

3. **Actor Interface** (areal/engine/ppo/actor.py):
   - Roll old_logp to align with rolled proximal_t and prox_logp
   - Fix tensor misalignment bug in loss computation

4. **Workflow API** (areal/api/workflow_api.py):
   - Add recompute_all_proximal_t() to update cached samples before weight sync
   - Track recompute version (RECOMPUTE_VERSION_KEY) to avoid redundant work
   - Thread-safe queue recompute with drain-putback pattern

5. **Model API** (realhf/api/core/model_api.py):
   - Add proximal_logprobs_t field to ModelResponse
   - Extend version tracking for per-token policy versions

**Critical Bug Fixes**:

Bug #1: Incorrect proximal_logprobs_t length (CRITICAL)
- **Issue**: Extended with prompt logprobs and duplicated during abort-resume
- **Impact**: Length mismatch causing crashes (proximal_t.len != output_tokens.len)
- **Fix**: Changed EXTEND to REPLACE logic for abort-resume iterations
- **Location**: areal/engine/sglang_remote.py:240-282

Bug #2: Misaligned tensor roll (CRITICAL)
- **Issue**: proximal_t rolled but old_logp not rolled before loss computation
- **Impact**: Off-by-one misalignment causing wrong importance weights
- **Fix**: Added roll operation for old_logp before ppo_actor_loss_fn()
- **Location**: areal/engine/ppo/actor.py:322-327

**Test Coverage** (19 CPU-only tests, all passing):

Core functionality:
- test_behav_imp_weight_floor.py (10 tests): Cap/floor clipping, symmetric/asymmetric
- test_grpo_loss_logp_alignment.py (4 tests): Tensor rolling behavior, alignment
- test_proximal_t_generation_simple.py (5 tests): Generation, abort-resume, integration

Workflow tests (require einops):
- test_recompute_timing.py (11 tests): Cache/queue recompute, drain-putback
- test_workflow_executor_wait.py (26 tests): Wait behavior, version purge, caching
- test_workflow_helper_functions.py: Helper function unit tests
- test_workflow_wait_bugfixes.py: Edge cases and concurrency

**Files Modified** (29 files):
- Core implementation: 8 files (engine, loss, workflow, API)
- Tests: 7 new test files
- Documentation: CHANGES_SUMMARY.md, PROXIMAL_T_BUGS_COMPLETE_ANALYSIS.md
- Evaluation: eval scripts and configs
- Examples: gsm8k_grpo.py, gsm8k_grpo.yaml

**Design Decisions**:
- Per-token version tracking for fine-grained importance sampling
- Abort-resume pattern for policy updates during generation
- Recompute-before-sync to ensure proximal_t freshness
- Symmetric/asymmetric clipping via cap+floor parameters
- Thread-safe drain-putback for queue recompute

**Validation**:
- All 19 CPU tests pass ✓
- Integration tested with gsm8k_grpo.py (requires GPU)
- Documented in docs/PROXIMAL_T_BUGS_COMPLETE_ANALYSIS.md

**References**:
- AReaL paper (arXiv:2505.24298): Decoupled PPO objective
- This implementation: Extends to segment-wise per-token tracking

Co-Authored-By: Claude <noreply@anthropic.com>
zhshgmail pushed a commit that referenced this pull request Oct 10, 2025
Implement segment-wise decoupled PPO algorithm that reduces variance in importance
ratios by introducing per-token proximal policy logprobs (π_proximal_t) to replace
global π_proximal in the AReaL objective function. This enables fine-grained
importance sampling correction when different sequence segments are generated
under different policy versions during asynchronous training.

**Core Algorithm**:
- Original: importance_ratio = π_proximal / π_behave
- Segment-wise: importance_ratio[i] = π_proximal_t[i] / π_behave[i]
- Reduces variance by tracking per-token policy versions during generation
- Supports abort-resume with proximal_t updates when policy changes mid-generation

**Key Components**:

1. **Generation Engine** (areal/engine/sglang_remote.py):
   - Track per-token policy versions during generation
   - Maintain proximal_logprobs_t aligned with output tokens
   - Recompute proximal_t for previous tokens after abort-resume
   - Add recompute_output_logprobs_sync() API for cache recomputation

2. **PPO Loss** (realhf/impl/model/utils/ppo_functional.py):
   - Add behav_imp_weight_floor parameter for symmetric/asymmetric clipping
   - Support both cap and floor for behav_imp_weight filtering
   - Compute segment-wise importance weights: exp(proximal_t - old_logprobs)

3. **Actor Interface** (areal/engine/ppo/actor.py):
   - Roll old_logp to align with rolled proximal_t and prox_logp
   - Fix tensor misalignment bug in loss computation

4. **Workflow API** (areal/api/workflow_api.py):
   - Add recompute_all_proximal_t() to update cached samples before weight sync
   - Track recompute version (RECOMPUTE_VERSION_KEY) to avoid redundant work
   - Thread-safe queue recompute with drain-putback pattern

5. **Model API** (realhf/api/core/model_api.py):
   - Add proximal_logprobs_t field to ModelResponse
   - Extend version tracking for per-token policy versions

**Critical Bug Fixes**:

Bug #1: Incorrect proximal_logprobs_t length (CRITICAL)
- **Issue**: Extended with prompt logprobs and duplicated during abort-resume
- **Impact**: Length mismatch causing crashes (proximal_t.len != output_tokens.len)
- **Fix**: Changed EXTEND to REPLACE logic for abort-resume iterations
- **Location**: areal/engine/sglang_remote.py:240-282

Bug #2: Misaligned tensor roll (CRITICAL)
- **Issue**: proximal_t rolled but old_logp not rolled before loss computation
- **Impact**: Off-by-one misalignment causing wrong importance weights
- **Fix**: Added roll operation for old_logp before ppo_actor_loss_fn()
- **Location**: areal/engine/ppo/actor.py:322-327

**Test Coverage** (19 CPU-only tests, all passing):

Core functionality:
- test_behav_imp_weight_floor.py (10 tests): Cap/floor clipping, symmetric/asymmetric
- test_grpo_loss_logp_alignment.py (4 tests): Tensor rolling behavior, alignment
- test_proximal_t_generation_simple.py (5 tests): Generation, abort-resume, integration

Workflow tests (require einops):
- test_recompute_timing.py (11 tests): Cache/queue recompute, drain-putback
- test_workflow_executor_wait.py (26 tests): Wait behavior, version purge, caching
- test_workflow_helper_functions.py: Helper function unit tests
- test_workflow_wait_bugfixes.py: Edge cases and concurrency

**Files Modified** (29 files):
- Core implementation: 8 files (engine, loss, workflow, API)
- Tests: 7 new test files
- Documentation: CHANGES_SUMMARY.md, PROXIMAL_T_BUGS_COMPLETE_ANALYSIS.md
- Evaluation: eval scripts and configs
- Examples: gsm8k_grpo.py, gsm8k_grpo.yaml

**Design Decisions**:
- Per-token version tracking for fine-grained importance sampling
- Abort-resume pattern for policy updates during generation
- Recompute-before-sync to ensure proximal_t freshness
- Symmetric/asymmetric clipping via cap+floor parameters
- Thread-safe drain-putback for queue recompute

**Validation**:
- All 19 CPU tests pass ✓
- Integration tested with gsm8k_grpo.py (requires GPU)
- Documented in docs/PROXIMAL_T_BUGS_COMPLETE_ANALYSIS.md

**References**:
- AReaL paper (arXiv:2505.24298): Decoupled PPO objective
- This implementation: Extends to segment-wise per-token tracking

Co-Authored-By: Claude <noreply@anthropic.com>
zhshgmail pushed a commit that referenced this pull request Oct 29, 2025
This commit addresses design issues #1-#4 by reorganizing interfaces:

## Changes

**1. Moved to api module (proper location for interfaces):**
- `QueueAPI` → `areal/api/queue_api.py`
- `CacheAPI` → `areal/api/cache_api.py`
- `EventType`, `EventContext`, `EventHandler` → `areal/api/event_api.py`
- `QueueFilter` → `Filter` in `areal/api/filter_api.py`

**2. Created separate queue/cache event handler protocols:**
- `QueueEventHandler` + `QueueEventContext` in `areal/api/queue_event_handler.py`
- `CacheEventHandler` + `CacheEventContext` in `areal/api/cache_event_handler.py`

**3. Simplified event_system.py:**
- Now only contains `EventRegistry` class
- Imports interfaces from api module
- No longer defines protocols

**4. Renamed QueueFilter → Filter:**
- Generic name since it applies to both queue and cache
- Located in api module as proper interface
- StalenessFilter now implements Filter protocol

## Why Protocol as superclass? (Answer to #4)

Protocol enables **structural subtyping** (duck typing with types):

```python
from typing import Protocol

class QueueAPI(Protocol):
    def put(self, item): ...

# No need to inherit!
class MyQueue:
    def put(self, item):
        pass

# Type checker accepts this ✓
def foo(q: QueueAPI):
    q.put(1)

foo(MyQueue())  # Works! Structural typing
```

vs ABC (requires inheritance):
```python
from abc import ABC

class QueueAPI(ABC):
    ...

class MyQueue:  # Must inherit from QueueAPI
    ...
```

**Protocol = Interface without inheritance requirement**

## Remaining Work

Still TODO (per user feedback):
- Redesign ProximalRecomputer with propagator pattern (#3)
- Fix AsyncTaskRunner to require QueueAPI/CacheAPI (#5)
- Remove executor._filter_context (#6)
- Add CacheFilter or apply Filter to all operations (areal-project#7, areal-project#8)
- Fix RemoteInfEngine to not expose queue/cache (areal-project#9)
- Merge event_factory into workflow_factory (areal-project#10)
- Add vLLM recompute support (areal-project#11)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
zhshgmail added a commit that referenced this pull request Nov 4, 2025
- Replace Python for loop with scatter_add_ for GPU performance
- Simplify advantage aggregation description in documentation
- All 18 GSPO tests pass with identical results

Addresses GitHub review comments #1 and #2.
zhshgmail added a commit that referenced this pull request Nov 4, 2025
…eal-project#501)

* feat: implement GSPO (Group-level Sequential Policy Optimization)

Add GSPO support with sequence-level advantage computation instead of token-level.
This implementation includes:

- Add importance_sampling_level configuration ("token" for PPO, "sequence" for GSPO)
- Modify ppo_actor_loss_fn to compute advantages at sequence level for GSPO
- Add comprehensive tests for sequence-level importance sampling
- Add GSPO example with GSM8K dataset configuration
- Update weight_update_meta initialization and validation workflow
- Merge DAPO configs for better flexibility
- Update README with GSPO usage and configuration details

The key difference from standard PPO is that GSPO sums token-level advantages
within each sequence before computing the policy gradient, enabling more stable
sequence-level optimization.

* Address PR review comments

Changes:
- Add more assertions in unit tests for GSPO
- Fix GSPO packed sequences to use cu_seqlens for per-sequence ratios
- Fix GSPO gradient scaling bug by averaging instead of summing advantages
- Add GSPO algorithm description and implementation notes to documentation
- Add PPOActor configuration logging for reproducibility
- Simplify documentation by removing detailed implementation notes
- Update examples to reuse existing gsm8k_grpo.py with GSPO config
- Remove dedicated gsm8k_gspo.py script (not necessary)
- Remove unnecessary overlong penalty parameters from config

GSPO can be enabled with any PPO-like training by setting
importance_sampling_level: sequence in the configuration.

* Ajust code format to pass pipeline black formatter check.

* perf: vectorize GSPO 1D packed tensor computation and simplify docs

- Replace Python for loop with scatter_add_ for GPU performance
- Simplify advantage aggregation description in documentation
- All 18 GSPO tests pass with identical results

Addresses GitHub review comments #1 and #2.

* Ajust code format to pass pipeline black formatter check.

---------

Co-authored-by: bruceli_ed24 <bruce.li2@h-partners.com>
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.

2 participants