From 5f35a5d2b38f38898c7d941d2927541722b93d2c Mon Sep 17 00:00:00 2001 From: biondizzle Date: Thu, 7 May 2026 00:04:29 +0000 Subject: [PATCH] Gracefully handle missing scale tensors (BF16 weights with stale index entries) --- fp8_to_nvfp4_streaming.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fp8_to_nvfp4_streaming.py b/fp8_to_nvfp4_streaming.py index 16a56c6..186fd5f 100644 --- a/fp8_to_nvfp4_streaming.py +++ b/fp8_to_nvfp4_streaming.py @@ -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