vllm.models.deepseek_v4 ¶
DeepSeek V4 model — hardware-isolated entry point.
The actual implementation lives under nvidia/ and amd/; this module picks the right one for the current platform and re-exports the public classes used by the model registry and quantization config lookup.
Modules:
-
amd– -
attention–DeepseekV4 MLA Attention Layer
-
common– -
compressor– -
nvidia– -
quant_config–Quantization config for DeepSeek V4.
-
sparse_mla–DeepSeek-V4 FlashMLA sparse backend, metadata, and metadata builder.
-
xpu–
Classes:
-
DSparkDeepseekV4ForCausalLM– -
DeepSeekV4MTP– -
DeepseekV4FP8Config–FP8 config for DeepSeek V4 with expert-dtype-aware MoE dispatch.
-
DeepseekV4ForCausalLM–
DSparkDeepseekV4ForCausalLM ¶
Bases: Module
Methods:
-
compute_logits–Base logits U_k = lm_head(norm(head_hidden)).
-
load_weights–Load the
mtp.{0,1,2}.*draft weights from the target checkpoint.
Source code in vllm/models/deepseek_v4/nvidia/dspark.py
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 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 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 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
_remap_dspark_name(name) ¶
Map a checkpoint mtp.{i}.* name to this model's parameter path.
Returns None for non-mtp weights (owned by the target model).
Source code in vllm/models/deepseek_v4/nvidia/dspark.py
compute_logits(hidden_states) ¶
Base logits U_k = lm_head(norm(head_hidden)).
load_weights(weights) ¶
Load the mtp.{0,1,2}.* draft weights from the target checkpoint.
Non-mtp weights (embed/head/main layers) belong to the target model and are skipped here. embed_tokens/lm_head are aliased from the target.
Source code in vllm/models/deepseek_v4/nvidia/dspark.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 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 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
DeepSeekV4MTP ¶
Bases: Module
Source code in vllm/models/deepseek_v4/nvidia/mtp.py
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 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 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 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | |
_rewrite_spec_layer_name(spec_layer, name) ¶
Rewrite the weight name to match the format of the original model. Add .mtp_block for modules in transformer layer block for spec layer and rename shared layer weights to be top level.
Source code in vllm/models/deepseek_v4/nvidia/mtp.py
DeepseekV4FP8Config ¶
Bases: Fp8Config
FP8 config for DeepSeek V4 with expert-dtype-aware MoE dispatch.
DeepSeek V4 checkpoints always use FP8 block quantization for linear/attention layers. The MoE expert weights vary by checkpoint: - expert_dtype="fp4" (e.g. DeepSeek-V4-Flash): MXFP4 experts with ue8m0 (e8m0fnu) FP8 linear scales. - expert_dtype="fp8" (e.g. DeepSeek-V4-Flash-Base): FP8 block experts with float32 FP8 linear scales.
The dispatch and the linear scale dtype are both keyed off expert_dtype from the model's hf_config; missing values default to "fp4" so existing FP4 checkpoints stay unchanged.
NOTE: expert_dtype is resolved lazily because this config is constructed during VllmConfig setup, before set_current_vllm_config is active. Reading hf_config eagerly in __init__ would always see the default "fp4" and silently misroute Flash-Base checkpoints.
Source code in vllm/models/deepseek_v4/quant_config.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 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 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 | |
_is_quark_mxfp4_ocp(hf_quant_cfg) staticmethod ¶
True for AMD-Quark exports whose global scheme is MXFP4.
Source code in vllm/models/deepseek_v4/quant_config.py
DeepseekV4ForCausalLM ¶
Bases: Module, SupportsPP, SupportsEagle3, DeepseekV4MixtureOfExperts
Methods:
-
get_mtp_target_hidden_states–Pre-hc_head residual stream buffer (max_num_batched_tokens,
Source code in vllm/models/deepseek_v4/nvidia/model.py
1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 | |
get_mtp_target_hidden_states() ¶
Pre-hc_head residual stream buffer (max_num_batched_tokens, hc_mult * hidden_size) for the MTP draft model. Populated by forward(); valid after each target step.