MoeStreamingLayer class
Constructors
- MoeStreamingLayer({required String prefix, required int numExperts, required int topK, required ShardedSafeTensorsReader reader, GateFunction gate = GateFunction.softmax, bool renormalize = false})
Properties
- gate → GateFunction
-
Router gate function (Softmax for V2 / Qwen; sigmoid for V3).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- numExperts → int
-
Total routed experts (
numRoutedExperts).final - prefix → String
-
HF key prefix ending in
.mlp— e.g."model.layers.5.mlp".final - reader → ShardedSafeTensorsReader
-
Streaming source.
final
- renormalize → bool
-
If true, top-K weights are row-normalized so they sum to 1.
V3 default; V2 / Qwen leave this false.
final
- routerKey → String
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- topK → int
-
Top-K experts picked per token by the router.
final
Methods
-
expertBytes(
{int probeExpert = 0}) → int - Per-expert byte count on disk (sum of the 3 SwiGLU tensors). Cheap — reads header entries only.
-
loadRoutedExpert(
int j, {bool keepFp16 = true}) → RoutedExpertWeights - Load one routed expert's SwiGLU triplet.
-
loadRouter(
{bool keepFp16 = false}) → Tensor -
Read the router weight and return it transposed to
[D, E]sox @ routerWcomputes gate logits directly. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
report(
MoeRoutingDecision decision, {int? bytesPerExpert}) → MoeStreamingReport - Bytes plan given a MoeRoutingDecision.
-
route(
Tensor routerW, Tensor x) → MoeRoutingDecision - Full routing pass. Returns:
-
routedExpertDownKey(
int j) → String -
routedExpertGateKey(
int j) → String -
routedExpertUpKey(
int j) → String -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited