Repository navigation
server : add /v1/decision for parallel constrained decisions - #29752
Open
thecodacus wants to merge 1 commit into
Open
thecodacus wants to merge 1 commit into
thecodacus wants to merge 1 commit into
Conversation
Answer a finite JSON schema (enum, boolean, bounded integer, number on a grid) about 1-256 contexts in batched passes instead of generating tokens. The instructions and field catalogue are a cached prefix; each context forks one branch per field, and each field's values are scored as a token trie. Hybrid models get their branches right-padded so they batch in one ubatch. Enabled with --decision-seqs N, which reserves sequences above the slots and turns on the unified KV cache. Also adds the llama-parallel-decision tool. Heavily AI-assisted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Hi @thecodacus, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This lets any LLM served by llama.cpp act as a decision endpoint: every field of a JSON schema is answered by parallel queries in one execution pass, instead of generating the JSON token by token.
Adds
POST /v1/decisionto llama-server (enabled with--decision-seqs N) and allama-parallel-decisiontool. It answers a small finite JSON schema (enums, booleans, bounded integers, numbers on a grid) about one or more input texts without generating tokens.How it works:
llama_memory_seq_cp.mode,tree_max).--decision-seqs Nreserves N sequences above the normal slots (n_seq_max = n_parallel + n_seq_decision) and turns on the unified KV cache so branches share the prompt cells. With the flag unset (default 0) nothing changes for existing users.On hybrid models (Qwen3.5, Nemotron-H) the recurrent layers only batch sequences with the same token count, so each group of branches is right-padded to its longest one. The padding comes after the token that is read, so the logits are unchanged.
Additional information
Numbers on an RTX 3060 12GB:
Tested on current master on macOS/Metal with Qwen3.5-4B (hybrid) and MiniCPM5-2B: single and batched contexts, all field types, schema validation errors (HTTP 400), the endpoint returning 400 without
--decision-seqs, and/completionwith and without the flag.test-arg-parserpasses.llama-benchdoes not use the changed code path;llama-perplexitydoes, but with the flag unsetn_seq_maxis unchanged.A browser playground for trying it: https://github.com/thecodacus/decision-playground
I can split this (tool first, server endpoint later) or move it under examples if that fits the project better.
Requirements