Skip to content

Conversation

@ZSL98
Copy link
Collaborator

@ZSL98 ZSL98 commented Dec 23, 2025

What does this PR do?

Bypass the CPU in the checkpoint engine for fully_async mode.

Currently, in fully_async mode, each time the weights are updated, they are offloaded to the CPU, then copied to the h2d_buffer, and finally copied to the broadcast buffer.

The offload-to-CPU operation seems unnecessary. So this PR adds an additional configuration named bypass_cpu to bypass the CPU cache. Early-stage experiments show benefits.

Checklist Before Starting

Test

For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc.

API and Usage Example

Demonstrate how the API changes if any, and provide usage example(s) if possible.

# Add code snippet or script demonstrating how to use this

Design & Code Changes

Demonstrate the high-level design if this PR is complex, and list the specific changes.

Checklist Before Submitting

Important

Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an optimization to bypass the CPU in the checkpoint engine for fully_async mode, which should improve performance by reducing data copies between host and device. A new configuration bypass_cpu is added to control this behavior. The changes in checkpoint_engine.py and fsdp_workers.py correctly implement this new path. My main feedback is to improve the naming of some functions and variables that have become misleading with this change, to ensure code clarity and maintainability.

@zpltys
Copy link
Contributor

zpltys commented Dec 24, 2025

The reason I cache params to cpu is to further support parameters version management. But I think it is a good pr. Can you update the relevant experiments/readme as in the commit.

@ZSL98 ZSL98 marked this pull request as ready for review December 26, 2025 01:32
@ZSL98
Copy link
Collaborator Author

ZSL98 commented Dec 26, 2025

@zpltys Sorry for the delay. I have updated the README and conducted some basic experiments.

With a single-node Ascend A2 server and a 4B model, enabling bypass_cpu can reduce the total sync weight time from 0.84s to 0.64s (a 24% reduction), reduce the cache cost from 0.16s to 0.10s, and reduce the update cost from 0.26s to 0.21s. All numbers are averages over 500 trials. bypass_cpu is set to False by default, so it does not conflict with your original setting. Since we do not have GPU machines, the numbers on larger-scale GPU nodes remain untested. Hope these numbers can be tested by the community.

Besides, fully_async, together with the checkpoint engine, can work well on Ascend NPUs with some adaptations, as in #4658. We may first have a discussion internally and then figure out how to support fully_async and the checkpoint engine more gracefully. Many thanks.

@ZSL98
Copy link
Collaborator Author

ZSL98 commented Dec 27, 2025

@zpltys @ArronHZG Would you please help review the code?

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