vllm.model_executor.layers.quantization.utils.humming.moe
¶
Configure, prepare weights for, and assemble Humming MoE kernels.
Functions:
-
convert_to_humming_moe_kernel_format–Convert MoE weights from checkpoint format to Humming kernel format.
-
select_humming_moe_experts–Select the primary Humming MoE Experts class
-
stage_moe_weights_for_humming–Install canonical weights and scales for Humming's layer-based converter.
_convert_sublayer_to_humming(layer, sublayer_name, shape_n, shape_k, weight_schema, input_schema, num_experts, param_dtype)
¶
Convert a sublayer's weights from checkpoint format to Humming format.
Returns:
Source code in vllm/model_executor/layers/quantization/utils/humming/moe.py
_extract_sublayer_tensors(layer, sublayer_name)
¶
Extract a sublayer's live params and persistent buffers.
Source code in vllm/model_executor/layers/quantization/utils/humming/moe.py
_prepare_and_transform_sublayer(layer, sublayer_name, shape_n, shape_k, weight_schema, input_schema, has_bias, num_experts, param_dtype)
¶
Prepare Humming configuration and transform one sublayer's tensors.
Source code in vllm/model_executor/layers/quantization/utils/humming/moe.py
_process_single_sublayer(layer, sublayer_name, shape_n, shape_k, weight_schema, input_schema, has_bias, num_experts, param_dtype, force_weight_schema=None, allow_input_schema_fallback=True)
¶
Process a single sublayer: convert, optionally requant, prepare, and transform.
This combines the common logic from convert_to_humming_moe_kernel_format for processing a single sublayer.
Parameters:
-
(layer¶RoutedExperts) –The RoutedExperts layer
-
(sublayer_name¶str) –Name of the sublayer (e.g., "w13", "w2")
-
(shape_n¶int) –Output dimension size
-
(shape_k¶int) –Input dimension size
-
(weight_schema¶Any) –Initial weight quantization schema
-
(input_schema¶Any) –Initial input quantization schema
-
(has_bias¶bool) –Whether the layer has bias terms
-
(num_experts¶int) –Number of experts
-
(param_dtype¶dtype) –Parameter data type
-
(force_weight_schema¶Any | None, default:None) –Optional schema to force requantization to
-
(allow_input_schema_fallback¶bool, default:True) –Whether incompatible input schemas may be replaced.
Returns:
-
tuple[Any, Any, LayerConfig]–Tuple of the final weight schema, input schema, and Humming layer config.
Source code in vllm/model_executor/layers/quantization/utils/humming/moe.py
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 | |
_replace_layer_parameters(layer, sublayer_name, tensors, preserve_bias=False)
¶
Replace layer parameters for a sublayer with new tensors.
Parameters:
-
(layer¶RoutedExperts) –The RoutedExperts layer
-
(sublayer_name¶str) –Name of the sublayer (e.g., "w13", "w2")
-
(tensors¶dict[str, Tensor]) –Dict of parameter name to tensor
-
(preserve_bias¶bool, default:False) –If True, don't delete bias parameters
Source code in vllm/model_executor/layers/quantization/utils/humming/moe.py
convert_to_humming_moe_kernel_format(layer, quant_config=None, sublayer_configs=None, weight_schema=None, input_schema=None, force_weight_schema=None, allow_input_schema_fallback=True)
¶
Convert MoE weights from checkpoint format to Humming kernel format.
This function processes weights for each sublayer (w13, w2) by: 1. Converting from checkpoint format to humming format if needed 2. Force requanting if a different quantization schema is specified 3. Preparing layer metadata for the Humming kernel 4. Transforming weights for inference
Parameters:
-
(layer¶RoutedExperts) –The RoutedExperts layer containing weights to process
-
(quant_config¶dict | None, default:None) –Optional quantization config dict. Required if weight_schema or input_schema are None. Used to build schemas via BaseWeightSchema.from_config().
-
(sublayer_configs¶dict[str, Any] | None, default:None) –Optional configuration dict for each sublayer (w13, w2). Each config must have "shape_n" and "shape_k" keys. If None, configs are built from layer.moe_config properties.
-
(weight_schema¶Any | None, default:None) –Optional initial weight quantization schema. If None, built from quant_config.
-
(input_schema¶Any | None, default:None) –Optional initial input quantization schema. If None, built from quant_config or env vars.
-
(force_weight_schema¶Any | None, default:None) –Optional schema to force requantization to
-
(allow_input_schema_fallback¶bool, default:True) –Whether incompatible input schemas may be replaced.
Side effects
- Modifies layer parameters in place
- Sets layer.weight_schemas and layer.input_schemas
- Sets layer.humming_configs for quant config construction
Source code in vllm/model_executor/layers/quantization/utils/humming/moe.py
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 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | |
select_humming_moe_experts(config, weight_key, activation_key)
¶
Select the primary Humming MoE Experts class Note: Shape-specific fallbacks may still occur at runtime.
Source code in vllm/model_executor/layers/quantization/utils/humming/moe.py
stage_moe_weights_for_humming(layer, w13, w2, w13_scale, w2_scale, w13_input_scale=None, w2_input_scale=None)
¶
Install canonical weights and scales for Humming's layer-based converter.
Returns the scale parameter name used, weight_scale or
weight_scale_inv.