rajivmehtaflex/power-utility/colab-llm-inference
Claude Code and agent skill by rajivmehtaflex/power-utility
- community
Checking that the SKILL.md file is still in the repository.
Use when running LLM inference on Colab GPUs.
Install
npx vskill@latest install rajivmehtaflex/power-utility/colab-llm-inferenceSKILL.md
The same SKILL.md was published earlier as rajivmehtaflex/power-utility/colab-llm-inference.
Colab LLM Inference
Run large language models on Google Colab GPUs reliably — from VRAM estimation to quantized loading and verification. Captures the non-obvious Colab-specific pitfalls uncovered in live sessions (e.g., Gemma-4 12B on T4).
When to Use
- User asks "will model X fit on Colab T4/L4/A100?" or "does Y fit with quantization/MTP/QAT?"
- Loading any 7B+ model on Colab and need to choose BF16 vs INT8 vs 4-bit
transformersload fails withunexpected keyword argument 'load_in_4bit'orAmbiguousGlobalPerLayerAttributeErrornvidia-smiortorch.cuda.is_available()disagrees betweensshandcolab execpip install llama-cpp-pythonhangs and leaves BUSY/defunct kernel
VRAM Estimation (Rule of Thumb)
| Precision | Bytes/param | Example: 12B model | Fits T4 15GB? | Fits A100 40GB? | |
|---|---|---|---|---|---|
| BF16 | 2 | 23.9GB → ~30GB total | ❌ | ✅ | |
| INT8 | 1 | 12GB → ~16GB | ❌ borderline | ✅ | |
| Q4_0/NF4 | 0.5 | 6GB → ~9GB | ✅ | ✅ |
Use hf models info REPO_ID (safetensors.parameters.BF16) to get exact params, then apply formula. See references/gemma4-t4-fit.md for full Gemma-4 numbers.
Quantized Loading — Correct Pattern for Gemma-4 (and any Gemma4Unified*)
Never pass load_in_4bit=True as a top-level kwarg to AutoModelForImageTextToText.from_pretrained — Gemma4's __init__ rejects it:
Correct (bitsandbytes wheel, 60s install, no compile):
Why not `llama-cpp-python`? pip install llama-cpp-python on Colab triggers a source compile (>10 min), often hangs, leaves python3 <defunct> (zombie) visible via ssh ... "ps aux" and a persistent BUSY (exec(...)) that colab restart-kernel doesn't clear. Recovery requires colab stop -s NAME && colab new -s NAME --gpu T4. Prefer bitsandbytes==0.47.0 wheel.
Why not `compressed-tensors` NVFP4 path? unsloth/gemma-4-12b-it-NVFP4 fails with AmbiguousGlobalPerLayerAttributeError: 'num_key_value_heads' is per-layer due to version mismatch. Use BitsAndBytesConfig path above.
GPU Visibility: colab exec vs ssh (Critical)
- `colab exec -s NAME -f script.py` → runs inside the kernel container where CUDA is mounted.
torch.cuda.is_available() == True,nvidia-smishowsTesla T4 15360 MiB. - `ssh g-xxx "python3 -c '...'"` → lands in host VM's root FS where
libnvidia-ml.sois not in PATH.nvidia-smifails (couldn't find libnvidia-ml.so),torch.cuda.is_available() == False.
Live proof 2026-08-23 (`g-gemma-4-12b` T4):
colab exec:cuda True, Tesla T4, 7573 MiB used after 4-bit loadssh:False, NVIDIA-SMI couldn't find libnvidia-ml.so
Implication: Always run GPU inference/training via colab exec. VSCode Remote-SSH's integrated terminal is also host-FS, so wrap model runs in colab exec.
Colab SSH Alias with Custom Session Name
When user requests alias == session name (e.g., g-gemma-4-12b):
Must start with /usr/bin/env PYTHONPATH= (Hermes leaks PYTHONPATH → ModuleNotFoundError: pydantic_core._pydantic_core). Use absolute mighty-colab path from readlink -f $(which colab).
Workflow Checklist
export PYTHONPATH="" && colab --auth=adc new -s NAME --gpu T4colab --auth=adc status -s NAME→ verifyHardware: T4colab --auth=adc exec -s NAME -f install.py→ installbitsandbytes transformers accelerate- Estimate VRAM via
hf models info+ formula; pick quantized repo if needed - Load with
BitsAndBytesConfigpattern above viacolab exec - Verify:
nvidia-smiinside exec vs ssh discrepancy expected colab stop -s NAMEwhen done (billing)
References
references/gemma4-t4-fit.md— full 2026-08-23 session transcriptreferences/colab-exec-vs-ssh.md— exec vs ssh GPU visibility reproduction
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingprofile/mlops/colab-llm-inference/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/rajivmehtaflex/power-utility/colab-llm-inference)