Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

airllm

БесплатноБез исполняемых скриптовНе проверен

AirLLM runs very large open language models on a small GPU (or a CPU) by loading the model one layer at a time from disk instead of holding it all in memory…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

AirLLM — run models bigger than your GPU, one layer at a time

Overview

AirLLM (pip install airllm) is a Python library that loads a Hugging Face causal language model, splits its weights into one file per layer on disk, and during generation brings a single layer into GPU memory, runs it, frees it and moves to the next (with the next layer prefetched on a background thread). GPU memory use is therefore set by the size of one layer, not the whole model: the project reports Llama-class 70B models in about 4 GB of VRAM without quantizing, and far larger mixture-of-experts models in more. The README's figures are VRAM only.

The trade-off is speed. Every generated token has to pass through every layer, so every token streams essentially the whole model from disk to the GPU. Expect seconds to tens of seconds per token for 70B-class models on a consumer SSD (the README gives no tokens-per-second figure, so measure on your hardware before promising anything). Use it for offline, non-interactive jobs where memory is the limit and latency is not: batch classification, overnight summarisation, one-off questions to a big model. It is not a chat server.

It is an inference library you call from Python, with a Hugging Face-style generate. It does not expose an OpenAI-compatible server.

Instructions

Install and check the machine

python -m venv .venv && . .venv/bin/activate
pip install airllm            # pulls torch>=2.4, transformers, accelerate, safetensors, sentencepiece
pip install -U bitsandbytes   # only if you want compression='4bit' or '8bit'
python -c "import torch; print(torch.cuda.is_available())"
df -h ~/.cache/huggingface    # the model is downloaded AND re-saved layer by layer

For an NVIDIA GPU install a CUDA build of torch from pytorch.org first. On macOS only Apple silicon is supported and mlx must be installed; there only Llama-style and Mistral-style models run.

Generate text

from airllm import AutoModel

model = AutoModel.from_pretrained(
    "meta-llama/Llama-3.1-70B-Instruct",   # a Hugging Face repo id or a local folder
    max_seq_len=512,                        # default; longer context needs more memory per layer
)

prompts = ["Summarize the termination clause of a standard SaaS contract in two sentences."]
tokens = model.tokenizer(prompts, return_tensors="pt", return_attention_mask=False,
                         truncation=True, max_length=256, padding=False)

out = model.generate(
    tokens["input_ids"].to(model.device),
    max_new_tokens=60,
    use_cache=True,
    return_dict_in_generate=True,
)
print(model.tokenizer.decode(out.sequences[0]))

AutoModel reads the model's config and picks the right class, including special classes for ChatGLM, Qwen v1, Baichuan and InternLM; other standard decoder-only architectures use a generic streaming class. The first call is the slow one: the library downloads the checkpoint, writes one safetensors file per layer into a splitted_model folder (inside the Hugging Face cache by default), and only then starts generating. Later runs reuse those shards.

Constructor options

Argument Meaning
device Default "cuda:0". Pass "cpu" to run on CPU (works, slower)
max_seq_len Default 512
compression "4bit" or "8bit" block-wise weight compression; makes the shards smaller so disk loading is faster (the project says up to about 3x); needs bitsandbytes; disables prefetching
layer_shards_saving_path Where to write the layer shards (put it on your fastest disk)
delete_original True deletes the downloaded original checkpoint after splitting, roughly halving disk use
hf_token Hugging Face token for gated repos such as the Meta Llama models
profiling_mode True prints where time goes (disk load versus compute)
prefetching On by default; overlaps loading the next layer with computing the current one
dtype Defaults to the model's own dtype (usually bfloat16)

Pick a model and prepare disk

  • Choose an instruction-tuned model that fits your task, and check its licence and whether the repo is gated (request access on Hugging Face, then pass hf_token=os.environ["HF_TOKEN"], created at huggingface.co/settings/tokens).
  • Plan disk for the original download plus the shards: for a 70B model in 16-bit that is about 140 GB for each unless you set delete_original=True. A full disk surfaces as NotEnoughSpaceException or a MetadataIncompleteBuffer safetensors error; free space and re-run.
  • Test the pipeline on a small model of the same family (for example an 8B) before pulling a 70B one, and time one token.

Measure speed before committing

import time
t = time.time()
out = model.generate(tokens["input_ids"].to(model.device), max_new_tokens=3, use_cache=True,
                     return_dict_in_generate=True)
print(f"{(time.time() - t) / 3:.1f} s per token")

Divide your expected output lengt

Полный SKILL.md на GitHub

Установить airllm в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл airllm?

AirLLM runs very large open language models on a small GPU (or a CPU) by loading the model one layer at a time from disk instead of holding it all in memory, at the price of slow generation. Use when the user wants to run a 70B or larger Hugging Face model locally with 4-12 GB of VRAM, asks how to fit a model that does not fit in GPU memory, or says "airllm", "layer-by-layer inference", "run Llama 70B on a small GPU", "offline batch answers from a big model".

Как установить скилл airllm?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл airllm запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить airllm с