Skip to content

vllm.model_executor.layers.fused_moe.expert_substitution

Constant expert substitution for MoNE-pruned checkpoints.

MoNE (https://arxiv.org/abs/2507.00390) replaces redundant experts with "novices" that return a constant vector. Checkpoints list the replaced experts per decoder layer either in config.approximate_experts, with constants named <experts prefix>.<expert id>.approx_value, or in compression_config.transform_config.expert_substitution, with explicitly named constants. Retained experts keep their logical checkpoint names and are loaded into compact physical rows.

Classes:

Functions:

ConstantExpertSubstitution

Bases: Module

Constant outputs for the substituted experts of one MoE layer.

Router outputs keep logical expert IDs. transform_routes maps retained experts to compact physical rows and turns substituted routes into zero-weight routes to physical expert 0, so any decomposed MoE backend can run them unchanged.

Methods:

  • physical_expert_id –

    Physical row of a retained expert, or -1 for a substituted one.

  • transform_routes –

    Remap routes in place and return the constant experts' output.

physical_expert_id(expert_id)

Physical row of a retained expert, or -1 for a substituted one.

transform_routes(hidden_states, topk_weights, topk_ids)

Remap routes in place and return the constant experts' output.

SubstitutedRoutedExperts

Bases: RoutedExperts

Routed experts that hold weights only for retained experts.

decoder_layer_index(path)

Return the only integer component of a module path, if unique.

get_expert_substitution_spec(model_config)

Parse the substituted experts declared in a model's HF config.