Live data from Hacker News

GigaToken: ~1000x faster Language model tokenization

github.com

51–60 of 137 posts

Re: GigaToken: ~1000x faster Language model tokenization

#51

So the question becomes, how many other parts of the inference pipeline have left 1000x optimization opportunities lying on the table?

The problem with the rest of inference is that changes are not trivially correct or incorrect, as they are with the tokenization layer.

Eh, linear algebra changes are still easy to measure correctness, it's just that you're competing with 50 years of research for most of them, less low hanging fruit.

Re: GigaToken: ~1000x faster Language model tokenization

#52

Very interesting project! Are there benchmarks for the "compatibility mode" or are all the numbers for the Gigatoken API?

Numbers are for the Gigatoken API, but compatibility mode just means eating a bunch of Python overhead (creating lists, reading strings to bytes). You can expect a modest ~200-300x speedup with compatibility mode depending on how you use it.

> a modest ~200-300x speedup with compatibility mode

marcelroed is modest, this speedup is not. Good work.

Re: GigaToken: ~1000x faster Language model tokenization

#54

Earlier quoted context omitted.

Author here! In my case it's mostly pretraining experiments, where you might want to change your data mixture/filtering/processing of training data, and splits are usually done at a token-level instead of a text level. In this case we usually run for days on a huge number of CPUs to finish tokenizing something like DCLM. From what I can tell it's also useful for inference when considering time-to-first-token (TTFT) a…

> I'm not sure about the proprietary inference engines, but in the open source ones tokenization is done before looking up if a text sequence is present in the KV-cache Is this necessary? Tokenisation is deterministic, so for a hit/miss check you can lookup on (a hash of) the source text instead of the tokens. You only need the tokens once you're seeking for the exact token index having determined there is a hit. Tha…

It's usually not as binary as "hit" or "miss" with a prefix cache, and you need to know the token boundaries to know where the cache hit ends.

The current structures used for KV-caching in vLLM and SGLang work by chunking the KV-cache tokens into prefix trees, and you need to hash chunks of tokens in order to look up in these, meaning you need to be able to slice up your tokens by token count.

Again I have no idea what proprietary engines are doing, but this is why open source stuff needs to tokenize before cache lookup at least.

Re: GigaToken: ~1000x faster Language model tokenization

#55

This is awesome, but tokenization is typically Presumably there's a host of applications that just need to tokenize, though, and this would be great for those!

I run an AI platform and we need to tokenize fast and early to make a lot of decisions on the subsequent steps (things like routing, rate limiting and such). Its really important to do this efficiently even though its not a large % of total end to end time for the request.

‘I run an AI platform’ I have so many genuine questions I don’t even know where to start.

Re: GigaToken: ~1000x faster Language model tokenization

#56

Earlier quoted context omitted.

Tokenization is <0.1% of the inference time for the first token in the same way it is <0.1% for the last.

Time to first token refers to the time until the model outputs one token, which includes the time to process the entire prompt (doing prefill). The GPU time per token is much lower when doing prefill, so the significance of tokenization is higher.

Have you done preliminary numbers on replacing tokenizer on, say, llama-server?

Re: GigaToken: ~1000x faster Language model tokenization

#57

Earlier quoted context omitted.

I run an AI platform and we need to tokenize fast and early to make a lot of decisions on the subsequent steps (things like routing, rate limiting and such). Its really important to do this efficiently even though its not a large % of total end to end time for the request.

‘I run an AI platform’ I have so many genuine questions I don’t even know where to start.

Pick one. I would like to hear it.

Re: GigaToken: ~1000x faster Language model tokenization

#58
post #2

What sort of setups do people have that are bounded by the speed of the tokenizer?

I worked on a system a couple years ago with a BERT-based model (64M parameters) used for classification. The rest of the system could process data at gigabytes per second, and so here tokenization at a measly few megabytes per second really slowed things down. The model inference was more expensive than tokenization, but tokenization was still >10% of total runtime.

Re: GigaToken: ~1000x faster Language model tokenization

#59

engineering effort to make something 1000x faster that accounts for 0.1% of total runtime is the most software developer thing imaginable

1000x faster on 0.1% of runtime = 0.1% saved. Amdahl remains undefeated.

Globally that’s ~50 GWh/yr, or ~5.7 MW continuous:

• 4,700 American homes

• a week of British tea

Re: GigaToken: ~1000x faster Language model tokenization

#60

engineering effort to make something 1000x faster that accounts for 0.1% of total runtime is the most software developer thing imaginable

I initially had a Rust-based word cloud generator that generates word clouds in high resolution in ~100 milliseconds whereas it would take other generators a couple seconds to do the same thing. Does the world need a super-fast word cloud generator? No. Do I want a super-fast word cloud generator? Yes.

I later found enough optimizations to reduce the generation speed all the way down to ~16ms. Do I need a word cloud generator that fast? No. But if I have a word cloud generator it's going to be as fast as possible dammit.

Post reply on HN