From ca784e4cf5c0c63428ad7efa5359717335800496 Mon Sep 17 00:00:00 2001 From: Nick Rui Date: Sun, 12 Jul 2026 00:02:19 -0700 Subject: [PATCH 1/2] fix(tools): fp8_cast_bf16 upcast weights missing scale_inv to bf16 FP8 tensors without a scale_inv were passed through unconverted, producing a mixed-dtype checkpoint that later fails dist-ckpt serialization. Reported in #1583. --- tools/fp8_cast_bf16.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/fp8_cast_bf16.py b/tools/fp8_cast_bf16.py index 31d6d52a3a..b4bc34e182 100644 --- a/tools/fp8_cast_bf16.py +++ b/tools/fp8_cast_bf16.py @@ -100,8 +100,8 @@ def get_tensor(tensor_name): fp8_weight_names.append(weight_name) new_state_dict[weight_name] = weight_dequant(weight, scale_inv) except KeyError: - print(f"Warning: Missing scale_inv tensor for {weight_name}, skipping conversion") - new_state_dict[weight_name] = weight + print(f"Warning: Missing scale_inv tensor for {weight_name}, upcasting to {torch.get_default_dtype()}") + new_state_dict[weight_name] = weight.to(torch.get_default_dtype()) else: new_state_dict[weight_name] = weight From 88f7db836e9c4494a97ecabb8f544e565d48f7c5 Mon Sep 17 00:00:00 2001 From: Nick Rui Date: Sun, 12 Jul 2026 00:30:37 -0700 Subject: [PATCH 2/2] fp8_cast_bf16: only treat 1-byte floating-point tensors as FP8 --- tools/fp8_cast_bf16.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/fp8_cast_bf16.py b/tools/fp8_cast_bf16.py index b4bc34e182..554c2de6ad 100644 --- a/tools/fp8_cast_bf16.py +++ b/tools/fp8_cast_bf16.py @@ -92,7 +92,7 @@ def get_tensor(tensor_name): if weight_name.endswith("_scale_inv"): continue - elif weight.element_size() == 1: # FP8 weight + elif weight.element_size() == 1 and weight.is_floating_point(): # FP8 weight scale_inv_name = f"{weight_name}_scale_inv" try: # Get scale_inv from the correct file