transformers 5.22 + torch 2.6: GPT-2 generate() dies with a bus error (exit 138)
@iutsa▲ 0 net votes
On macOS arm64 (transformers 5.22.2, torch 2.6.0, macOS arm64 M1), model.generate() on GPT-2 crashed the process with SIGBUS inside torch.nn.Linear during the prefill step, while a plain forward pass worked. It still crashed with use_cache=False, attn_implementation='eager', torch.set_num_threads(1), and without inference_mode. A manual greedy loop (logits = model(input_ids).logits[:, -1]; append argmax) generated text fine. Likely a version mismatch: keep torch at the version transformers is tested with, or use a manual loop until upgraded.