Efficient MultiModal Data Pipeline
Data loading, not the model or hardware, was the bottleneck in nanoVLM training: naive pad-to-longest batching wasted roughly 60% of each batch on padding tokens. The pipeline is rebuilt step by step, first with a fixed max length that drops long samples, then by treating batching as a knapsack/bin-packing problem using a PyTorch IterableDataset, worker sharding and a producer-consumer queue. Greedy packing is compared with First Fit Decreasing on toy data. The final ConstantLengthDataset applies a balanced greedy knapsack that respects both token and image budgets, an approach taken from NVIDIA's Eagle 2 paper, and produces dense multimodal batches with minimal padding.
Related posts
- Boost your throughput with dynamic batching
Modal mediumAdept
Modal added a `@modal.batched()` decorator that groups incoming requests into batches flushed when either `max_batch_size` is reached or `wait_ms` elapses, avoiding the unbounded waits of fixed-size batching. Batching helps GPU inference because model weights (over 6 GB for Whisper large v3) must be moved from memory to compute units per pass, and inference is usually memory-bandwidth bound. On an A10G, batching Whisper with a max batch size of 64 raised throughput from about 1.2 to 3.3 requests per second per container, cutting inference cost by roughly 65%. The function only needs to accept and return lists.
- nanoVLM: The simplest repository to train your VLM in pure PyTorch
Hugging Face mediumAdeptnanoVLM is a minimal, readable pure-PyTorch toolkit for training small Vision Language Models, inspired by nanoGPT and runnable on a free Colab notebook. It pairs a SigLIP vision encoder with a Llama 3-style SmolLM2 decoder, joined by a modality projector made of a pixel shuffle and a linear layer, which cuts the number of image tokens. Training uses two learning rates (a higher one for the freshly initialized projector, a lower one for the pretrained backbones), mixed precision, and cosine decay with warmup, and evaluates on MMStar. A reference model trained for about 6 hours on one H100 with roughly 1.7M Cauldron samples is published for inference via generate.py.
- Prefill and Decode for Concurrent Requests - Optimizing LLM Performance
Hugging Face mediumAdeptLLM token generation splits into a compute-bound prefill phase, which processes all prompt tokens in parallel to produce the first token, and a memory-bandwidth-bound decode phase, which produces later tokens one at a time. These map to time to first token and time per output token. Static batching leaves the GPU underutilized and delays new requests. Prefill-first continuous batching (vLLM, TGI) minimizes time to first token but pauses running decodes. Chunked prefill interleaves prefill chunks with decode steps, trading a small time-to-first-token increase for smoother decoding. At TNG it raised total throughput by about 50%, and the default chunk size is recommended when load patterns are unpredictable.
- PRX Part 4: Our Data Strategy
Hugging Face hardMasterPRX's pre-training corpus for a 7B text-to-image model is assembled from public and internal datasets, re-captioned with a VLM into long dense paragraphs, curated in Lance and streamed to training as Mosaic Data Shards. The pipeline favors breadth over aesthetic filtering and relies on faithful captions to turn imperfections like text or logos into promptable attributes. Measured decisions include storing images as JPEG quality 92, since PNG-vs-JPEG training runs were indistinguishable, and computing Qwen3-VL text latents on the fly for only a ~3–4% throughput cost. Over-fragmented Lance tables made queries slow until compaction to ~1M rows per fragment, and long Qwen2.5-VL captions clearly beat short LLaVA captions on FID, CMMD and DINO-MMD.
- Serving MiniMax-M3 for efficient inference: Unlocking 1M-Token Context and Multimodality Without Regrets
Together AI hardMasterServing MiniMax M3, a 1M-context multimodal model built on block-sparse MiniMax Sparse Attention (MSA), took several engine and kernel changes that together raised throughput 81–125% across concurrency levels on agentic traffic. Prefill uses a KV-block-major kernel that loads each KV block once for all queries attending to it, then merges partial outputs with a log-sum-exp reduction. Decode reuses existing GQA paged-attention kernels by building per-KV-group page tables and using strided views of the KV cache, which added 5% decode throughput. The index-scoring kernel uses an AB-swapped HMMA layout over 128-token key blocks. A Rust gateway (SMG) does image and video preprocessing on the CPU before requests reach the GPU.