# Repository Briefing: ARahim3/kaggle-tpu-lab
> Source: https://repoforai.com/repo/ARahim3/kaggle-tpu-lab (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/ARahim3/kaggle-tpu-lab
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: MIT
- **Engineering Health**: B+ (68/100 · Maintenance 26/35 · Adoption 16/25 · Releases 6/20 · License 20/20)
- **Review Snapshot**: 2026-12-04
- **Deployment / Stack Signals**: GPU, API, CLI
- **Momentum**: 825 ★ total (+1 24h / +11 7d) · 110 forks
- **Topics**: `anthropic-api`, `claude-code`, `coding-agents`, `free-gpu`, `glm`, `glm-5-3-flash`, `jax`, `kaggle`, `llm-inference`, `llm-serving`, `long-context`, `mixture-of-experts`
- **When to Use**: Best for: Evaluating Qwen3.8-27B or GLM-5.3-Flash on TPUs, testing long-context coding-agent workloads, or running a short-lived API endpoint without local accelerator hardware. Skip if: You need a stable, continuously available endpoint, verified coverage of a specific API feature set, or a private network deployment ready out of the box.

## Overview
```text
### Architecture & Core Mechanics
kaggle-tpu-lab packages two model-specific TPU serving recipes rather than a single inference engine. `qwen38-27b/` runs Qwen3.8-27B on vllm-tpu with one patch; `glm53-flash/` runs GLM-5.3-Flash on a purpose-built JAX engine. Each recipe includes a serving script under `kernel/`, a run-all notebook under `notebook/` generated from it, and any patch or engine code the model needs.

On Kaggle, the notebook attaches public datasets containing weights and, where applicable, a prebuilt compilation cache. It initializes the engine across all eight TPU chips, starts the server, and exposes it through a Cloudflare tunnel. The endpoint speaks OpenAI- and Anthropic-compatible APIs. The launcher and notebook use the same configuration block; the documented extension pattern is to add a model directory with its own runtime recipe.

### Key Capabilities & Differentiators
Both configurations list a 262k context window and prefix caching. Qwen3.8-27B runs in unquantized bf16 and delivers ~130 tok/s on one stream, ~540 tok/s aggregate at eight streams, and 10,300 tok/s in prefill. GLM-5.3-Flash is a 320B mixture-of-experts model with 3-bit expert weights and int8 weights elsewhere. It delivers ~165 tok/s on one stream, ~170 tok/s aggregate at three streams, and ~1,800 tok/s in prefill.

These figures are for the shipped configurations. GLM leads on single-stream throughput, while Qwen posts higher prefill and aggregate throughput at the reported test points. The concurrency points differ, so they are not a matched-load comparison. Neither the throughput figures nor the context limit establish response latency at 262k tokens; benchmark realistic prompts and concurrency if the endpoint will serve interactive agents.

### Trade-offs & Limitations
This is a way to evaluate specific open-weight models without owning a GPU. The two backends have different maintenance surfaces: Qwen relies on a patched vllm-tpu stack, while GLM relies on a model-specific JAX engine. GLM's reported single-stream advantage is not enough to pick it for a shared endpoint: Qwen delivers more aggregate throughput at the reported concurrency points, and the results do not establish the quality impact of GLM's quantized weights.

Compared with a managed API such as the OpenAI API, the Kaggle path gives you control over the model recipe but makes you responsible for restarts, changing URLs, and access to a public tunnel. Test the features your clients use before treating either compatibility layer as a drop-in replacement. The MIT license covers repository code; check model-weight terms and hosting policies separately.

### Hardware & Deployment Guide
The Kaggle notebook route needs no local installation, but it requires an account with TPU access. Phone verification is required, and some accounts also need a Persona identity check. The free quota is around 20 TPU hours per week. Measured startup-to-URL times are ~22 minutes for Qwen and 6–13 minutes for GLM. The final cell runs the server and must stay active. Keepalive does not remove the session limit of just under nine hours; restarting yields a new URL.

The terminal route requires Python 3.9+ and the Kaggle CLI. `python launch.py serve` starts Qwen by default; the launcher also provides `status` and `stop`. For GLM, `gcp/` provides setup, dataset, and run scripts for rented `v5litepod-8` or `v6e-8` TPU VMs, without Kaggle's queue or session cap. There is no published GitHub release to use as a version pin; record the tested commit if reproducibility matters.
```

## Key Capabilities
```text
- Runtime split: Patched vllm-tpu for bf16 Qwen3.8-27B; a model-specific JAX engine for GLM-5.3-Flash.
- GLM weight layout: 320B MoE with 3-bit expert weights and int8 weights elsewhere.
- Long-context serving: Both configurations list 262k context and support prefix caching.
- Concurrency profile: Qwen reaches ~540 tok/s at eight streams; GLM reaches ~170 tok/s at three in the respective shipped configurations.
- Client integration: OpenAI- and Anthropic-compatible APIs exposed via a Cloudflare tunnel with an API key.
- Deployment paths: Run-all Kaggle notebooks, a Kaggle CLI launcher, and a Google Cloud TPU VM recipe for GLM.
```

## Quick Start / Clone
```bash
ANTHROPIC_BASE_URL=<url> ANTHROPIC_AUTH_TOKEN=<key> ANTHROPIC_MODEL=<model> claude
```
