MCPcopy Create free account
hub / github.com/FreedomIntelligence/LLMZoo / disable_torch_init

Function disable_torch_init

llmzoo/deploy/webapp/utils.py:98–105  ·  view source on GitHub ↗

Disable the redundant torch default initialization to accelerate model creation.

()

Source from the content-addressed store, hash-verified

96
97
98def disable_torch_init():
99 """
100 Disable the redundant torch default initialization to accelerate model creation.
101 """
102 import torch
103
104 setattr(torch.nn.Linear, "reset_parameters", lambda self: None)
105 setattr(torch.nn.LayerNorm, "reset_parameters", lambda self: None)
106
107
108def violates_moderation(text):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected