Earlier quoted context omitted.
What is stored is not the tokens, but all keys and values of all attention layers for each token.
As I pointed out, even if it's a gig of data that's still almost an order of magnitude more than the cost of a managed in-memory cache in the cloud. That's wild.
> A token is 32-bit integer.
No, in transformer, token is a vector, for larger models it is probably something like 6k-12k floats, assuming larger model sizes. Assume 8-bit precision, a token is more like 6-12kB, per token.
So assume 100k tokens, you will end up with 554MB for input tokens, ALONE.
Depending on your model architecture, the memory could vary, but from my observation, the runtime memory increase is at least on the same magnitude with the initial amount of memory usage upon loading the model, and this is for a moderate context length (So you are easily looking at caching 10~100GB of data, in a very hot state, and that is going to be very expensive indeed.