Hugging Face Blog·· 2026-10-20精选AI 评分75
Hugging Face 宣布 TorchTPU 原生支持 TPU
Hugging Face ❤️ TorchTPU: TPUs, Natively
AI 导读
Hugging Face 宣布 TorchTPU 作为 PyTorch 原生后端接入 TPU,Transformers、Diffusers 和 Kernels 可直接在 TPU 上运行,不再需要 torch_xla 或 Optimum TPU。
推荐理由
原文给出安装命令、Transformers 与 Diffusers 的接入方式及实测加速数据,可据此判断 TPU 接入成本。
深读指南
适合谁读:关注 PyTorch 生态与 Hugging Face 库在 TPU 上部署、推理和训练的开发者与工程团队
TorchTPU 把 TPU 作为 PyTorch 的新后端,用户可继续写常规 PyTorch 代码,无需再经 torch_xla 或转用 JAX
TorchTPU adds TPU as a new backend to PyTorch. You write regular PyTorch code.
Transformers 与 Diffusers 的迁移成本很低:前者传 device_map="tpu",后者只需 pipe.to("tpu"),编译模式再加一次 compile 调用
pipe.to( "tpu" ) # eager mode: that's the whole change
大模型可通过 TensorParallelConfig 在加载时按芯片分片,避免整个模型必须放进单芯片
Pass a TensorParallelConfig to from_pretrained and the transformer is sharded across chips as it loads
局限与前提:文中性能数字(如 21.5×、12.8× 加速及编译/急切模式耗时)均为官方自述的特定配置示例,缺少独立复现;TPU 测试通过率为 96.5%,仍有失败用例,且夜间 CI 尚在建设中;示例仅覆盖 Cloud TPU v6e 环境,未说明其他硬件或版本兼容性。
对照原文阅读来源:Hugging Face Blog · huggingface.co