fix: rebuild the rotary frequencies per call so transformers 5 cannot zero them

#1
InstaDeep Ltd org

transformers >= 5 refills non-persistent buffers with torch.empty after loading, so inv_freq came back as zeros on every NTv3 model: rotary disabled, no error, logits off by up to 248 on NTv3_pretrained. The frequencies are now computed in the forward.

Verified: NTv3_pretrained under transformers 5.17 is bitwise identical to 4.57.1; the three annotation models reproduce jax_model/roundtrip_fixture.npz under both (max abs <= 4.6e-05, 100% argmax). Generated by ntv3_huggingface/build_hf_modeling_files.py, genomix-research commit f5936eb5f9.

Yanisadel changed pull request status to merged

Sign up or log in to comment