<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/ms3p-sushima-engineering-a-production-grade-byte-level-bpe-tokenizer-from-scratch-ztnhuzdzw" -->

---
title: MS3P Sushima: Engineering a Production-Grade Byte-Level...
description: A detailed engineering case study on building a production-grade byte-level BPE tokenizer called MS3P Sushima from scratch in Python. The post covers three...
canonical: https://daily.dev/posts/ms3p-sushima-engineering-a-production-grade-byte-level-bpe-tokenizer-from-scratch-ztnhuzdzw
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: MS3P Sushima: Engineering a Production-Grade Byte-Level BPE Tokenizer from Scratch | daily.dev
og:description: A detailed engineering case study on building a production-grade byte-level BPE tokenizer called MS3P Sushima from scratch in Python. The post covers three...
og:url: https://daily.dev/posts/ms3p-sushima-engineering-a-production-grade-byte-level-bpe-tokenizer-from-scratch-ztnhuzdzw
og:image: https://api.daily.dev/og/posts/zTnHUzDZW.png
og:image:alt: MS3P Sushima: Engineering a Production-Grade Byte-Level BPE Tokenizer from Scratch
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# MS3P Sushima: Engineering a Production-Grade Byte-Level BPE Tokenizer from Scratch

**[Medium](https://daily.dev/sources/medium_js)** · 21 min read · 0 upvotes · 0 comments

## Summary

A detailed engineering case study on building a production-grade byte-level BPE tokenizer called MS3P Sushima from scratch in Python. The post covers three major components: a deterministic multilingual corpus generator (30+ languages), the BPE training algorithm with heap-based incremental updates, and three successive engine revisions that fixed real production bugs. Bug #1 was a quadratic O(n²) inference path that was replaced with a doubly-linked-list + min-heap approach. Bug #2 was a vocab size accounting error that silently produced 7 extra token IDs, breaking downstream embedding tables. Bug #3 was a memory leak where rejected merge candidates were never removed from bookkeeping structures. The post also covers atomic model persistence using temp-file-then-rename, graceful optional dependency degradation (msgpack, cachetools), and a regression suite that encodes each failure mode explicitly.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@smcgandco/ms3p-sushima-engineering-a-production-grade-byte-level-bpe-tokenizer-from-scratch-a18b5a6f22f3>

## Similar posts on daily.dev

- [LLM Tokenizers Simplified: BPE, SentencePiece, and More](https://daily.dev/posts/llm-tokenizers-simplified-bpe-sentencepiece-and-more-snofgtfbe) · DigitalOcean Community · 2 upvotes · 0 comments
- [Let’s Build the GPT Tokenizer: A Complete Guide to Tokenization in LLMs – fast.ai](https://daily.dev/posts/let-s-build-the-gpt-tokenizer-a-complete-guide-to-tokenization-in-llms-fast-ai-enm7elmas) · fast.ai · 1 upvotes · 0 comments
- [Bytes Speak All Languages: Cross-Script Name Retrieval via Contrastive Learning](https://daily.dev/posts/bytes-speak-all-languages-cross-script-name-retrieval-via-contrastive-learning-nexqauuco) · Towards Data Science · 2 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#nlp](https://daily.dev/tags/nlp)

[View this post on daily.dev](https://daily.dev/posts/ms3p-sushima-engineering-a-production-grade-byte-level-bpe-tokenizer-from-scratch-ztnhuzdzw)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"MS3P Sushima: Engineering a Production-Grade Byte-Level BPE Tokenizer from Scratch","url":"https://daily.dev/posts/ms3p-sushima-engineering-a-production-grade-byte-level-bpe-tokenizer-from-scratch-ztnhuzdzw","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/ms3p-sushima-engineering-a-production-grade-byte-level-bpe-tokenizer-from-scratch-ztnhuzdzw"},"datePublished":"2026-07-26T09:05:54.423Z","dateModified":"2026-07-26T09:06:35.824Z","description":"A detailed engineering case study on building a production-grade byte-level BPE tokenizer called MS3P Sushima from scratch in Python. The post covers three...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9d715e764edf89cb9e4367b315bb2c57?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9d715e764edf89cb9e4367b315bb2c57?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/ms3p-sushima-engineering-a-production-grade-byte-level-bpe-tokenizer-from-scratch-ztnhuzdzw","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,nlp","timeRequired":"PT21M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"MS3P Sushima: Engineering a Production-Grade Byte-Level BPE Tokenizer from Scratch"}]}
```

