diff --git a/vllm/patches/deepseek_v4.py b/vllm/patches/deepseek_v4.py index 719907c1..1227e79b 100644 --- a/vllm/patches/deepseek_v4.py +++ b/vllm/patches/deepseek_v4.py @@ -1754,7 +1754,7 @@ class DeepseekV4Model(nn.Module): E2M1_LUT = torch.tensor([0, 0.5, 1, 1.5, 2, 3, 4, 6], dtype=torch.bfloat16) self._dequant_nvfp4_to_bf16(mod, E2M1_LUT) if layer_idx == 0: - print(f"[CLAWMINE] Layer 0: {proj_name} AFTER dequant: dtype={mod.weight.dtype} amax={mod.weight.data.amax().item():.4f} NaN={torch.isnan(mod.weight.data).any().item()}") + print(f"[CLAWMINE] Layer 0: {proj_name} AFTER dequant: dtype={mod.weight.dtype} amax={mod.weight.data.amax().item():.4f} NaN={torch.isnan(mod.weight.data).any().item()} quant_method={type(mod.quant_method).__name__}") bf16_converted += 1 # FP8 conversion: wo_a (used by fp8_einsum, no input_scale) diff --git a/vllm/patches/deepseek_v4_attention.py b/vllm/patches/deepseek_v4_attention.py index 2bde4a53..3e0ed6c2 100644 --- a/vllm/patches/deepseek_v4_attention.py +++ b/vllm/patches/deepseek_v4_attention.py @@ -3,6 +3,7 @@ """ DeepseekV4 MLA Attention Layer """ +import os from collections.abc import Callable from dataclasses import dataclass @@ -303,6 +304,10 @@ class DeepseekV4MultiHeadLatentAttentionWrapper(PluggableLayer): ) o = o_padded[:, : self.n_local_heads, :] + if os.environ.get('CLAWMINE_DEBUG', '0') == '1': + with torch.no_grad(): + print(f"[CLAWMINE] attn L{self.layer_name}: o amax={o.amax().item():.4f} NaN={torch.isnan(o).any().item()}") + # O projection: inverse RoPE + FP8 quant + einsum + wo_b o_fp8, o_scale = fused_inv_rope_fp8_quant( o, @@ -315,6 +320,10 @@ class DeepseekV4MultiHeadLatentAttentionWrapper(PluggableLayer): tma_aligned_scales=self._tma_aligned_scales, ) + if os.environ.get('CLAWMINE_DEBUG', '0') == '1': + with torch.no_grad(): + print(f"[CLAWMINE] attn L{self.layer_name}: o_fp8 amax={o_fp8.float().amax().item():.4f} o_scale amax={o_scale.float().amax().item():.6f}") + wo_a_fp8 = self.wo_a.weight wo_a_scale = self.wo_a.weight_scale_inv