Set max context length per request independently of unified kv cache total size? #22658
Replies: 2 comments 2 replies
-
|
I fully agree that the dual semantics of --ctx-size is a huge problem. I would like to reserve 524288 KV cache so that who longish of 262144 can stay in VRAM in the KV cache in parallel. But because I use MTP, the docs tell me I need to set parallel=1 and enable unified KV. Without a separate flag that limits the context window per request to 262144, I then have a config in which a single chat can potentially exceed the max model context size of 262144 and I will run into undefined behavior. I therefore fully support the ieade that --ctx-size 128k should strictly limit the context size per request (and lead to either "context window exceeded" errors or to a rolling context window bheavior if the window is exceeded), and a separate parameter to set the total kv-cache-size is nedded. |
Beta Was this translation helpful? Give feedback.
-
For this use case you don't need a unified KV cache. These args should work exactly as you want: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Correct me if my understanding is wrong, but there doesn't seem to be a way to do this today. In llama-server
-c / --ctx-sizecurrently serves a dual purpose: It sets the total unified kv cache size that is shared by all slots during parallel processing, and also sets the max length for any single prompt whether parallel processing is in use or not.You can set ctx-size to larger than the model's native max context length to get a bigger unified kv cache for more parallel requests, but this also sets the max prompt length. Prompts will still ultimately be capped to the model's max length, but there doesn't seem to be a way to limit prompts to a shorter length than that cap while also increasing the unified kv cache size beyond that.
I think a second parameter is needed for the unified kv cache size, which defaults to the same size as the context length to maintain current behavior, but can be made larger. Something like:
--ctx-size 128k --unified-kv-cache-size 512kUse case example: Using a model with a native 256k max context length, I want to configure a max prompt length of 128k and a unified cache big enough for 4 parallel requests at 128k. If I set
-c 512k, then the unified cache size will be correct, but the max prompt length will end up at 256k, not 128k, and its possible 2 requests will saturate the unified cache. If I set-c 128kthen the max prompt length will be 128k, but the unified cache will be too small for 4 parallel requests.Beta Was this translation helpful? Give feedback.
All reactions