MCPcopy Create free account
hub / github.com/Pints-AI/1.5-Pints / num_parameters

Function num_parameters

lit_gpt/utils.py:48–57  ·  view source on GitHub ↗
(module: nn.Module, requires_grad: Optional[bool] = None)

Source from the content-addressed store, hash-verified

46
47
48def num_parameters(module: nn.Module, requires_grad: Optional[bool] = None) -> int:
49 total = 0
50 for p in module.parameters():
51 if requires_grad is None or p.requires_grad == requires_grad:
52 if hasattr(p, 'quant_state'):
53 # bitsandbytes 4bit layer support
54 total += math.prod(p.quant_state.shape)
55 else:
56 total += p.numel()
57 return total
58
59
60def reset_parameters(module: nn.Module) -> None:

Callers 2

mainFunction · 0.90
estimate_flopsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected