From 5fa6c88b179d2167c0c4b99b75a9d503990ef181 Mon Sep 17 00:00:00 2001 From: biondizzle Date: Sat, 30 May 2026 22:51:10 +0000 Subject: [PATCH] Fix: replace FP4 Inf with 24 (avoid NaN in dequant) --- single_shot_inference.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/single_shot_inference.py b/single_shot_inference.py index 601d8a4e..1ed2d3b7 100644 --- a/single_shot_inference.py +++ b/single_shot_inference.py @@ -28,7 +28,7 @@ PROMPT = "The capital of France is" # FP4 E2M1 lookup table: index → float value (unsigned) # E2M1: 1-bit sign, 2-bit exp (bias=1), 1-bit mantissa # Values: 0, 2, 3, 4, 6, 8, 12, Inf (for exp 00,01,10,11 × mantissa 0,1) -FP4_LUT = torch.tensor([0., 2., 3., 4., 6., 8., 12., float('inf')]) +FP4_LUT = torch.tensor([0., 2., 3., 4., 6., 8., 12., 24.]) # E2M1: last value (0b111) is nominally Inf, use 24 (2^(2+1) * 1.5) def dequant_nvfp4_weight( weight: torch.Tensor, # (out, in/2) uint8