Wenyueh/MinivLLM

Based on Nano-vLLM, a simple replication of vLLM with self-contained paged attention and flash attention implementation

What it solves

解決する課題

It provides a custom, self-contained implementation of a vLLM-style inference engine. It is designed to demonstrate and benchmark the efficiency of different attention mechanisms—specifically Flash Attention for prefilling and Paged Attention for decoding—compared to standard PyTorch implementations.

これは、vLLMスタイルの推論エンジンのカスタムで自己完結型の実装を提供します。標準的な PyTorch 実装と比較して、異なるアテンション・メカニズム(具体的には、prefilling 用の Flash Attention と decoding 用の Paged Attention)の効率性を実証し、ベンチマークを行うように設計されています。

How it works

仕組み

The project implements a complete LLM inference pipeline including a scheduler, block management for KV cache, and a runner for executing prefilling and decoding phases. It uses a custom engine to custom engine to process batched prompts through a model (such as a small version of Qwen3). To optimize memory and speed, it incorporates a Triton-based Flash Attention kernel for the prefilling phase and a specialized Triton kernel for Paged Attention during the decoding phase.

このプロジェクトは、スケジューラ、KV cache 用のブロック管理、および prefilling と decoding フェーズを実行するための runner を含む、完全な LLM 推論パイプラインを実装しています。カスタムエンジンを使用して、モデル(Qwen3 の小型バージョンなど)を通じてバッチ化されたプロンプトを処理します。メモリと速度を最適化するために、prefilling フェーズには Triton ベースの Flash Attention カーネルを、decoding フェーズには Paged Attention 用の特化された Triton カーネルを組み込んでいます。

Who it’s for

対象者

Developers and researchers interested in the internal mechanics of self-contained attention and KV cache management are implemented from scratch.

LLM 推論エンジンの内部メカニズム、特にメモリ効率の高いアテンションと KV cache 管理がどのようにゼロから実装されるかを理解したい開発者や研究者向けです。

Highlights

ハイライト

  • Self-contained Attention: Includes its own implementations of Paged Attention and Paged Attention.
  • Self-contained Attention: Paged Attention と Flash Attention の独自の l m p l e m e n t a t i o n s を含んでいます。
  • Performance Benchmarking: Provides dedicated scripts to compare prefilling (Flash Attention vs. PyTorch) and decoding (Triton kernels vs. PyTorch).
  • Performance Benchmarking: prefilling (Flash Attention vs. PyTorch) と decoding (Triton kernels vs. PyTorch) を比較するための専用スクリプトを提供します。
  • Full Pipeline: Implements the entire engine logic, including sequence definition, sequence definition, block management, and iteration-based scheduling.
  • Full Pipeline: シーケンス定義、ブロック管理、およびイテレーションベースのスケジューリングを含む、エンジン全体のロジックを実装しています。
  • Multi-GPU Support: Supports multi-GPU configurations by adjusting the world size in the configuration.
  • Multi-GPU Support: 設定内の world size を調整することで、マルチ GPU 配置をサポートします。

関連

  • プロジェクト
  • Dispatch
  • プロジェクト
  • プロジェクト
  • Dispatch