kaggle-tpu-lab README

项目的 README,来自 github.com/ARahim3/kaggle-tpu-lab。合并为一个 markdown 文件:README.md。

kaggle-tpu-lab

Run open models on Kaggle's free TPU v5e-8 and get a public endpoint that speaks the OpenAI and Anthropic APIs. Point Claude Code, Codex CLI, opencode or anything else at it. No GPU, no cloud bill, about twenty minutes from pressing Run to a URL.

Each model has its own folder with a run-all Kaggle notebook, the kernel script behind it, and a write-up of how it works and what we measured.

Model Weights on the TPU Context One stream Many streams Prefill Run → URL Engine
Qwen3.8-27B bf16, no quantization 262k ~130 tok/s ~540 tok/s at 8 10,300 tok/s ~22 min vllm-tpu + one patch notebook
GLM-5.3-Flash (320B MoE) 3-bit experts, int8 rest 262k ~165 tok/s ~170 tok/s at 3 ~1,800 tok/s 6–13 min our own JAX engine notebook

Numbers are measured on the shipped configuration; the folder READMEs say how. Qwen runs on vllm-tpu with one patch. GLM-5.3-Flash runs on an engine we wrote in JAX for it; as far as we know it is the first to run that model on a TPU.

What you need

A Kaggle account with TPU access (verify it under Settings: a phone number, and for some accounts an identity check through Persona before TPU sessions are handed out) and its free quota, around 20 TPU hours a week. Nothing to install for the notebook route. For the terminal route, Python 3.9+ and the Kaggle CLI.

How a session works

The notebook attaches public datasets holding the weights (and, where it helps, a pre-built compile cache), builds the engine across the eight chips, opens a Cloudflare tunnel and prints the URL and an API key. The last cell is the server: leave it running. A keepalive holds the session up to Kaggle's limit, a little under nine hours, after which you run it again and get a new URL.

Wire a coding agent with one line, for example Claude Code:

ANTHROPIC_BASE_URL=<url> ANTHROPIC_AUTH_TOKEN=<key> ANTHROPIC_MODEL=<model> claude

Each folder README has the exact lines for Claude Code, Codex CLI and opencode.

From a terminal

git clone https://github.com/ARahim3/kaggle-tpu-lab
cd kaggle-tpu-lab
python launch.py serve            # Qwen3.8-27B today; --model picks another recipe once there is one

launch.py pushes the kernel with the Kaggle CLI and follows its progress; status and stop do what they say.

On a Google Cloud TPU VM

The GLM-5.3-Flash recipe also runs on a rented TPU VM, the same machine as Kaggle's (v5litepod-8) or a v6e-8, with no queue and no nine-hour cap: gcp/ has the guide and the three scripts (environment, datasets, run).

Adding a model

One folder at the top level, named after the model: README.md with the numbers and the how, kernel/ with the serving script, notebook/ with the run-all notebook generated from it, plus whatever the recipe needs (a patch, an engine). The launcher and the notebook share the same config block, so a setting changed in one place means the same thing in the other.

License

The code here is MIT. Model weights keep their own licenses; each folder says which.

kaggle-tpu-lab (ARahim3/kaggle-tpu-lab)

正在搜索数据库…

这是什么?这是一套方案,在 Kaggle 免费 TPU v5e-8 上部署前沿级开源 LLM——GLM-5.3-Flash 320B MoE 和 Qwen3.8-27B bf16——并暴露一个公开的 OpenAI 兼容(及 Anthropic 兼容)端点,可以接入 Claude Code、Codex、opencode、pi 等编程智能体。
这是托管服务,还是我自己运行的东西?由你自己运行:一个 Kaggle notebook 或本地 launch.py 脚本会把脚本内核推送到你自己的 Kaggle 账号,用你的个人 TPU 配额来部署模型,并打印一个临时的公开端点 URL。
怎么让它跑起来?要么复制并编辑已发布的 Kaggle notebook,把 Accelerator 设为 TPU VM v5e-8、打开 Internet,挂载列出的两个数据集,然后从头到尾运行;要么在终端里运行 `python launch.py` 远程完成同样的事。
开始之前需要什么?本地要有 Python 3.9+,以及一个有 TPU 权限的 Kaggle 账号(如果还没有,去 Settings 里完成手机验证)——免费额度大约是每周 20 小时 TPU。
有什么限制?每个 Kaggle 账号同一时间只能开一个 TPU 会话,会话最长 9 小时,免费配额大约每周 20 TPU 小时;另外这个混合注意力模型目前禁用了前缀缓存,多轮智能体对话每一轮都要重新 prefill。
API 端点会暴露在互联网上吗?会——启动器会开启一个公开的 cloudflared 隧道 URL,但它由每次启动时新生成的 API key 保护,请把这对 URL 和 key 当作机密保管。
我需要自己的 GPU 吗?不需要——它完全跑在 Kaggle 免费 TPU v5e-8 配额上,不需要付费 GPU、云账号,也不需要量化。
具体怎么把它接入 Claude Code?内置的 vLLM 暴露了一个 Anthropic 兼容的 /v1/messages 端点;把 Claude Code 指向打印出来的端点 URL,并把 ANTHROPIC_AUTH_TOKEN(不是 ANTHROPIC_API_KEY)设置为生成的 key。
MTP 投机解码在这里为什么有风险?修好了吗?原版 vllm-tpu 0.28.0 在 MTP 与该模型的 gated-DeltaNet 层一起使用时会损坏输出;仓库附带一个补丁,使其经过验证无损(12/12 个贪婪提示词与非投机输出完全一致),解码速度提升约 34%。
这个端点能处理图片吗?可以,Qwen3.8 是视觉语言模型,接受 image_url 内容;新分辨率的第一张图片大约需要一分钟来编译,之后同尺寸的图片都能即时处理。
为什么前缀缓存被禁用了?vllm-tpu 0.28.0 有意在 TPU 上为混合线性注意力模型关闭了自动前缀缓存,所以多轮会话每一轮都要重新 prefill——能感觉到,但很快(5 万 token 的对话约 5 秒)。
作者
ARahim3
大小
0.4 MB
星标
810
更新
提交Oct 06
时长
3个月
提交 · 90 天