Commit 1466760
authored
[misc] fix: no need to use world_size to decide whether to use full_tensor in FSDP2 (#1529)
[misc] fix: no need to use world_size to decide whether to use
full_tensor() for FSDP2 state_dict() when world_size==1
### Checklist Before Starting
- [x] Search for similar PR(s).
### What does this PR do?
This PR simplifies the parameter loading logic within the
`FSDPVLLMShardingManager` by removing an unnecessary `world_size` check
when determining whether to call `full_tensor()` on parameters obtained
from an FSDP2 model's `state_dict()`. As the FSDP2 parameters are all
`DTensor`.
### High-Level Design
The change modifies the update_params method. When loading weights into
the vLLM model, parameters from the FSDP state_dict() (which might be
ShardedTensor or DTensor instances under FSDP2 when world_size == 1) are
converted to full tensors using param.full_tensor(). This PR ensures
this conversion happens if the full_tensor() method is available on the
parameter, without an additional, potentially incorrect, check against
world_size == 1.
### Specific Changes
Skip. See file changes
### API
No
### Usage Example
No
### Test
No CI changes
### Additional Info.
- **Issue Number**: No
- **Training**: [Note which backend this PR will affect: FSDP
- **Inference**: [Note which backend this PR will affect: vLLM
### Checklist Before Submitting
- [x] Read the [Contribute
Guide](https://github.com/volcengine/verl?tab=readme-ov-file#contribution-guide).
- [x] Apply [pre-commit
checks](https://github.com/volcengine/verl?tab=readme-ov-file#code-linting-and-formatting).
- [ ] Add `[BREAKING]` to the PR title if it breaks any API.
- [ ] Update the documentation about your changes in the
[docs](https://github.com/volcengine/verl/tree/main/docs).
- [ ] Add CI test(s) if neccessary.1 parent 11622fc commit 1466760
1 file changed
+9
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| |||
52 | 58 | | |
53 | 59 | | |
54 | 60 | | |
55 | | - | |
| 61 | + | |
56 | 62 | | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
61 | | - | |
| 67 | + | |
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
| |||
188 | 194 | | |
189 | 195 | | |
190 | 196 | | |
191 | | - | |
192 | 197 | | |
193 | | - | |
| 198 | + | |
194 | 199 | | |
0 commit comments