# MoonshotAI/MoBA

MoBA: Mixture of Block Attention for Long-Context LLMs

Repository: https://github.com/MoonshotAI/MoBA
Canonical: https://ross.abutalabs.com/products/moba
Language: Python
License: MIT
License Family: permissive
Topics: flash-attention, llm, llm-serving, llm-training, moe, pytorch, transformer
Last push: 2025-04-03T07:28:06+00:00

## Health v2 (maintenance only)
Score: 27/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 14, release rhythm 35, longevity 40
- inputs: {"age_days": 562, "days_push": 517, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2169, forks 158 (observed 2026-08-28T04:06:21.647845+00:00)

## What it is
MoBA (Mixture of Block Attention) is a PyTorch implementation of a trainable block-sparse attention mechanism for long-context large language models, applying MoE-style top-k gating to select relevant KV blocks. It can seamlessly switch between full and sparse attention and is deployed in Kimi's long-context serving.

## Use cases
- speed up long-context llm attention with sparse block attention
- train a transformer that switches between full and sparse attention
- implement mixture-of-experts style gating for attention
- reduce quadratic attention cost for long sequences
- research efficient attention mechanisms for llms

## When to choose
- you are training or continue-training an llm for long-context workloads and want efficient sparse attention
- you need a flexible attention layer that can toggle between full and sparse modes
- you want a production-proven approach (used by Kimi) with FlashAttention integration

## When to avoid
- you need a drop-in speedup for an existing pretrained model without retraining
- you only run inference and cannot continue-train the model
- your sequences are short enough that full attention cost is acceptable

## Facets
- artifact type: library
- maturity: active
- function: llm-training, llm-inference, machine-learning, deep-learning
- domain: large-language-models, deep-learning, machine-learning
- platform: python
- tags: sparse-attention, mixture-of-experts, flash-attention, long-context, transformer, pytorch, gpu, linux

## Member repositories
- MoonshotAI/MoBA (main) score 27

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:21.647845+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T02:49:21.175735+00:00, confidence not recorded.
  - readme: https://github.com/MoonshotAI/MoBA (fetched 2026-08-28T04:06:21.647845+00:00, sha 0aa294b46a88)
- Data as of 2026-08-30T08:39:29.467469+00:00.
