MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / ParametrizeTestModule

Class ParametrizeTestModule

tests/test_parametrize.py:20–32  ·  view source on GitHub ↗

Test module with different parameter shapes for testing parametrization.

Source from the content-addressed store, hash-verified

18
19
20class 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())

Calls

no outgoing calls

Tested by 8

test_error_conditionsFunction · 0.68
test_multiple_parametersFunction · 0.68
test_gradient_behaviorFunction · 0.68