lab

A home for measured experiments, technical breakdowns, and long-form learning artifacts.

Reports, breakdowns and notes on inference, speech, audio and image generation, plus a few digests on how to do research.

Reports & notes

All articles →

Chameleon v2: replacing the style describer with one linear projection, and de-leaking Krea 2's sref space

Chameleon v1's 59.8M-parameter text describer, replaced by one closed-form linear map: a content-whitened supervised reduced-rank regression over 160,000 MegaStyle images into the frozen DiT's own text-token space. Zero text generation, zero DiT training. Image-to-sref lands at CSD .436 on Qwen-Image 2.1 (+.107 over unsupervised PCA) and ties it on FLUX.2-klein-4B in 4 steps. Reverse-engineering Lyra's Krea 2 adapter shows its codes vary more with the subject than the style; projecting out 4 Fisher directions cuts object copying from .141 to .087. $1.76 of GPU time.

report

Tessera: Content-Adaptive Image Tokenization in FLUX.2 Latent Space

A tokenizer on the frozen FLUX.2 VAE that spends tokens by content, with a one-pass router and a perceptual Judge that verifies every image: 61 tokens for a clean Mondrian, 1,021 for a dense Waldo page, and 369.6 on average (−63.9%) across a 90-image held-out set with 100% pass and no fallbacks. Two held-out arms are still pending, and a measured 512 to 4096 px resolution ladder (blockwise).

report

Tessera v2 lab report: trials, failures and final tables

Every trial, failure and final table behind Tessera v2: the Judge recalibration, router vs RD-tree, curated and held-out results, and the planned pixel head.

report

Retina: a Mondrian in 75 tokens, a Waldo page in 1,764

An image tokenizer on the frozen FLUX.2 VAE whose token count follows content: 75 tokens for the median Mondrian, 1,764 for a Where's Waldo page (23.5×), never more than the 2,304-token grid. A warp, a tuned complexity budget and a small refiner, measured against the full grid on 259 images, plus a 57M MAR that learns to choose its own length.

report

A style SAE inside Qwen-Image's text encoder: what Qwen3-VL knows about style

Top-k sparse autoencoders on Qwen3-VL activations of 48,000 MegaStyle images from 6,000 styles. 165 features are strongly style-specific (polaroid frames, ink mandalas, halftone print, pixel art, a purple palette), content features fire on their subject in any medium, and most features are neither. Qwen-Image's DiT never reads the image tokens these features live in, and an SAE filter that keeps only style features removes style instead of content. With an interactive explorer of about 1,150 features.

report

Chasing --sref on open models: style cartridges for Qwen-Image, and where native references copy from

A Midjourney-style reference code for FLUX.2-klein and Qwen-Image 2.1, with frozen models and two days of Colab. A describer that turns a style embedding into text-encoder soft tokens gives a 256-float cartridge that mixes, samples at random, keeps content and transfers to Qwen-Image zero-shot. Every adapter trained through the DiT's denoising loss learned zero reference-specific information. Qwen-Image's own reference input beats them all on style (CSD .43 vs .28), and a channel ablation shows that its style and its subject copying both ride on the reference's VAE latents. Relabelling the training styles with a vision LLM for $4 lifted the describer by +.10 CSD: the ceiling was the labels, not the language.

report

Image editing with Qwen-Image 2.1 on an RTX 5090: how it works and where the time goes

A 7.1 B single-stream image model on one RTX 5090: a Turbo edit takes 1.31 s at 1024² and 7.14 s at 2048², text encoder included, where the official diffusers pipeline takes 27.1 s and runs out of memory. With block-scaled FP8 and NVFP4 matmuls, a 4-bit attention kernel written for Blackwell, a prefix cache that stays quantised, a showcase of edits, and the full profile taken on an RTX PRO 6000.

report

Faster Mel-Band RoFormer on an RTX 3050: 22.19 → 7.64 seconds

Fused rotary and norms, a fixed token layout, per-axis attention, a skipped chunk and hand-written GEMMs that do the next memory pass in their epilogue: 2.90× faster at the original settings. A practical 25 % overlap option reaches 4.78 s (4.64×), with 0.082/0.042 dB mean truth-SDR loss. Baseline, quality gate, before/after traces and an explicit tradeoff review.

report

Stable Audio 3 medium: one TPU chip against an L4, module by module

A 2.16 B audio model profiled on a single Colab TPU v6e-1 and on an L4, with the same JAX port on both: 405 ms for 120 s of audio on one v6e chip (297× real time), 6.3× faster than the official PyTorch runtime on an L4. The SAME-L decoder costs more than the whole 24-block DiT on TPU, the port beats torch on the same GPU at every duration (3.97× at 5 s, 1.15× at 120 s), and the XProf capture puts the accelerator at ~100 % device-busy during the sampler — the only real idle is ~12 ms of host-side work.

report

944 → 306 ms: optimizing FLUX.2 klein-4B on one TPU v6e chip

FLUX.2 klein-4B at 1024² on a single TPU v6e-1, from a frozen 944.67 ms to 305.8 ms per image (3.09×, 1.06 → 3.27 img/s, 17.6 % → 54.5 % MFU), every step gated against the PyTorch oracle. Resident weights that were silently re-copied every call, a Pallas flash kernel that cut 2 GB-per-call fp32 score buffers, a fused qk-prep kernel where three XLA rewrites only moved the cost — and the measured dead ends: batching, sub-pixel VAE, and int8 that plateaus just short of the quality floor.

report

401 → 163 ms: Stable Audio 3 medium on one TPU v6e chip

Stable Audio 3 medium on a single Colab TPU v6e-1, from 401.4 ms to 163.4 ms, 2.46× faster and ahead of TensorRT fp8 on an RTX PRO 6000. Quality gated against official PyTorch; the full optimization log with teaching notes lives in an appendix.

report

klein-4B and Stable Audio 3 — where the time actually goes on TPU v6e

Per-module FLOPs, bytes moved, arithmetic intensity and collective cost for two generative inference workloads at their real shapes. Ridge point 560 FLOP/byte; FSDP-8 costs more than the entire math floor while Ulysses is nearly free; and the analytical model underestimates the measured L4 by 2.4-2.7× on the DiT and 8.1× on the text encoder, decomposed into m=1 prologues and small-shape GEMM inefficiency. Eleven tables, every row printed by one script.

report

nnx_save — four blocking bugs, one silent one, and a 4× memory tax

Testing an NNX checkpointing library I wrote and never tested: the committed version could not save a single model on current jax/flax/safetensors, an nnx.List stack loaded with random weights and no error — and how streaming reads plus an abstract builder cut a load from 3× the checkpoint in host RAM to 1.1×, with shard-per-process paths for a TPU pod.

report

How to build research & engineering taste

Pick questions worth answering, test claims, design around real constraints, and act without waiting to be asked. Includes notes on taste in inference engineering and a section on agency.

guide

Richard Hamming — You and Your Research

Why so few scientists do significant work, the 10-20 problems list, Friday "great thoughts", working with doors open, and the courage to tackle essential questions.

digest

Rich Sutton — The Bitter Lesson

The 70-year meta-pattern in AI: general methods that leverage search and learning scaled with compute inevitably crush human-engineered heuristics.

digest

Michael Nielsen — Principles of Effective Research

The craft of problem discovery, building tools for thought, Anki for deep retention, networked science, and navigating the research valley of despair.

digest

Claude Shannon — Creative Thinking

Six mental models for invention: radical simplification, structural isomorphism, state-space inversion, generalization, and playful tinkering.

digest

The inference-efficiency playbook — post-training and serving for faster models

The cost model, the full catalog of post-training families that buy serving speed (distillation, MTP/draft heads, QAD, architecture surgery, step distillation), the non-training engineering map across LLMs/diffusion/audio/VLMs, and the 2026 production numbers from fal and Baseten that prove the recipe end to end.

playbook

The Gabriel Petersson playbook — getting hired by not competing

A digest of @gabriel1's tweets on effective job search: proof-of-work demos instead of resumes, direct outreach past HR, risk-reversal trial offers, interviews you control — and the career-as- decisions mindset behind it all.

digest

chatterbox — architecture, model map & inference hot paths

Full codebase & systems breakdown of Resemble AI's Chatterbox suite (Base TTS, Multilingual V2/V3, Turbo 350M, Nano 110M, Voice Conversion): the T3 autoregressive LLM, S3Gen flow matching, MeanFlow distillation, iSTFTNet neural source filter vocoding, empirical benchmarks, and the optimization roadmap.

report

kaminari — anatomy of a single-GPU Qwen3-VL inference engine

Full repo walkthrough: the native Qwen3-VL port, static-KV compiled decode, int4 sidecar quantization, three schedulers, the 3.49×/9.35× optimization ladder — and what it would take to swap Qwen3-VL for GLM-OCR.

report

DSpark, every bolt and rivet — semi-autoregressive speculative decoding

Analogy → plain English → pseudocode, grounded in the paper (arXiv 2607.05147) and the DeepSpec reference code: the parallel backbone + Markov/RNN sequential head, the confidence head with sequential-temperature calibration, the hardware-aware prefix scheduler (with the Appendix A losslessness counterexample), training losses, the inference loop, results — and a minimal plan to train a DSpark drafter for a local VLM.

tutorial

From Experiments to an Inference Engineering Career

A 12-week plan for speech and multimodal inference engineering on constrained hardware: case studies, evidence inventory, and job search operating habits.

guide

Stable Audio 3 — Architecture & Inference Hot Path

The SAME autoencoder, the diffusion transformer and the 8-step sampling loop, costed against a 6 GB laptop GPU — plus why a sub-3 GB model can still OOM, and how these models are served at scale.

report

YuE2-3B — Architecture & RTX 3050 Feasibility

A frontier open music model that will not fit a 6 GB GPU: verified parameter inventory, the mixture-of-transformers and flow-matching inference path, and why the blocker is memory rather than speed.

report