debug more5

This commit is contained in:
2026-05-14 23:01:59 +00:00
parent e46ff41569
commit e4f52c8900

View File

@@ -2220,6 +2220,30 @@ class DeepseekV4ForCausalLM(nn.Module):
else:
print("[POST-LOAD] No NaN scale tensors found — scales are clean")
# Dump layer 0 attn keys: model state_dict vs checkpoint
if int(os.environ.get('NVFP4_DEBUG', '0')):
sd = self.state_dict()
layer0_keys = sorted(k for k in sd if 'layers.0.attn' in k or 'layers.0.self_attn' in k)
print("=== MODEL state_dict (layer 0 attn): ===")
for k in layer0_keys:
t = sd[k]
nz = (t != 0).any().item() if torch.is_tensor(t) else '?'
print(f" {k} shape={tuple(t.shape)} dtype={t.dtype} any_nonzero={nz}")
from safetensors import safe_open
import glob
ckpt_files = sorted(glob.glob(os.path.join('/model', '*.safetensors')))
print(f"\n=== CHECKPOINT files: {len(ckpt_files)} shards ===")
seen = set()
for f in ckpt_files[:5]:
with safe_open(f, framework='pt') as h:
for k in h.keys():
if ('layers.0.' in k) and ('attn' in k or 'self_attn' in k):
if k not in seen:
seen.add(k)
t = h.get_tensor(k)
print(f" {k} shape={tuple(t.shape)} dtype={t.dtype}")
return loaded_params
def get_expert_mapping(self) -> list[tuple[str, str, int, str]]: