Test module with different parameter shapes for testing parametrization.
| 18 | |
| 19 | |
| 20 | class ParametrizeTestModule(nn.Module): |
| 21 | """Test module with different parameter shapes for testing parametrization.""" |
| 22 | |
| 23 | def __init__(self, device="cpu", dtype=torch.float32): |
| 24 | super().__init__() |
| 25 | # 2D parameter (typical weight matrix) |
| 26 | self.weight_2d = nn.Parameter(torch.randn(1024, 1024, device=device, dtype=dtype)) |
| 27 | # 3D parameter (MoE expert weights - the main use case for this feature) |
| 28 | self.expert_weights = nn.Parameter(torch.randn(8, 512, 256, device=device, dtype=dtype)) |
| 29 | # 1D parameter (bias-like) |
| 30 | self.bias_1d = nn.Parameter(torch.randn(1024, device=device, dtype=dtype)) |
| 31 | # Non-parameter attribute (should not be quantizable) |
| 32 | self.not_param = torch.randn(32, device=device, dtype=dtype) |
| 33 | |
| 34 | |
| 35 | @pytest.mark.parametrize("device", get_available_devices()) |
no outgoing calls