MCPcopy Create free account
hub / github.com/Francis-Rings/FlashPortrait / autocast_model_forward

Function autocast_model_forward

wan/utils/fp8_optimization.py:36–45  ·  view source on GitHub ↗
(cls, origin_dtype, *inputs, **kwargs)

Source from the content-addressed store, hash-verified

34 param.data = param.data.to(torch.float8_e4m3fn)
35
36def autocast_model_forward(cls, origin_dtype, *inputs, **kwargs):
37 weight_dtype = cls.weight.dtype
38 cls.to(origin_dtype)
39
40 # Convert all inputs to the original dtype
41 inputs = [input.to(origin_dtype) for input in inputs]
42 out = cls.original_forward(*inputs, **kwargs)
43
44 cls.to(weight_dtype)
45 return out
46
47def convert_weight_dtype_wrapper(module, origin_dtype):
48 for name, module in module.named_modules():

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected