vllm.model_executor.models.cohere2_moe
¶
Classes:
-
Cohere2Moe–Tensor-parallel MoE block for Cohere2Moe with shared experts.
-
Cohere2MoeAttention–Cohere MoE attention with sliding-window interleave.
-
Cohere2MoeDecoderLayer– -
Cohere2MoeMLP–Cohere MLP used as shared experts in the MoE block.
-
Cohere2MoeModel–Transformer decoder for Cohere2Moe.
Functions:
-
is_prefix_dense_layer–True when layer_idx lies in the contiguous dense MLP prefix.
-
make_norm–RMSNorm when config.rms_norm_eps is set, otherwise Cohere LayerNorm with
-
token_choice_with_bias–Sigmoid -> top-k (-> renormalize) custom routing for Cohere2Moe.
Cohere2MoeDecoderLayer
¶
Bases: Module
_allows_dual_stream()
¶
With the dual stream the only TP collective in a layer is the all-reduce of attention + MLP after the join. A MoE that reduces internally would let the attention all-reduce run while the MoE stream is still communicating.
EP all2all kernels stay single-stream at any TP size (including DP + EP at TP1): all2all on the side stream, and next to DBO, is not validated.
Cohere2MoeModel
¶
_DualStreamState
dataclass
¶
Dual-stream state of one decoder layer.
stream is the model's single side stream, shared by every layer; the
events and join_pending are per layer, since a layer has at most one
fork in flight. DBO would need one state per ubatch.
_make_dual_stream(vllm_config)
¶
Side stream shared by all decoder layers, or None when the dual stream is disabled (token threshold 0) or unsupported.
is_prefix_dense_layer(config, layer_idx)
¶
True when layer_idx lies in the contiguous dense MLP prefix.
make_norm(config)
¶
RMSNorm when config.rms_norm_eps is set, otherwise Cohere LayerNorm with config.layer_norm_eps.
token_choice_with_bias(hidden_states, gating_output, topk, renormalize)
¶
Sigmoid -> top-k (-> renormalize) custom routing for Cohere2Moe.