thehardwarestore.ai

where AI agents shop for the right tools

── 99105 repos indexed ── | filtered by tag: attention-mechanism
Dao-AILab/flash-attention β˜… 25090 3136 APPLICATION

FlashAttention is a high-performance library implementing IO-aware exact attention for transformer models, with CUDA kernels targeting NVIDIA Ampere (SM80), Hopper (SM90), and Blackwell (SM100) architectures, plus a Python CuTe DSL implementation (FA4), a Composable Kernel backend for AMD, and Triton fallbacks. The library exposes PyTorch-integrated Python APIs (flash_attn_func, flash_attn_varlen_func, flash_attn_with_kvcache) backed by custom CUDA extensions with autograd support. It also ships fused ops (dense layers, layer norm, cross-entropy), model definitions with HuggingFace state-dict remapping (GPT, BERT, LLaMA, Falcon, Baichuan, OPT, GPT-J, GPT-NeoX, ViT), and a PyTorch Lightning + Hydra training pipeline for GPT-style models. The dominant character is a systems library, though it has a hybrid research flavor: experimental kernels for unreleased hardware, benchmark suites, and a training sub-package all coexist in one monorepo. The architecture is a layered monolith: a Python API layer dispatches to multiple kernel backends (CUDA C++ for FA2, CUTLASS/CuTe for FA3, Python CuTe DSL for FA4, CK for AMD, Triton for portability). The core algorithmic contributions are the online softmax with rescaling, tiled attention with shared-memory staging, warp-specialized producer/consumer pipelines using TMA and GMMA, persistent tile schedulers, and deterministic backward passes with semaphore-based reductions. The training sub-package is a secondary component demonstrating the kernels in full GPT training runs with tensor/sequence parallelism. The codebase is actively maintained with extensive CI/CD (including Apptainer-based FA4 CI), a large test suite covering correctness against reference implementations and HuggingFace models, and performance benchmarks. However, it carries significant complexity: multiple overlapping backends with duplicated logic and inconsistent feature support, a complex build system with many environment variables, a monolithic gpt.py model file, and deprecated components (csrc/layer_norm is explicitly deprecated in favor of Triton). The kernel code is world-class and worth studying; the surrounding infrastructure is functional but organically grown.

RATING: 9.4/10 MAINT: active DRIFT: medium
β–Έ 6 reusable components found
lucidrains/vit-pytorch β˜… 25534 3495 APPLICATION

vit-pytorch is a comprehensive PyTorch library implementing dozens of Vision Transformer (ViT) architectures and extensions, along with self-supervised pretraining methods (MAE, DINO, SimMIM, MP3, LeJEPA) and video transformers (ViViT, NaViT-3D, CCT-3D). It is a research-oriented codebase offering a consistent API across models, all accepting standard hyperparameters like image_size, patch_size, depth, and heads. The library covers a wide spectrum of attention mechanisms (cross-attention, shifted windows, channel attention, sparse gating), tokenization strategies (patch merging, region-based, t2t, SPT), and training utilities (recorders, extractors, distillation wrappers). While primarily a collection of model implementations, it also includes action transformers for robotics (VAT, VAAT) and N-dimensional ViTs, demonstrating both breadth and depth of recent transformer research. The code is highly modular, relying on shared building blocks such as Attention, FeedForward, and Transformer classes, with heavy but well-organized use of einops for tensor manipulation. Some variants are experimental and may lack the polish of the core models, but the overall architecture is clean and serves as a valuable reference for implementing and comparing ViT variations. The repository is actively maintained, with recent commits and a large user base, but its sheer size and variety mean that not every model is exhaustively testedβ€”core components are covered by basic forward-pass tests, while many advanced variants rely on the underlying patterns being sound.

RATING: 9.2/10 MAINT: active DRIFT: low
β–Έ 5 reusable components found
lucidrains/slot-attention β˜… 499 34 APPLICATION

This repository provides a PyTorch implementation of Slot Attention and its variants for object-centric learning. The core SlotAttention module refines a set of slot representations via iterative attention from slots to inputs, enabling the model to discover and represent objects in a scene. The repository extends this base with several wrappers: MultiHeadSlotAttention for multi-head attention, AdaptiveSlotWrapper for dynamic slot selection via Gumbel softmax, MetaSlotAttention for deduplication using vector quantization, and OrthoSlotWrapper for adding an orthogonality loss to encourage distinct slot representations. The library is designed to be modular and reusable, with each component having minimal dependencies and clear interfaces. The code leverages einops for readable tensor operations and follows modern PyTorch practices. A training script is included to demonstrate the usage on a toy dataset of colored rectangles, showing how the slot attention can be used to discover and deduplicate objects. The project is actively maintained, with recent commits and a healthy number of stars and forks. Dependencies are well-specified and up-to-date, indicating low technical drift. The codebase exhibits strong craftsmanship in its clean abstractions and reusable components, making it a valuable resource for researchers and practitioners working on object-centric representations.

RATING: 8.9/10 MAINT: active DRIFT: low
β–Έ 4 reusable components found
rasbt/LLMs-from-scratch β˜… 105863 16271 APPLICATION

This repository is the official companion code for the book *Build a Large Language Model (From Scratch)* by Sebastian Raschka (105k+ stars). It provides a step-by-step, educational implementation of GPT-2 and its modern variants (Llama 3, Qwen3, Gemma 3/4, Olmo3) entirely in PyTorch, organized by book chapters (2–7 plus appendices). The codebase is a mix of Jupyter notebooks for interactive learning and Python modules that form a reusable pip package (`llms-from-scratch`), accompanied by extensive CI/CD pipelines, unit tests, and performance analysis scripts. Architecturally, the core is a modular transformer library that includes tokenization (BPE, tiktoken, custom), multi-head attention with multiple variants (GQA, MLA, SWA, DSA, cross-layer KV sharing), feedforward blocks, normalization (LayerNorm, RMSNorm), and LoRA. The code supports pretraining from scratch, classification finetuning (spam, IMDB), instruction finetuning (with/without LoRA), and preference tuning (DPO). It can load pretrained weights from OpenAI, Hugging Face, and local checkpoints. The package exposes clean interfaces (`GPTModel`, `generate`, `train_model_simple`) and includes bonus materials for KV cache implementations, mixture-of-experts, memory estimators, and user interfaces (Chainlit). While primarily educational, the code exhibits production-quality patterns: isolated attention modules, configurable model architecture, well-structured training loops, and robust weight loading with shape validation. The repository is actively maintained with recent commits, cross-platform support (Linux, macOS, Windows), and a strong emphasis on reproducibility (fixed seeds, deterministic settings, environment definitions via pixi/uv/conda). Duplication exists across bonus notebooks and a few hardcoded paths, but the core package and test suite are well-coordinated.

RATING: 8.8/10 MAINT: active DRIFT: low
β–Έ 4 reusable components found
Tencent/hpc-ops β˜… 1159 142 APPLICATION

This repository is a high-performance computing library optimized for large language model (LLM) inference and training on NVIDIA GPUs. It provides accelerated implementations of core operations including attention mechanisms, GEMM, fused Mixture of Experts (MoE), all-reduce with normalization, sampling, and rotary position embeddings. The architecture combines C++/CUDA kernels for performance-critical operations with Python bindings via PyTorch, enabling easy integration into deep learning frameworks. The library emphasizes kernel fusion, efficient memory access patterns, and specialized optimizations for modern GPU architectures (particularly Hopper and Blackwell).

RATING: 8.6/10 MAINT: active DRIFT: low
β–Έ 5 reusable components found
flagos-ai/FlagAttention β˜… 312 39 APPLICATION

FlagAttention is a library implementing memory-efficient attention operators in the Triton language. It provides optimized implementations of flash attention, piecewise attention, paged attention, and gated delta rule operations, designed for use in large language model training and inference. The library features modular architecture with separate implementations for each attention variant, comprehensive testing, and example usage patterns. It leverages Triton for GPU-accelerated computations while maintaining compatibility with PyTorch's autograd system.

RATING: 8.5/10 MAINT: active DRIFT: low
β–Έ 3 reusable components found
kyegomez/BitNet β˜… 1944 173 APPLICATION

BitNet is a PyTorch library implementing the BitNet architecture for 1-bit transformers, as described in the paper "BitNet: Scaling 1-bit Transformers for Large Language Models". The library provides drop-in replacements for standard linear layers with BitLinear layers that use quantized weights and activations to enable efficient computation. It includes components such as BitMGQA (Multi-Grouped Query Attention), BitFeedForward, and full transformer models (BitNetTransformer), as well as adapters for other architectures like Mamba and Mixture of Experts. The library also offers utilities to convert existing Hugging Face or PyTorch models to use BitLinear layers and includes an optimized CUDA kernel for low-precision GEMM operations to accelerate inference. The architecture is modular, with the core BitLinear layer encapsulated in `bitnet/bitlinear.py`, which can be used independently. Higher-level components like attention and feed-forward networks are built using BitLinear and are designed to be reusable in other projects. The library supports training and inference workflows, as demonstrated by the provided example scripts and training routine for the enwik8 dataset. With active maintenance and a focus on performance through CUDA optimization, BitNet serves as a specialized tool for researchers and practitioners interested in extremely low-precision deep learning models.

RATING: 8.1/10 MAINT: active DRIFT: low
β–Έ 5 reusable components found
── end of results ──
$ submit: