vllm.model_executor.layers.quantization.utils.marlin_utils_fp8 ¶
Functions:
-
mxfp8_marlin_process_scales–Reorder scales for e8m0 kernel layout and convert to float8_e8m0fnu.
-
pack_fp8_to_int32–Repack FP8 weights to gptq format (packed int32 elements)
-
prepare_fp8_moe_layer_for_marlin–Shuffle weights and scales into marlin format.
-
prepare_mxfp8_layer_for_marlin–Repack MXFP8 weights and scales into Marlin kernel format.
-
prepare_mxfp8_moe_layer_for_marlin–Repack MXFP8 MoE weights and scales into Marlin kernel format.
_moe_pad_last(x, n, padded_n) ¶
Zero-pad the last dim of a (E, ..., n) tensor to padded_n.
Source code in vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py
_moe_pad_shard_rows(x, n, padded_n) ¶
Zero-pad each gate/up shard of a (E, 2 * n, ...) tensor to padded_n rows. FP8 zero decodes to 0.0, so the padded rows contribute nothing.
Source code in vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py
mxfp8_marlin_process_scales(marlin_scales) ¶
Reorder scales for e8m0 kernel layout and convert to float8_e8m0fnu.
Source code in vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py
pack_fp8_to_int32(fp8_tensor, size_k_first=True) ¶
Repack FP8 weights to gptq format (packed int32 elements)
Source code in vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py
prepare_fp8_moe_layer_for_marlin(layer, w13_weight, w2_weight, w13_weight_scale, w2_weight_scale) ¶
Shuffle weights and scales into marlin format.
Note that this function has the side effect of adding a workspace attribute to the layer. This workspace does not need to be registered as a Parameter as it is not used during weight reloading.
Source code in vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py
239 240 241 242 243 244 245 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 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 | |
prepare_mxfp8_layer_for_marlin(layer) ¶
Repack MXFP8 weights and scales into Marlin kernel format.
Expects the layer to have
- weight: [N, K] float8_e4m3fn
- weight_scale: [N, K//32] uint8 (e8m0 encoded)
- input_size_per_partition / output_size_per_partition
Source code in vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py
prepare_mxfp8_moe_layer_for_marlin(layer, w13, w2, w13_scale, w2_scale) ¶
Repack MXFP8 MoE weights and scales into Marlin kernel format.
Parameters:
-
(layer¶Module) –MoE layer (used to read params_dtype and attach workspace).
-
(w13¶Tensor) –[E, 2*N, K] float8_e4m3fn weights.
-
(w2¶Tensor) –[E, K, N] float8_e4m3fn weights.
-
(w13_scale¶Tensor) –[E, 2*N, K//32] uint8 e8m0 scales.
-
(w2_scale¶Tensor) –[E, K, N//32] uint8 e8m0 scales.
Returns:
Source code in vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | |