Commit c120dad
[BugFix] Fix static_forward_context cleanup and MTP draft loading (vllm-project#11491)
### What this PR does / why we need it?
This PR fixes two issues in `ModelNetLoaderElastic` when loading models
via D2D netloader, especially in MTP / speculative decoding scenarios.
**1. Clear `static_forward_context` before fallback**
When elastic loading fails and the loader falls back to
`DefaultModelLoader`, `initialize_model` may have already registered
attention layers into `compilation_config.static_forward_context`.
Without clearing these registrations, `revert_to_default()` can hit
duplicate-registration errors or leave stale layer state.
Changes:
- Add `_get_static_forward_context()` and
`_clear_static_forward_context()` helpers.
- Clear both the passed `vllm_config` and the global
`get_current_vllm_config()` (when available), with deduplication by
object id.
- Invoke cleanup in the fallback path, right before
`revert_to_default()`.
**2. Improve MTP draft model netloader efficiency and synchronization**
In MTP scenarios, target and draft models are loaded sequentially via
netloader. Two problems were observed:
- **DRAM cache inefficiency for draft model**: When `INT8_CACHE=dram`,
the draft model's `ElasticServer` also cached int8 weights to CPU DRAM.
Draft models are typically much smaller; keeping int8 cache in HBM
avoids unnecessary CPU↔NPU transfers during weight serving and improves
startup/serving efficiency.
- **Race across ranks**: Draft model loading could start before all
ranks finished target model netloader setup. A
`torch.distributed.barrier()` is added after target model loading (only
when `speculative_config` is set) so all ranks synchronize before draft
loading proceeds.
Changes:
- Draft `ElasticServer` uses `int8_cache="hbm"` when user config is not
`"no"` (overrides `"dram"` for draft only).
- Add `_sync_target_netloader_before_draft()` barrier after target model
load completes.
- Draft model path does not trigger the barrier.
fixes vllm-project#11553
### Does this PR introduce _any_ user-facing change?
No API or CLI changes.
### How was this patch tested?
Pre-commit passed
Unit tests passed
E2E verified: Elastic server start time has been significantly reduced
under netloader + MTP with 'int8_cache=dram' serving on 4 * Ascend 800I
A3 scenario.
**fix1**
**before:**
<img width="1589" height="804" alt="image"
src="https://github.com/user-attachments/assets/22c71938-d8ed-4e12-aa2d-6451e71fbad7"
/>
**after:**
<img width="1612" height="570" alt="image"
src="https://github.com/user-attachments/assets/07315209-a28b-4649-bdcc-ed92d2f905ca"
/>
curl coordinator:
<img width="1035" height="586" alt="image"
src="https://github.com/user-attachments/assets/ad5975c4-b3d7-494b-b539-8824b71dc686"
/>
**fix2**
**before:**
<img width="1017" height="503" alt="image"
src="https://github.com/user-attachments/assets/155f74f4-a254-4a73-aff7-a203c91c44e2"
/>
**after:**
<img width="1003" height="494" alt="image"
src="https://github.com/user-attachments/assets/569efaf8-7562-4826-91f7-d8148047bfab"
/>
curl coordinator:
<img width="1032" height="635" alt="image"
src="https://github.com/user-attachments/assets/7a97c969-d5ad-48ef-a9a5-5be484c9a951"
/>
- vLLM version: v0.23.0
- vLLM main:
vllm-project/vllm@1f486d9
---------
Signed-off-by: yilunh <hanyilun1@huawei.com>
Co-authored-by: yilunh998 <yilunh998@users.noreply.github.com>
Co-authored-by: yilunh <hanyilun1@huawei.com>1 parent beb54c2 commit c120dad
2 files changed
Lines changed: 221 additions & 2 deletions
File tree
- tests/ut/model_loader/netloader
- vllm_ascend/model_loader/netloader
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
136 | 161 | | |
137 | 162 | | |
138 | 163 | | |
| |||
219 | 244 | | |
220 | 245 | | |
221 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
222 | 341 | | |
223 | 342 | | |
224 | 343 | | |
| |||
229 | 348 | | |
230 | 349 | | |
231 | 350 | | |
| 351 | + | |
232 | 352 | | |
233 | 353 | | |
234 | 354 | | |
| |||
248 | 368 | | |
249 | 369 | | |
250 | 370 | | |
| 371 | + | |
251 | 372 | | |
252 | 373 | | |
253 | 374 | | |
254 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
255 | 406 | | |
256 | 407 | | |
257 | 408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
38 | 44 | | |
39 | 45 | | |
40 | 46 | | |
| |||
136 | 142 | | |
137 | 143 | | |
138 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
139 | 200 | | |
140 | 201 | | |
141 | 202 | | |
| |||
240 | 301 | | |
241 | 302 | | |
242 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
243 | 307 | | |
244 | 308 | | |
245 | 309 | | |
| |||
293 | 357 | | |
294 | 358 | | |
295 | 359 | | |
| 360 | + | |
296 | 361 | | |
297 | 362 | | |
298 | 363 | | |
| |||
301 | 366 | | |
302 | 367 | | |
303 | 368 | | |
304 | | - | |
| 369 | + | |
305 | 370 | | |
306 | 371 | | |
307 | 372 | | |
| |||
321 | 386 | | |
322 | 387 | | |
323 | 388 | | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
324 | 392 | | |
325 | 393 | | |
326 | | - | |
| 394 | + | |
327 | 395 | | |
328 | 396 | | |
329 | 397 | | |
| |||
0 commit comments