Repository navigation
Fix pageable H2D copies in Gated DeltaNet PyTorch fallback - #45665
Merged
Merged
Conversation
Cyrilvallez
approved these changes
Apr 28, 2026
Cyrilvallez
left a comment
Member
There was a problem hiding this comment.
LGTM, it's indeed always better to initialize directly rather than calling to
Cyrilvallez
enabled auto-merge
April 28, 2026 05:25
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: olmo_hybrid, qwen3_5, qwen3_5_moe, qwen3_next |
Contributor
Author
|
@Cyrilvallez Thanks for the approval! It looks like there are still two workflows awaiting maintainer approval, and doc_build_status_check is still pending. Could you please approve/run them when you get a chance? Thanks! |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Merged
2 tasks done
lxb007981
added a commit
to lxb007981/verl
that referenced
this pull request
Sep 28, 2026
…karound Transformers PR #45665 removed a blocking CPU-to-device state copy. Removing that implicit synchronization exposed an NPU performance regression, with allocator retries and increased actor time. Restore the wait before initial recurrent state allocation in the native gated delta rule fallback while retaining device-local zeros. Gate the workaround behind VERL_QWEN3_NEXT_NPU_SYNC_BEFORE_STATE=1. Require Transformers 5.10.4 and verify upstream source hashes before patching. Preserve existing FLA selection. In the measured workload, actor time dropped from 113.94s to 45.16s and allocator retries fell from 144 to zero. Upstream: huggingface/transformers#45665
wucong25
pushed a commit
to verl-project/verl
that referenced
this pull request
Sep 29, 2026
…karound (#8033) ### What does this PR do? Transformers PR #45665 removed a blocking CPU-to-device state copy. Removing that implicit synchronization exposed an NPU performance regression, with allocator retries and increased actor time. Restore the wait before initial recurrent state allocation in the native gated delta rule fallback while retaining device-local zeros. Gate the workaround behind VERL_QWEN3_NEXT_NPU_SYNC_BEFORE_STATE=1. Require Transformers 5.10.4 and verify upstream source hashes before patching. Preserve existing FLA selection. In the measured workload, actor time dropped from 113.94s to 45.16s and allocator retries fell from 144 to zero. Upstream: huggingface/transformers#45665 ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `veomni`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data`, `cfg`, `reward`, `fully_async`, `one_step_off` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching`
lxb007981
added a commit
to lxb007981/verl
that referenced
this pull request
Sep 29, 2026
…karound Transformers PR #45665 removed a blocking CPU-to-device state copy. Removing that implicit synchronization exposed an NPU performance regression, with allocator retries and increased actor time. Restore the wait before initial recurrent state allocation in the native gated delta rule fallback while retaining device-local zeros. Gate the workaround behind VERL_QWEN3_NEXT_NPU_SYNC_BEFORE_STATE=1. Require Transformers 5.10.4 and verify upstream source hashes before patching. Preserve existing FLA selection. In the measured workload, actor time dropped from 113.94s to 45.16s and allocator retries fell from 144 to zero. Upstream: huggingface/transformers#45665
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR removes unnecessary pageable Host-to-Device copies in the pure-PyTorch fallback for Gated DeltaNet (
torch_chunk_gated_delta_ruleandtorch_recurrent_gated_delta_rule), used by Qwen3-Next, Qwen3.5, Qwen3.5 MoE and OLMo-Hybrid whenflash-linear-attentionis not installed.The current implementation initializes
last_recurrent_stateandcore_attn_outviatorch.zeros(...).to(value).Because

torch.zeros(...)is called without a device argument, the tensor is first allocated in pageable host memory and zero-filled on CPU, then.to(value)triggers: pageable H2D copy and an implicit synchronization (.to()defaults tonon_blocking=False).e.g. In nsys traces it looks like following:
This PR allocates these tensors directly on the target device and dtype, eliminating the H2D copies and the implicit syncs entirely.
Nsight system traces:
Code Agent Policy
The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. We are currently bottlenecked by our ability to review and respond to them. As a result,
we ask that new users do not submit pure code agent PRs at this time.
You may use code agents in drafting or to help you diagnose issues. We'd also ask autonomous "OpenClaw"-like agents
not to open any PRs or issues for the moment.
PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this
repeatedly or maliciously.
This is a rapidly-evolving situation that's causing significant shockwaves in the open-source community. As a result,
this policy is likely to be updated regularly in the near future. For more information, please read
CONTRIBUTING.md.Before submitting
Pull Request section?
to it if that's the case. Not an existing issue.
documentation guidelines, and
here are tips on formatting docstrings. No need for documentation.
AI-assisted disclosure
Didn't use AI
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
cc @Cyrilvallez @zucchini-nlp @ArthurZucker