โš ๏ธ Heads up: this tool's official website appears to be unreachable right now. It may be offline, rebranded, or temporarily down.
MEGABYTE-pytorch

MEGABYTE-pytorch

โ˜… 3.6 ๐Ÿ”– 600 saves ๐Ÿ’ฐ Free GitHub

MEGABYTE-pytorch is a PyTorch implementation of MEGABYTE, the multiscale transformer architecture from the paper “Predicting Million-byte Sequences with Multiscale Transformers”. It models raw bytes directly, without a tokenizer, which opens the door to very long contexts across text, audio and other byte streams. The project is released under the MIT license, has about 657 stars on GitHub, and was last updated in December 2024.

Overview

The MEGABYTE design splits a byte sequence into patches. A large global transformer reasons over the patch-level stream, while smaller local transformers predict the bytes inside each patch, so the model can in principle handle sequences of a million bytes. This repository by Phil Wang (lucidrains) follows the paper and then generalizes it further: you can stack more than the paper’s two stages, with multiple local models at different scales. Configuration is explicit and code-first, setting vocabulary size, per-stage dimensions, sequence lengths, depths and attention heads, with flash attention supported. Installation is a single pip command, and the README shows a complete training and sampling example in a few lines.

Key Features

  • Faithful PyTorch implementation of the MEGABYTE paper
  • Tokenizer-free modeling directly over raw byte sequences
  • Multiscale architecture with global and local transformer stages
  • Generalized beyond two stages, with multiple local models supported
  • Flash attention support for faster training
  • Installable from PyPI with a concise usage example

Like other lucidrains repositories, the code favors clarity over framework magic, which makes it a popular reference implementation to read alongside the paper itself. Researchers often use it as a baseline, or as a starting point for testing their own multiscale and long-context ideas, before scaling experiments up to larger runs.

๐Ÿ’ณ Pricing

MEGABYTE-pytorch is free and open source under the MIT license. There is no hosted version; you train and run models on your own hardware.

Who Is It For

MEGABYTE-pytorch is for deep learning researchers experimenting with long-context modeling, tokenizer-free architectures and byte-level sequence prediction across different data modalities.

๐Ÿš€ Visit MEGABYTE-pytorch Official Site

๐Ÿšฉ Report an issue