Skip to content

[Bug] Foundry Local v2.0.1 uses max_length config instead of model context_length #1067

Description

Describe the issue

The Foundry Local model gemma-4-e2b-it-generic-gpu:2 advertises a context length of 131,072 tokens, but Foundry Local SDK/runtime v2.0.1 rejects requests using more than 4,096 total tokens.

The downloaded model package contains conflicting values in genai_config.json:

  • model.context_length: 131072
  • search.max_length: 4096

At runtime, request validation uses the 4,096-token value. A text-only request with approximately 127,826 input tokens and 256 requested output tokens (128,082 total) is below the advertised 131,072-token context but is rejected as exceeding the model's maximum context length of 4,096 tokens.

Short text prompts and image inference work with the same model and WebGPU backend, so this appears to be a context-length/configuration mismatch rather than a general WebGPU execution failure.

This is similar to #969, but affects the Gemma 4 WebGPU model and limits it to 4,096 tokens.

To reproduce

  1. Install Foundry Local SDK/runtime v2.0.1.
  2. Resolve and download gemma-4-e2b-it-generic-gpu:2 using the C++ API.
  3. Load the model with the WebGPU provider.
  4. Submit a text-only request containing approximately 127,826 input tokens and request up to 256 output tokens.
  5. Observe that the request is rejected against a 4,096-token maximum.
  6. Inspect the downloaded genai_config.json and observe that model.context_length is 131,072 while search.max_length is 4,096.

Expected behavior

The runtime should support the advertised 131,072-token context window, with input and requested output counted together. If the model variant intentionally supports only 4,096 tokens, the catalog metadata and model.context_length should report that effective limit consistently.

Platform and architecture

macOS Apple Silicon

OS Version

macOS

Installation type

Released package/binary

Foundry Local version

Foundry Local SDK/runtime 2.0.1

API or surface area

C++ API

Hardware acceleration/backend

WebGPU

Model

gemma-4-e2b-it-generic-gpu:2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions