MCPcopy Create free account
hub / github.com/pytorch/executorch / __init__

Method __init__

backends/mlx/test/test_ops.py:5816–5833  ·  view source on GitHub ↗
(
        self,
        num_experts: int,
        in_features: int,
        out_features: int,
        group_size: int = 32,
    )

Source from the content-addressed store, hash-verified

5814 """Model using quantized SwitchLinear for expert selection + matmul."""
5815
5816 def __init__(
5817 self,
5818 num_experts: int,
5819 in_features: int,
5820 out_features: int,
5821 group_size: int = 32,
5822 ):
5823 super().__init__()
5824 from executorch.backends.mlx.llm.quantization import quantize_model_
5825 from executorch.backends.mlx.llm.switch import SwitchLinear
5826
5827 self.switch = SwitchLinear(in_features, out_features, num_experts)
5828 quantize_model_(
5829 nn.ModuleDict({"switch": self.switch}),
5830 qlinear_config="4w",
5831 qlinear_group_size=group_size,
5832 )
5833 self.switch.pack()
5834
5835 def forward(self, x: torch.Tensor, indices: torch.Tensor) -> torch.Tensor:
5836 return self.switch(x, indices)

Callers

nothing calls this directly

Calls 4

SwitchLinearClass · 0.90
quantize_model_Function · 0.85
packMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected