Gracefully handle missing scale tensors (BF16 weights with stale index entries)

This commit is contained in:
2026-05-07 00:04:29 +00:00
parent 4470653e15
commit 5f35a5d2b3

View File

@@ -358,12 +358,16 @@ class ShardCache:
def load_weight_and_scale(cache: ShardCache, weight_map, name):
"""Load an FP8 weight with its weight_scale_inv companion (if any)."""
"""Load an FP8 weight with its scale companion (if any)."""
weight = cache.get(weight_map[name]).get_tensor(name)
scale_name = name.replace(".weight", ".scale")
scale = None
if scale_name in weight_map:
scale = cache.get(weight_map[scale_name]).get_tensor(scale_name)
try:
scale = cache.get(weight_map[scale_name]).get_tensor(scale_name)
except Exception:
# Scale listed in index but not in shard (BF16 weights have no scale)
pass
return weight, scale