MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT-LLM / MoeConfig

Class MoeConfig

tensorrt_llm/layers/moe.py:106–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104
105@dataclass
106class MoeConfig:
107
108 class ExpertScaleNormalizationMode(IntEnum):
109 NONE = 0
110 RENORMALIZE = 1
111 SPARSE_MIXER = 2
112 DEVICE_LIMITED = 3
113 DEVICE_LIMITED_RENORM = 4
114
115 num_experts: int = 0
116 shared_expert_intermediate_size: int = 0
117
118 top_k: int = 0
119 normalization_mode: ExpertScaleNormalizationMode = ExpertScaleNormalizationMode.RENORMALIZE
120 sparse_mixer_epsilon: float = 0.01
121 tp_mode: int = 0
122
123 device_limited_n_group: int = 0
124 device_limited_topk_group: int = 0
125 device_limited_routed_scaling_factor: float = 1.0
126
127 def validate(self) -> "MoeConfig":
128 if (self.num_experts == 0) != (self.top_k == 0):
129 raise ValueError(
130 "Both or neither MoeConfig's num_experts and top_k must be set to 0"
131 )
132 return self
133
134 def has_moe(self) -> bool:
135 return self.num_experts > 1
136
137 @classmethod
138 def from_dict(cls, config: dict):
139 return cls(**config)
140
141 def to_dict(self):
142 return asdict(self)
143
144
145def _moe_plugin(moe_config,

Callers 15

create_trt_sessionMethod · 0.90
create_trt_sessionMethod · 0.90
to_MOE_configMethod · 0.70
__init__Method · 0.50
from_hugging_faceMethod · 0.50
__init__Method · 0.50
from_hugging_faceMethod · 0.50
from_hugging_faceMethod · 0.50

Calls

no outgoing calls

Tested by 3

create_trt_sessionMethod · 0.72
create_trt_sessionMethod · 0.72