LocalAI icon indicating copy to clipboard operation
LocalAI copied to clipboard

Model-specific `context_size` ignored, global Default Context Size always applied

Open Nathilion opened this issue 1 month ago • 2 comments

LocalAI Version

  • LocalAI v4.11.0 (58830f7ac508845a6f4efa32cfca06af422d4d82)

Describe the bug

For llama-cpp models, the parameters.context_size value defined in the model YAML appears to be ignored.

The effective context size always matches the global Default Context Size setting instead of the model-specific value.

This can be observed both in the startup logs (n_ctx_slot) and in VRAM usage.

To Reproduce

Model configuration:

backend: llama-cpp

parameters:
  context_size: 65535
  model: Qwen3-VL-4B-Thinking-Q4_K_M.gguf

Steps:

  1. Set the global Default Context Size to 32768.
  2. Configure the model with:
    parameters:
      context_size: 8192
    
  3. Restart LocalAI.
  4. Observe the startup log:
    load_model: initializing, n_slots = 1, n_ctx_slot = 32768
    
  5. Change the global Default Context Size to 4096.
  6. Restart LocalAI.
  7. Observe the startup log:
    load_model: initializing, n_slots = 1, n_ctx_slot = 4096
    

Expected behavior

The model should use the value specified in its YAML configuration.

For example:

parameters:
  context_size: 8192

should result in:

n_ctx_slot = 8192

and corresponding VRAM usage.

Actual behavior

The model always uses the global Default Context Size.

Changing parameters.context_size in the model YAML has no observable effect.

Both:

  • n_ctx_slot
  • VRAM usage

follow the global setting instead.

Additional context

I tested the following combinations:

Global Default Context Size Model context_size Observed n_ctx_slot
32768 65535 32768
32768 8192 32768
4096 65535 4096

VRAM usage also changed according to the global value, not the model-specific value.

This suggests that the global Default Context Size is overriding or replacing the model-level parameters.context_size.

Nathilion avatar Oct 06 '26 19:10 Nathilion

localai-org-maint-bot is correct. The generated YAML puts context_size under parameters. However, if I move it to a top-level position then given context size will override the global default.

I would then like to request to have a look at the code that generates the YAML file so that context_size is removed from the parameter block and put at the top-level instead.

Nathilion avatar Oct 06 '26 20:10 Nathilion