vllm.model_executor.layers.fused_moe.oracle.fp8
¶
Functions:
-
make_fp8_moe_quant_config–Create FusedMoEQuantConfig for the specified FP8 Backend.
-
map_fp8_backend–Map user's MoEBackend to Fp8MoeBackend.
-
pad_tp_shard_to_weight_blocks–Pad the TP shard to whole checkpoint blocks, keeping scales rank-local.
-
refine_fp8_moe_block_shape–Compute a refined block shape for block-quantized FP8 MoE weights whose
-
resolve_fp8_moe_weight_block_shape–Return the TP-adapted block shape and refine factor:
-
select_fp8_moe_backend–Select the primary FP8 MoE backend
_get_priority_backends(moe_config, weight_key, activation_key)
¶
Get available backends in priority order based on platform and config.
This function can be extended to become more complex as needed.
Source code in vllm/model_executor/layers/fused_moe/oracle/fp8.py
_humming_fp8_weight_schema(layer, weight, weight_scale)
¶
Build the humming weight schema from the canonical on-device fp8/mxfp8 tensors (scale dtype/shape, block size), not the producing quant method.
Source code in vllm/model_executor/layers/fused_moe/oracle/fp8.py
make_fp8_moe_quant_config(fp8_backend, w1_scale, w2_scale, a1_scale, a2_scale, w1_bias=None, w2_bias=None, block_shape=None, per_act_token_quant=False, per_out_ch_quant=False, swiglu_limit=None, gemm1_alpha=None, gemm1_beta=None, layer=None)
¶
Create FusedMoEQuantConfig for the specified FP8 Backend. The FusedMoEQuantConfig holds the scales that are used at runtime by the Modular Kernel abstraction.
Note that certain kernels (e.g. Flashinfer CUTLASS) need special Quant configs to handle non-standard inputs to their kernel interfaces.
In a future PR, we will have this function should be a method of the modular kernel itself.
Source code in vllm/model_executor/layers/fused_moe/oracle/fp8.py
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 | |
map_fp8_backend(runner_backend)
¶
Map user's MoEBackend to Fp8MoeBackend.
Source code in vllm/model_executor/layers/fused_moe/oracle/fp8.py
pad_tp_shard_to_weight_blocks(config, weight_block_size)
¶
Pad the TP shard to whole checkpoint blocks, keeping scales rank-local.
Source code in vllm/model_executor/layers/fused_moe/oracle/fp8.py
refine_fp8_moe_block_shape(config, weight_block_size)
¶
Compute a refined block shape for block-quantized FP8 MoE weights whose checkpoint blocks cannot be sharded exactly across TP ranks.
TP shards the intermediate dim of the expert weights, so a per-shard size that is not a multiple of the checkpoint's block size makes the checkpoint's block scales impossible to shard exactly. When a finer block size (>= 32) divides both the checkpoint blocks and all involved dims, the weight scales can be refined to that granularity at load time (a lossless upsampling, since the refined block divides the checkpoint block). Only Triton-based kernels can consume the refined block shape: they take it as a runtime argument, while the other backends require the native 128x128 blocks. The refined shape is encoded in the QuantKey used for backend selection, so backends that only support 128x128 blocks are rejected by the oracle automatically.
Returns the refined [block_n, block_k] shape, or None if no refinement is needed or possible.
Source code in vllm/model_executor/layers/fused_moe/oracle/fp8.py
resolve_fp8_moe_weight_block_shape(config, weight_block_size, activation_key, is_checkpoint_fp8_serialized)
¶
Return the TP-adapted block shape and refine factor: refine if kernels allow, else pad to the TP shard.
Source code in vllm/model_executor/layers/fused_moe/oracle/fp8.py
select_fp8_moe_backend(config, weight_key, activation_key, allow_vllm_cutlass=False)
¶
Select the primary FP8 MoE backend Note: Shape-specific fallbacks may still occur at runtime.
Source code in vllm/model_executor/layers/fused_moe/oracle/fp8.py
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 531 532 533 534 535 536 | |