Read the equation
Each chosen expert evaluates the same input representation h. Its output vector is multiplied by the associated routing weight, and the selected vectors are added. The implementation groups tokens by expert for efficient evaluation and restores their original order before summing; those data-movement steps preserve this intended mixture formula.
Terms & definitions
| Term | Meaning in this source |
|---|---|
| h | Token representation |
| w_i | Routing weight for selected expert i |
| y | Routed output vector |
How it works
Read the definition from its right-hand expression to the quantity on the left. Its surrounding source records the intended input, state, or parameter context. Where the source leaves an operation unspecified, this page preserves that gap.
Assumptions & limits
Source recovery establishes that the expression appears in this record. Its mathematical validity, implementation behavior, and interpretation must be assessed separately. See the linked source and research notes for the checks available for this version.
Original context
Read the surrounding source passage
Then in DeepseekV3MoE.forward (lines 522-532):
identity = h # the PRE-MoE residual
y = moe_infer(h, topk_idx, topk_weight) # sum_i w_i * Expert_i(h)
y = y + shared_experts(identity) # shared expert added afterwards
The shared expert consumes the pre-MoE hidden state, not the routed output.Exact original notation
y = moe_infer(h, topk_idx, topk_weight) # sum_i w_i * Expert_i(h)
Related builds
Sources & provenance
y = moe_infer(h, topk_idx, topk_weight) # sum_i w_i * Expert_i(h)
y = moe_infer(h, topk_idx, topk_weight) # sum_i w_i * Expert_i(h)