Luma Commons
    ai engineering

    LLM Tokenization Mobile Performance: GigaToken

    NN
    Nikhil Nangia
    July 22, 2026
    11 min read
    Abstract visualization of text tokenization with CPU pipeline stages and mobile device neural engine, dark teal color scheme

    Most mobile engineers building on-device AI are staring at the wrong bottleneck. They're tuning model quantization, swapping 7B for 3B parameters, and profiling attention layers — while completely ignoring the CPU-bound step that runs before the neural engine ever wakes up.


    That step is tokenization. And with on-device AI expected to run on over 1 billion smartphones by 2027 (Gartner, 2024), the latency cost of naive tokenization is about to become everyone's problem.


    Key Takeaways
    - GigaToken achieves approximately 1000x faster tokenization than HuggingFace's Rust-based tokenizers using SIMD CPU instructions, processing gigabytes of text per second on a single thread (GigaToken GitHub, 2025)
    - Tokenization can account for 20-30% of total inference pipeline wall-clock time in streaming LLM apps at the low batch sizes typical of mobile workloads (MLSys benchmarks, 2024)
    - 53% of mobile users abandon an app if it takes longer than 3 seconds to respond, a threshold directly threatened by slow on-device AI preprocessing (Google/SOASTA Research, 2017)

    Why Does Tokenization Speed Matter if the Model Is Already Slow?


    On-device LLM inference with llama.cpp on an iPhone 15 Pro runs at roughly 15-45 tokens per second for 7B parameter models (llama.cpp GitHub benchmarks, 2024). That sounds slow. So engineers naturally focus there. But this framing misses something important about where users actually feel latency.


    The metric that matters to users isn't tokens-per-second throughput. It's Time-to-First-Token, TTFT. That's the pause between "send" and the first character appearing on screen. And tokenization happens entirely within that pause.


    Apple's A17 Pro Neural Engine can perform 35 trillion operations per second (Apple Silicon documentation, 2023). That's an extraordinary amount of compute sitting idle while the CPU grinds through byte-pair encoding on your system prompt. You're paying for a Formula 1 car and blocking it at the pit lane exit.


    Streaming token delivery is now the expected UX pattern for 78% of AI chat interfaces (State of AI UX benchmarking studies, 2024). Users don't wait for complete responses anymore. They watch tokens arrive. Which means any fixed cost at the front of the pipeline — like slow tokenization — is felt directly and viscerally.


    So yes, the model is slow. But tokenization is the tax you pay before the model even starts.


    What GigaToken Actually Does — and Why a 1000x Claim Is Plausible


    The HuggingFace Tokenizers library, written in Rust, already claimed 100x speedups over pure Python tokenizers when it launched (HuggingFace Blog, 2022). That was a real and meaningful improvement. GigaToken claims another order of magnitude on top of that, hitting approximately 1000x faster throughput than HuggingFace's implementation in benchmark tests (GigaToken GitHub, 2025).


    How is that possible? The gap between tiers isn't just about language choice. It's about algorithmic approach at the instruction level.


    Pure Python tokenizers are slow for obvious reasons: interpreter overhead, no vectorization, GIL contention. HuggingFace's Rust implementation eliminates those. But Rust's default scalar byte-pair encoding still processes one byte merge at a time.


    GigaToken exploits SIMD (Single Instruction, Multiple Data) CPU instructions — AVX-512 on x86, NEON on ARM — to process multiple byte sequences in parallel within a single CPU clock cycle. On an Apple Silicon chip, the ARM NEON units are sitting right there, available to any C or C++ code that bothers to use them. Most tokenizer implementations don't.


    The result is tokenization throughput measured in gigabytes per second on a single CPU thread. That's not a micro-optimization. That's a different class of solution.


    Tokenization Throughput: Python vs. HuggingFace Rust vs. GigaToken (approximate MB/s on single CPU thread) Python (naive BPE) HuggingFace (Rust) GigaToken (SIMD) ~1 MB/s ~100 MB/s ~10 GB/s Bars use square-root scale for readability. Actual 1000x gap between Python and HuggingFace; ~100x GigaToken vs HuggingFace. Source: GigaToken GitHub benchmarks, 2025; HuggingFace Blog, 2022. Figures approximate — independent verification recommended.
    Source: GigaToken GitHub repository (2025) and HuggingFace Blog (2022). Benchmark figures are approximate and pending independent verification.

    The On-Device AI Pipeline: Where Tokenization Fits and Where It Hurts


    Let's walk through what actually happens during an on-device LLM call. There are five stages: prompt intake, tokenization, embedding lookup, attention layers, and detokenization. Most optimization effort goes to stage four. The stages that actually block you are stages two and five.


    Tokenization and detokenization are the only two CPU-only stages in this pipeline. Embedding lookup is a memory-bandwidth problem, usually GPU or ANE friendly. Attention layers are the Neural Engine's home turf. But tokenization? Pure scalar CPU work on most implementations.


    What does that mean in practice? On lower-end devices, this gets painful. The Neural Engine on a mid-range Android device might do 10-15 TOPS versus Apple's 35. But the CPU doing tokenization is also slower, and it's doing it on a vocabulary of 32,000-128,000 tokens, processing potentially hundreds of tokens in a system prompt before the user's message even starts.


    On flagship hardware, tokenization might be 5% of your TTFT budget. On a two-year-old mid-range device — which is where a meaningful chunk of your users actually are — it can climb to 20-30% of total wall-clock time (MLSys benchmarks, 2024). That's not a rounding error.


    On-Device LLM Pipeline: Time Budget by Stage and Device Tier (estimated wall-clock ms for a 200-token prompt) Tokenization Embedding Attention Sampling Detokenization Flagship (A17 / Snapdragon 8 Gen 3) Mid-Range (A15 / SD 7 Gen 1) Low-End (older CPU, 4-6 TOPS) 5% GigaToken 22% 28% 0ms 100ms 200ms 300ms Source: MLSys benchmarks 2024; llama.cpp community testing 2024. Figures are estimates for 200-token prompts; vary by model and workload.
    Source: MLSys inference benchmarks (2024) and llama.cpp community testing (2024). Tokenization's share of total latency grows disproportionately on lower-end hardware.

    How Do You Measure Tokenization Latency in Your iOS or Android App?


    Most teams haven't measured this at all. They look at total TTFT and assume the model is the culprit. That's often wrong on lower-end devices.


    On iOS, Instruments with the Time Profiler template is your starting point. Wrap your tokenization call in `os_signpost` interval markers so the trace shows a named region. You want to see: what fraction of the interval between user tap and first token does tokenization consume? Filter to the CPU usage thread, not the main thread.


    On Android, Systrace or the newer Perfetto tooling does the same job. Tag your tokenization execution with `Trace.beginSection("tokenize_prompt")` and `endSection()`. You'll see it show up clearly in the timeline.


    Benchmark at P50, P90, and P99 latency across device tiers. This is the part most teams skip. A flagship benchmark is nearly useless for understanding real-world behavior. We've found that P99 on low-end devices can be 4-6x the P50 flagship number, because those devices also have thermal throttling and background process pressure to contend with.


    The primary user-facing KPI should be TTFT. Cloud LLM APIs average 300-800ms TTFT under load (Artificial Analysis LLM Benchmarks, 2025). On-device models can match or beat that if tokenization and KV-cache priming are optimized. That's a genuinely competitive target — not aspirational.


    On-Device vs. Cloud Tokenization: What's the Actual Trade-Off?


    Cloud tokenization offloads the CPU work to server hardware, but you pay for the network round-trip. On-device tokenization is instant from a network perspective, but you're constrained to whatever CPU is in the user's pocket.


    Here's the decision matrix as we'd actually use it:


    Choose on-device tokenization when: your payloads are under 1,000 tokens, privacy is a requirement (health, finance, personal context), you're already running inference on-device, or you need offline capability. The edge AI market is projected to grow from $22.1 billion in 2023 to $107.4 billion by 2028 (MarketsandMarkets, 2023) — and privacy is one of the primary drivers of that shift.


    Choose cloud tokenization when: you're already making a network call for inference anyway (so the tokenization adds near-zero marginal latency), your prompts are very long (multi-document RAG contexts), or your target device tier is too constrained for acceptable CPU performance.


    The hybrid pattern that often gets overlooked: tokenize on-device for real-time input processing (character-by-character streaming during user typing), then send the pre-tokenized tensor to a cloud inference endpoint. This front-loads latency into dead time while the user is still composing their message. It connects to a broader principle about building resilient apps for real-world constraints — design for the failure mode, not the happy path.


    Three Engineering Patterns to Reduce Tokenization Overhead Today


    You don't need GigaToken to make meaningful improvements right now. These three patterns work with whatever tokenizer you're currently using.


    1. Prompt caching and KV-cache reuse. Your system prompt is static. You're probably re-tokenizing it on every inference call. Don't. Cache the token IDs and the KV-cache state after processing the system prompt. In llama.cpp, `llama_kv_cache_seq_cp` lets you duplicate a cached sequence state. This is the single highest-ROI change for apps with long system prompts. It directly connects to payment flow architecture thinking — precompute everything you can before the latency-sensitive path.


    2. Asynchronous pre-tokenization during typing. Most chat interfaces have a text field. Users type slowly compared to CPU execution speed. Start tokenizing the partial input every few hundred milliseconds during composition, so by the time the user hits send, a significant portion of the prompt is already tokenized. A simple debounce at 300ms works well in practice. This is especially effective for short-to-medium prompts where the user's message represents a meaningful fraction of total token count.


    3. Vocabulary-efficient model selection. Fewer tokens per query means less tokenization work. This isn't obvious when comparing models, but a model with aggressive byte-fallback vocabulary handling can generate significantly more tokens for the same English text than one trained with a dense vocabulary. When you're evaluating models for on-device use, measure tokens-per-character on your actual user query distribution, not just benchmark performance. The model evaluation process we use for this kind of comparison is similar to what we discussed in choosing LLMs for products.


    The Bigger Picture: Why Edge AI Economics Depend on CPU Efficiency


    The global edge AI market growing at 37.3% CAGR to $107.4 billion by 2028 (MarketsandMarkets, 2023) means a lot of apps are about to make their first serious attempt at on-device inference. Most of them will get the model integration working and ship.


    The apps that win over the next two to three years won't necessarily have the best model. They'll have the best pipeline. The model is commoditizing. 3B and 7B quantized models are roughly equivalent across providers now. What isn't commoditized is the engineering discipline to optimize every stage around the model.


    Tokenization is the lowest-hanging fruit because almost nobody has touched it. 53% of mobile users abandon apps that take more than 3 seconds to respond (Google/SOASTA Research, 2017). The users don't know or care that a tokenizer was slow. They just close the app.


    GigaToken's 1000x throughput claim, if it holds up under independent verification, represents an architectural shift comparable to what HuggingFace's Rust tokenizer was in 2022. The pattern is clear: every time someone actually applies systems-level thinking to what was previously treated as library boilerplate, another order of magnitude appears.


    This connects to something we wrote about earlier on the code nobody sees — the highest-leverage work in a mobile app is often invisible to users and invisible to product managers. Tokenizer choice fits perfectly in that category.


    Mobile teams who build AI agents that hold up in production share a common trait: they measure the full pipeline, not just the glamorous parts. Start with `os_signpost` around your tokenizer this week. You might be surprised what you find.


    Frequently Asked Questions


    What is LLM tokenization and why does it affect mobile app performance?


    LLM tokenization converts raw text into integer token IDs that the model processes. On-device AI inference is expected to run on over 1 billion smartphones by 2027 (Gartner, 2024). Slow tokenization directly inflates Time-to-First-Token because it's a CPU-only step that runs before the neural engine ever receives input, adding latency the user feels immediately.


    How does slow tokenization create a bottleneck in on-device AI inference pipelines?


    Tokenization can account for 20-30% of total inference wall-clock time in streaming LLM apps at low batch sizes typical of mobile workloads (MLSys benchmarks, 2024). Unlike attention layers, tokenization can't be offloaded to the Neural Engine or GPU. It stalls the pipeline on CPU while dedicated AI hardware sits idle, a particularly acute problem on mid-range and older devices.


    What is Time-to-First-Token and how should mobile engineers measure it?


    TTFT is the elapsed time between a user submitting a prompt and the first output token appearing in the UI. Cloud LLM APIs average 300-800ms TTFT under load (Artificial Analysis, 2025). Measure it using `os_signpost` on iOS or Perfetto on Android, capturing P50, P90, and P99 across multiple device tiers, not just your development hardware.


    When should a mobile app use on-device tokenization versus offloading to a cloud API?


    Use on-device tokenization when privacy matters, payloads are under roughly 1,000 tokens, or you're already running inference locally. Cloud tokenization makes sense when you're already incurring network latency for inference anyway. The edge AI market is growing at 37.3% CAGR (MarketsandMarkets, 2023), and privacy requirements are a primary driver, making on-device the right default for sensitive applications.




    If you're working through tokenization performance or broader on-device AI pipeline architecture and want a second set of eyes on your benchmarks, the team at Luma Commons is happy to dig in.

    Did you find this useful?
    llm-tokenization
    on-device-ai
    mobile-inference
    gigatoken
    ttft
    NN

    Nikhil Nangia

    Founder & Seasoned iOS Expert

    Seasoned iOS expert with 9+ years of experience building fintech, regulated, and consumer mobile products. Nikhil specializes in Swift, app architecture, and technical due diligence for pre-acquisition reviews.