Skip to content

[RL][Feature] R3 Phase 2: routing data follows KVCache block lifecycl…#7099

Draft
gongshaotian wants to merge 1 commit intoPaddlePaddle:release/2.5from
gongshaotian:vibe_r3_2.5
Draft

[RL][Feature] R3 Phase 2: routing data follows KVCache block lifecycl…#7099
gongshaotian wants to merge 1 commit intoPaddlePaddle:release/2.5from
gongshaotian:vibe_r3_2.5

Conversation

@gongshaotian
Copy link
Copy Markdown
Collaborator

…e (swap/storage/PD)

Implement Phase 2 of RoutingReplay (R3) to make routing data compatible with CPUPrefixCache swap, KVCacheStorage persistence, and PD disaggregation.

Key changes:

  • Replace large GPU routing_replay_table (~3.8GB) with small transient buffer (~3.8MB)
  • Add SharedMemory-based routing_host_buffer/routing_swap_buffer for cross-process access
  • Routing data now follows KVCache blocks through GPU<->CPU swap (CTM numpy memcpy)
  • Routing data persists/restores with KVCacheStorage (mooncake/file backends)
  • PD disaggregation: P gathers prefill routing via ZMQ, D writes to routing_host_buffer
  • Move routing aggregation from Worker to Engine/TokenProcessor layer
  • AuxBlockDataSpec abstraction for extensible block-bound auxiliary data

Files: cache_data, cache_transfer_manager, prefix_cache_manager, common_engine, request, resource_manager_v1, forward_meta, moe, routing_indices_cache, pre_and_post_process, token_processor, gpu_model_runner

Motivation

💡 If this PR is a Cherry Pick, the PR title needs to follow the format by adding the [Cherry-Pick] label at the very beginning and appending the original PR ID at the end. For example, [Cherry-Pick][CI] Add check trigger and logic(#5191)

💡 如若此PR是Cherry Pick,PR标题需遵循格式,在最开始加上[Cherry-Pick]标签,以及最后面加上原PR ID,例如[Cherry-Pick][CI] Add check trigger and logic(#5191)

Modifications

Usage or Command

Accuracy Tests

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Mar 31, 2026

Thanks for your contribution!

…e (swap/storage/PD)

Implement dual-buffer architecture for routing replay:
- GPU transient buffer [max_num_batched_tokens, L, K] with Triton v2 kernel
- SharedMemory routing_host_buffer for cross-process Engine/Worker/CTM sharing
- Lazy SharedMemory attach in Worker and TokenProcessor (Engine creates after profiling)
- CTM routing write/read for swap and storage backends
- PD disaggregation: P gathers routing via send_first_token, D writes to host buffer
- Local store persistence verified end-to-end

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.51282% with 310 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/2.5@2efab46). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/cache_manager/cache_transfer_manager.py 8.84% 102 Missing and 1 partial ⚠️
...model_executor/layers/moe/routing_indices_cache.py 18.69% 100 Missing ⚠️
fastdeploy/output/token_processor.py 6.77% 54 Missing and 1 partial ⚠️
fastdeploy/engine/common_engine.py 5.55% 16 Missing and 1 partial ⚠️
fastdeploy/model_executor/pre_and_post_process.py 0.00% 16 Missing ⚠️
fastdeploy/cache_manager/prefix_cache_manager.py 18.18% 8 Missing and 1 partial ⚠️
fastdeploy/model_executor/layers/moe/moe.py 0.00% 4 Missing ⚠️
fastdeploy/engine/engine.py 0.00% 1 Missing and 1 partial ⚠️
fastdeploy/engine/request.py 77.77% 1 Missing and 1 partial ⚠️
fastdeploy/cache_manager/cache_data.py 93.33% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@              Coverage Diff               @@
##             release/2.5    #7099   +/-   ##
==============================================
  Coverage               ?   68.69%           
==============================================
  Files                  ?      390           
  Lines                  ?    54465           
  Branches               ?     8565           
==============================================
  Hits                   ?    37413           
  Misses                 ?    14345           
  Partials               ?     2707           
Flag Coverage Δ
GPU 68.69% <20.51%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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