Skip to content

Conversation

@liyonghua0910
Copy link
Collaborator

@liyonghua0910 liyonghua0910 commented Dec 10, 2025

Motivation

当前的 event_loop_normal 有两个状态信号,model_weight_status 是一个 SharedMemory,model_weights_signal 是一个 numpy 数组。每轮循环中,这个 np 数组会先读取 shm 的值,做一次 broadcast 之后再把自身值反向写回 shm。

另一方面,api server 也会去写 shm,在收到 /update_model_weight 调用时更新 shm 的状态为 UPDATING。如果 api server 写 shm 时,worker 刚好执行到 np 数组读取 shm 之后、写回 shm之前,np 数组读的是 CLEARED 状态,就会把 shm 的 UPDATING 信号覆盖掉,导致更新权重超时。

如果在清除权重后检测 shm 值为 CLEARED 时 sleep 住的话,可以保证 np 数组在参数 offload 期间不会去读/写 shm 的值,直到下一次 api server 收到 update 信号时 worker 才解冻,这样下一次 np 数组读的就是正确的 UPDATING 信号,不会读到上一轮的 CLEARED 信号。

💡 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

paddle-bot bot commented Dec 10, 2025

Thanks for your contribution!

gzy19990617
gzy19990617 previously approved these changes Dec 10, 2025
@codecov-commenter
Copy link

codecov-commenter commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 9.52381% with 19 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/2.4@c5c43e3). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/rl/dynamic_weight_manager.py 12.50% 14 Missing ⚠️
fastdeploy/worker/worker_process.py 0.00% 5 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             release/2.4    #5487   +/-   ##
==============================================
  Coverage               ?   59.02%           
==============================================
  Files                  ?      327           
  Lines                  ?    40632           
  Branches               ?     6173           
==============================================
  Hits                   ?    23983           
  Misses                 ?    14795           
  Partials               ?     1854           
Flag Coverage Δ
GPU 59.02% <9.52%> (?)

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.

@Jiang-Jia-Jun Jiang-Jia-Jun merged commit 7019afb into PaddlePaddle:release/2.4 Dec 11, 2025
12 of 16 checks passed
@liyonghua0910 liyonghua0910 changed the title [BugFix] fix instability after clearing weight [Cherry-Pick] [BugFix] fix instability after clearing weight (#5493) Dec 11, 2025
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.

4 participants