
Shipping LLM systems: RAG, agents, serving, eval. Attention seeker (self-attention only). No vibes, just logits.
Joined February 2022
- Tweets499
- Following406
- Followers1.2K
- Likes362
you are
a developer trying to run GPT-3 locally
your GPU catches fire
your AWS bill looks like a phone number
decide to learn the dark arts of optimization
18 months later i can make a 70B model run on a gaming laptop
here's the forbidden speedrun guide
the problem:
LLMs are fat and slow
175B parameters = 700GB in FP32
one forward pass = your GPU crying
inference speed measured in geological time
but the nerds fixed it
quantization = the ultimate life hack
take your fancy 32-bit floats
crush them to 8-bit ints
model gets 75% smaller
still works fine
it's like JPEG for neural networks
"lossy compression but nobody notices"
4-bit quantization:
yes, FOUR bits
0-15, that's all you get
somehow still generates shakespeare
GGUF, AWQ, GPTQ formats
pick your poison
they all work, nobody knows why
KV-cache quantization:
the cache that stores your conversation
normally bloats like your node_modules
quantize it too
suddenly you can chat for hours
memory usage: "what memory usage?"
flash attention = GPU go brrrr
normal attention: O(n²) memory
flash attention: "what if we just... didn't?"
compute in tiny blocks
use SRAM like a speed demon
4x faster, uses 10x less memory
dao-aielab/flash-attention changed the game
sparse attention patterns:
not every token needs to see every token
local: "i only talk to my neighbors"
strided: "i check in every 8 tokens"
learned: "the model decides who's worth talking to"
attention budget: managed
paged attention:
virtual memory but for transformers
breaks KV-cache into pages
no more memory fragmentation
vLLM uses this
suddenly you can serve 100 users on one GPU
"MMU for AI" energy
speculative decoding = parallel universe speedrun:
small model: "i think it says 'the cat sat'"
big model: "let me verify... yep, 2/3 correct"
accept the good, regenerate the bad
2-3x speedup
free performance, no quality loss
LoRA = fine-tuning for broke people:
don't retrain 70B params
add tiny 1M param adapters
they modify the big model's behavior
switch them like cartridges
one base model, infinite personalities
PEFT library makes it trivial
pruning = marie kondo for weights:
structured: delete entire layers
unstructured: delete random connections
magnitude pruning: "if weight < 0.01, yeet"
90% sparsity still works
your model on a diet
knowledge distillation:
big model teaches small model
teacher: "here's my probability distribution"
student: "i'll mimic that"
10x smaller, 95% as good
how edge devices run "GPT"
dynamic batching:
GPUs hate single requests
batch them like a subway at rush hour
continuous batching: add/remove on the fly
orca/vllm pioneered this
throughput goes 10x
tensor parallelism:
split matrices across GPUs
GPU 1: "i'll do columns 0-1024"
GPU 2: "i'll take 1024-2048"
requires NVLink or you die waiting
how you run 175B models at all
pipeline parallelism:
assembly line for layers
GPU 1 does layers 1-10
GPU 2 does 11-20
microbatching keeps everyone busy
deepspeed makes this "easy"
mixed precision = have your cake:
compute in FP16
accumulate in FP32
store in INT8
tensor cores go brrr
2x speedup for free
early exit strategies:
easy tokens exit early
"the" doesn't need 80 layers
complex tokens get full computation
adaptive compute budgets
30-50% faster on average
model serving stack that actually works:
vLLM for throughput
TensorRT-LLM for latency
llama.cpp for edge
everyone else is marketing
pick one, tune it, ship it
the multiplication effect:
quantization: 4x smaller
flash attention: 4x faster
batching: 10x throughput
sparse attention: 2x faster
speculative decoding: 2x faster
compound them all: 320x better
secret sauce combinations:
INT4 quantization + flash attention + paged attention
= 70B model on consumer GPU
LoRA + pruning + distillation
= custom 7B that beats GPT-3.5
all the techniques stack
forbidden truth:
OpenAI uses all of these
Anthropic too
the "magic" is just good engineering
frontier models = same architecture + better optimization
scale is a compiler flag
what nobody tells you:
inference optimization > training optimization
most "breakthroughs" are engineering
the papers are public
the code is on github
you can build this
tools of the trade:
bitsandbytes for quantization
flash-attention (obviously)
vLLM for serving
PEFT for LoRA
tensorRT for nvidia supremacy
llama.cpp for running on your toaster
final boss wisdom:
you don't need a PhD
you don't need H100s
you need obsession and arxiv
start with llama.cpp
work your way up
in 6 months you'll be explaining speculative decoding at parties
the endgame:
gpt-4 class models on your laptop
real-time inference on phones
open source catching up monthly
optimization democratizing AI
the moat is evaporating
they said LLMs need datacenters
they lied
with these techniques
you run them on edge
build your own
ship to users
no API keys
no rate limits
just pure, optimized inference
now you know
the sacred techniques
the forbidden optimizations
stop asking for API access
start quantizing
welcome to the resistance
1
349
smallest Arabic model ever
Built an Arabic RAG agent on @karpathy's nanochat
Trained on:
• ArabicText-Large (244M words)
• Hala-4.6M Arabic instructions
• MorphBPE tokenizer (76.8K vocab)
Features:
✓ RTL UI with citations
✓ Offline RAG + search
✓ Consensus decoding
✓ Runs on 4GB GPU
$0 cost. Fully offline.
github.com/h9-tec/arabic_nan…
The Journey from Human Attention to AI Revolution: How We Taught Machines to Focus
heshamharoon.substack.com/p/…
252
This research argues that the field should stop chasing ever-bigger models for logic. For reasoning, smaller can do better.
They built a Tiny Recursive Model, a deliberately small network with two layers and about seven million parameters. Instead of trying to solve a problem in one pass, it guesses, checks itself, and refines the answer through recursion. The design is intentionally simple: no heavy mathematical machinery and no biological analogies—just a compact loop that improves its own output step by step.
Why it matters: the tiny model outperforms much larger language models on hard logic tasks. It reaches state-of-the-art test accuracy on puzzle benchmarks, including around 87.4% on Sudoku-Extreme, and it beats large models on ARC-AGI-2 (about 7.8% versus 4.9% for a top LLM). The core reason is error control. Big language models generate text token by token; one early mistake can derail the entire chain of thought. The recursive model revisits and corrects its work, so errors don’t snowball. The study also finds that cutting depth to two layers improves generalization and reduces overfitting for these constrained logic problems. In short: for analytical, well-scoped reasoning, deep recursion with a tiny network can be more reliable and efficient than scaling up parameter counts.
3
4
614
Mindblowing paper
xitter.cf/jm_alexia/status/19755…
New paper 📜: Tiny Recursion Model (TRM) is a recursive reasoning approach with a tiny 7M parameters neural network that obtains 45% on ARC-AGI-1 and 8% on ARC-AGI-2, beating most LLMs.
Blog: alexiajm.github.io/2025/09/2…
Code: github.com/SamsungSAILMontre…
Paper: arxiv.org/abs/2510.04871
226
you’re
done treating attention like stage magic
here to make the mechanism legible
no mystique, no gatekeeping
map: attention variants + inference path, distilled
premises
text → tokens → vectors
attention = soft selection over history
everything else is plumbing
time encodings
absolute index: short-range bias; brittle past train span
RoPE: rotary phases; extendable via NTK/YaRN scaling; check order sensitivity
ALiBi: linear distance bias; cheap; stable for longer spans
head topology
MHA: feature bands in parallel
MQA/GQA: many Q heads, few K/V heads → smaller KV, faster decode, mild accuracy tax
exact kernels
flash-style attention: tile Q/K/V; keep stats in SRAM; exact softmax; IO-aware
big prefill gains; steady decode wins with small tiles
structured sparsity
sliding/dilated windows: O(n·w); strong locality; weak global recall
block-sparse (local + random + global): pattern choice matters; tune or degrade
linearized/low-rank (Performer/Linformer/Nyström): kernel/landmark shortcuts; audit reasoning drift
context extension
RoPE scaling: stretch frequencies; watch positional distortion
sink/primer tokens: early-step stabilizers
memory tokens/layers: learned scratchpad; capacity emergent, not guaranteed
KV cache engineering
shape ≈ [B, L, H, d_k]; bytes ≈ 2·B·L·H·d_k·dtype_size
paged KV: page the cache; kill fragmentation; enable continuous batching
eviction: sliding window baseline → trims by recency/entropy/salience
two regimes
prefill: FLOPs + bandwidth bound → flash kernels, fused MLPs, larger batch
decode: KV-read bound → MQA/GQA, KV locality, KV quantization, careful scheduling
serving levers
batching: continuous intake; chunk prefill to keep SMs utilized
quantization: W8/W4; KV 8/4-bit where stable; re-eval long-context tasks
scheduler: prioritize short jobs; cap context; allow preemption; track P95/P99
parallelism: request-level; speculative paths; shard KV if needed
speculative and guided decode
draft-then-verify: small proposer + large confirmer → fewer expensive steps/token
logit guidance: light penalties/rewards for safety/format; monitor diversity entropy
metrics that decide
TTFT, TPOT, tokens/s/GPU
P95/P99 latency
VRAM per token
throughput at fixed QoS
perplexity/task deltas per change
anti-use rules
no windowed attention for cross-doc reasoning without retrieval
no blind RoPE stretch beyond train regime; test order flips
no MQA/GQA on fragile domains without fresh eval
no sparse patterns in prod without failure audits
shop-floor truths
bandwidth rules; kernels are IO plays first
the fastest model is the one whose KV fits
batch size is a business constraint wearing a tensor
1
211
Why doesn't anyone include @Alibaba_Qwen in benchmarks? Is it because of the model's power, or are there other factors, perhaps political?
@JustinLin610
Introducing Command R7B: the smallest, fastest, and final model in our R series of enterprise-focused LLMs!
It delivers a powerful combination of state-of-the-art performance in its class and efficiency to lower the cost of building AI applications.
cohere.com/blog/command-r7b
Just launched: An offline, open-source alternative to NotebookLM!
Features:
- PDF to audio conversion
- Create dialogues between two characters based on PDF content
- Built with Gradio
- Runs 100% locally on your machine
Inspired by NotebookLlama
Coming soon:
- Arabic language support
- More features in development
github.com/h9-tect/pdf-to-po…
New model from @GoogleDeepMind Gemma 2: Advanced open-source LLMs (2.6B, 9B, 27B params)
Architecture:
- Decoder-only transformer
- Rotary Position Embeddings (RoPE)
- GeGLU non-linearity
- Context length: 8192 tokens
- Alternating attention layers:
• Local sliding window (4096 tokens)
• Global attention (8192 tokens)
- Grouped-Query Attention (GQA) for 9B/27B models (num_groups=2)
- RMSNorm for layer normalization
- Logit soft-capping: attention@50.0, final@30.0
Key Innovation: Knowledge distillation
- Smaller models (2.6B, 9B) trained on larger model's output probabilities
- Richer gradients, improved performance
Training:
- 27B: 13T tokens, 9B: 8T tokens, 2.6B: 2T tokens
- Data: web docs, code, scientific articles
- SentencePiece tokenizer, 256k vocabulary
- Infrastructure: TPUv4/v5, GSPMD partitioner, MegaScale XLA compiler
- Carbon footprint: 1247.61 tCO2eq (carbon neutral via offsets)
Post-training:
- Supervised Fine-Tuning (SFT) on synthetic+human prompt-response pairs
- RLHF with larger reward model
- Model merging by averaging experiments
- New formatting: explicit <end_of_turn><eos> tokens
Performance:
- 27B model: 75.2 MMLU, 74.0 GSM8K, 71.4 ARC-c
- 9B model: Up to 10% improvement over previous version
- Competitive with models 2-3x larger
- Strong in multi-turn conversations, instruction-following
Safety & Responsibility:
- Extensive data filtering
- Safety-aligned fine-tuning
- Evaluated on safety benchmarks and assurance evaluations
- Responsible Generative AI Toolkit for developers
Evaluations:
- Academic benchmarks (MMLU, GSM8K, ARC, HellaSwag, etc.)
- Human evaluations for instruction-following, safety, multi-turn conversations
- Assurance evaluations: offensive cyber-security, CBRN knowledge, self-proliferation
- Persuasion capabilities tested (charm offensive, hidden agenda, money talks, web of lies)
Technical details:
- d_model: 2304 (2.6B), 3584 (9B), 4608 (27B)
- Layers: 26 (2.6B), 42 (9B), 46 (27B)
- Feedforward dim: 18432 (2.6B), 28672 (9B), 73728 (27B)
- Head sizes: 256 (2.6B, 9B), 128 (27B)
- Num heads: 8 (2.6B), 16 (9B), 32 (27B)
- Num KV heads: 4 (2.6B), 8 (9B), 16 (27B)
6
1,055
Congratulations to @JustinLin610 and his team for Qwen 72b domination on overall in @huggingface leaderboard v2
The Chinese king is here 🫡
1
5
765
Please @AnthropicAI add code interpreter and internet search to your upcoming product
3
576
Replying to @karpathy
@karpathy cookin something new
I'm very excited 😅
github.com/karpathy/LLM101n
51
I'm absolutely hooked on @llama_index. I highly recommend it to anyone looking to develop a RAG (Retrieval-Augmented Generation) application. Kudos to the team for their outstanding work!
5
562
A must read paper
I really enjoyed it
🚨Announcing the largest study focused on *how* to optimize the prompts within LM programs, a key DSPy challenge.
Should we use LMs to… Craft instructions? Self-generate examples? Handle credit assignment? Specify a Bayesian model?
By @kristahopsalong* @michaelryan207* &team🧵
1
11
1,558
I completely agree. While having a lot of technical content is beneficial, the lack of true understanding and experience among many writers is a serious issue. It makes it difficult for readers to differentiate between quality information and poorly-informed opinions. This isn't just a local problem; it's a universal issue affecting many industries.
The rapid growth of social media has democratized content creation, allowing anyone to share their thoughts and insights. While this inclusivity is positive, it also means that not all content meets high standards of accuracy and depth. Many individuals writing technical content lack the necessary expertise or practical experience. They may struggle to grasp the complexities of the topics they discuss, leading to superficial or misleading information.
For readers, this creates a significant challenge. Distinguishing between genuinely knowledgeable sources and those who are less informed is difficult. Inaccurate or shallow content can lead to misunderstandings, misinformed decisions, and a general erosion of trust in available resources.
To address this, we need to prioritize quality over quantity. Encouraging collaboration between technical experts and skilled writers can ensure content is both accurate and well-articulated. Implementing rigorous peer review processes and providing specialized training in technical writing can also help improve content standards.
Ultimately, raising the bar for technical content benefits everyone. It fosters a more informed audience, supports better decision-making, and strengthens the credibility of available resources.
حاجة بقالي فتره مش عايز اقولها بس كفى. عظيم ان يكون عندنا محتوي تقني كتير بس بجد عندنا مشكله ان كتير اوي مش فاهمين اللي بيتكلموا فيه كويس او معندهمش خبرة حقيقية. المشكله ان مش سهل المستمع يعرف العلم من الفجل!
2
341
I'm curious if it's true or not, I really want to give it a try
Many things that claimed to beat gpt-4 is probably a fraud
But I think it's fantastic according to their blog and they really beat gpt-4
Open models available TODAY can beat GPT-4 using structured generation 👇
While we are proud of this achievement, we wanted to talk about the communities and projects that made this possible 🧑🤝🧑
The reasons why, eventually, Open Source shall prevail
📖 blog.dottxt.co/oss-v-gpt4.ht…
4
348
I want to extend a huge thank you to @huggingface for their incredible support and honesty. I accidentally left an Inference Endpoint running and was worried about the charges. When I reached out to their billing support, they were not only understanding but also covered the costs for me. Their commitment to customer satisfaction and transparency is truly commendable. It's reassuring to know that there are companies out there that genuinely care about their users. Thank you, Hugging Face, for going above and beyond!
!
1
621












