dev.to | 📄 原文链接 | 2026-11-03 收录

在 TorchTPU 上用 Rust 跑 Gemma 4:单块 TPU 芯片的实测

来源:dev.to — 2026-11-02

📋 概述

作者在 Colab 的单块 TPU v5e 上,用 Rust crate 读取 Gemma 4 E2B 检查点、解包 4 位权重,跑完 35 层和环形缓存,并自己驱动解码循环,全程由 TorchTPU 内核执行,Python 只负责后端和启动。结果是 Rust 版逐 token 输出与编译后的 Python 完全一致,流式速度约为后者一半,峰值内存却不到一半,全程不碰 JAX。

🔑 核心要点

💡 金句

“Rust writes the same tokens as compiled Python at about half the streaming speed and less than half the peak memory.”
译:Rust 写出的 token 与编译后的 Python 相同,流式速度约为一半,峰值内存不到一半。
← 返回 dev.to 首页