Skip to content

Server: recurrent_loops per request for looped models - #62

Merged
rromenskyi merged 2 commits into
mainfrom
dory-request-loops
Nov 7, 2026
Merged

rromenskyi merged 2 commits into
mainfrom
dory-request-loops

Conversation

@rromenskyi

Copy link
Copy Markdown

A request body can carry recurrent_loops (1-4) for a looped model (Dory). No value keeps the default: the model's config, or --recurrent-loops.

  • The loop count is the last element of ModelProvider.model_key for looped models. Prompt cache entries, warm-next jobs and handoffs are all keyed on it, so a cache made with 2 loops is never reused for 3. Their layouts differ, and so does the output-layer KV.
  • ModelDescription.loops: a request with another count doesn't join the running batch. The batch drains, then load() calls model.set_recurrent_loops(n). Weights aren't reloaded.
  • dory.Model.set_recurrent_loops resets the cache plan.
  • Validation: an integer 1-4, else 400.

Tests (tests/test_looped_model_config.py):

  • the provider switches loops and back without reloading;
  • --recurrent-loops stays the default;
  • a switched model gives the same logits as one loaded with that count;
  • over HTTP, real ModelProvider, tiny Dory with a Qwen tokenizer: requests with 3, none and 1 loops, and bad values get 400.

test_server, test_warm_next_turn and test_server_handoff pass.

🤖 Generated with Claude Code

Roman Romenskyi and others added 2 commits November 7, 2026 15:30
The loop count is part of the model key: a request with another count
drains the batch and switches the loaded model without reloading weights
(set_recurrent_loops), and its prompt cache entries are kept apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…use)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rromenskyi
rromenskyi merged commit 8784cec into main Nov 7, 2026
2 checks passed
@rromenskyi
rromenskyi deleted the dory-request-loops branch November 7, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant