#1392·examples

FSDP2 混合精度示例有误导性,断言无效

作者: zhc7创建于 2025年9月9日更新于 2025年9月9日

def inspect_mixed_precision(model: FSDPModule): model.unshard() for param in model.parameters(recurse=False): assert param.dtype == torch.bfloat16 model.reshard()

This function is highly misleading. In the provided example, the Transformer model itself has no direct parameters, all parameters are contained within its submodules. As a result, the current loop only inspects the model’s direct parameters, which means it effectively checks nothing. I would expect it to inspect some actual params.

内容来源: pytorch/examples