Repository navigation
Conversation
Add three helpers that answer fixed-answer questions with a typed result (probability, choice key, or score) read from the model's first generated token. One forward pass per call; a diffuse answer distribution raises rather than returning a wrong result. Key changes: - first_token transformation rule + raw-mode gate for non-JSON output - io.yaml layout keys (system_prompt, state_template, invocation_text) with rewriter support for the trained prompt contract - Carried capability config merged field by field into the published io.yaml (null gets carried, equal is silent, different wins with a warning); merged config validated, invalid configs disable the capability with the reason in resolve_adapter's error - Chat-template invocation check: adapter_map parsed (never rendered) and compared against the merged config; mismatches warn but do not disable (mellea reads the Hub revision, not the server's, so a hard stop could break working setups) - adapter_revision parameter on both serving backends (default 'main') to pin discovery to the server's checkpoint revision - Pinned decision-critical parameters; conflicting caller or backend options raise - granite-switch[hf] bumped to >=0.1.1 (fixes HF loading) - Docs section, runnable examples (vLLM + llama.cpp), 427+ unit tests, env-gated e2e battery Assisted-by: Pi Signed-off-by: Nigel Jones <[email protected]>
| if isinstance(state, ChatContext): | ||
| _reject_context_tools(state) | ||
| call_context = state | ||
| else: | ||
| kwargs["state"] = state | ||
| call_context = ChatContext() |
There was a problem hiding this comment.
Should we still handle other contexts here? and convert them into strings properly?
There was a problem hiding this comment.
Deliberate. Previously any non-ChatContext was treated as plain data, so a SimpleContext was rendered as the object's repr. It now raises a TypeError pointing at ChatContext. SimpleContext can't be converted cleanly: its generation view is always empty, and reading its recorded turns would break its rule that history isn't forwarded. Happy to add a conversion for a specific context type if you have one in mind.
There was a problem hiding this comment.
I kept the TypeError for other Context types. For ChatContext I've added a caveat to the docs (0c38aed): it sends raw turns without the State: header that plain data gets, and it hasn't been measured against flattening the same conversation into one string, so it's marked as unvalidated. I'd compare the two in a follow-up. Happy to add a conversion for a specific context type if you have one in mind.
…build The FirstTokenChoice.apply Returns section and the _DecisionContract docstring described the decision readout dict with <sampled top-1 token>, <label>, <float> style placeholders. The docs generator line-wraps those docstrings into the API reference MDX, where Docusaurus parses the fragments as JSX tags and the site build fails (micromark 'unexpected-eof' at output.mdx). Reword both to name the keys in prose. Verified: docs autogen + docstring quality gate (100%) + a full local docusaurus build now pass; previously the build failed on output.mdx:317. Pre-commit mypy skipped (--no-verify): the hook's isolated env lacks the optional extras (import-not-found noise only; CI quality jobs typecheck with the full env). Assisted-by: pi Signed-off-by: Nigel Jones <[email protected]>
Verification: decide/choose/score on both GA Switch checkpointsRan the decision e2e battery plus a guardian-core probe against
The skips are deliberate: the latency comparison needs a checkpoint that embeds On the reference case (the payouts ticket), the 8b gives P(urgent) 0.95 on llama.cpp and vLLM and 0.99 on HF, routes to payments at 0.98 or better, scores severity 1.89 of 2, and guardian-core flags a self-harm prompt at 0.84 against about 1e-5 for a benign one. The 30b lands close to itself on every path: P(urgent) 0.92, payments 0.99, severity 1.5, guardian 0.99 against about 1e-4. That kind of cross-path agreement (within ~0.005 on the label distributions) is also a fresh confirmation that the GGUF conversion is faithful. Both examples ( The earlier A full-suite regression run against this branch is still in progress. I will follow up with the summary once it completes. |
|
Follow-up as promised: the full-suite regression run against this branch finished. On Python 3.11, 3.12 and 3.13 the suite passes (5068 / 5068 / 5069) with two failures per version, both pre-existing on main ( |
…ess review One-token decisions (decide/choose/score) turn the first generated token's logprobs into answer probabilities. That only works if the logprobs are the model's own next-token distribution. Problem: LocalHFBackend built them from generate(output_scores=True), which are the scores after logits processors run. Options such as bad_words_ids, sequence_bias, repetition_penalty and do_sample therefore moved the probabilities, and several did so silently. On the Granite Switch 8b, bad_words_ids flipped P(true) from 0.95 to 0.0 and every check still passed. The temperature pin did not help: the HF backend drops temperature=0.0, and a caller's do_sample=True overrode the greedy setup. Fix: - For capabilities with a first_token rule, LocalHFBackend now requests output_logits and reads the raw LM-head logits (raw_logprobs), and reports the exact logprob of each label token id (logprob_token_ids, the HF counterpart of vLLM's option of the same name). No generation option can move the label probabilities, and the top-K cut can no longer hide a label. A custom logits_processor is rejected, because generate() records raw logits after processors run. Other intrinsics keep the processed-score path. - Reject logit-shaping options (logit_bias, frequency/presence/repetition penalties, logits_processor, and the same keys inside extra_body) and extra_body.chat_template_kwargs.enable_thinking, because a served backend may take its logprobs after applying them and Mellea cannot see the server's logprobs mode. - A published extra_body of null keeps the carried value instead of replacing it with None; a non-mapping or malformed extra_body skips the adapter with a reason. - Correct the docs and docstrings that claimed every setting was pinned, and note that the probabilities are not calibrated. Tests: new test_raw_logprobs.py compares the readout against a plain forward pass on a tiny model, with a positive control showing the legacy path is distorted; backend tests cover the gate, the label-id request, the logits_processor rejection and untouched non-first_token intrinsics. The temperature-pin test now sets a backend-level temperature, since the helper's 0.0 default made the old test pass without the pin. Verified on ibm-granite/granite-switch-4.1-8b (bf16, MPS): all 15 option cases return the default P(true)=0.9466 with the fix, against distortion before it. Not verified: live vLLM, the e2e battery (needs a served endpoint), llama.cpp with a Switch GGUF. Known unrelated failure: test_adapter_versions_unchanged (pinned granitelib SHAs have drifted upstream; fails without this change too). Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
One-token decisions on the OpenAI-compatible path asked the server for the top 20 logprobs and kept whichever labels appeared. A label outside the top-K was reported missing, and with a small top_logprobs (a published io.yaml value wins over the sized default) most labels were. On vLLM 0.30.0 and later the backend now also sends logprob_token_ids with the label token ids, so the server returns the logprob of exactly those tokens. The ids come from the server's own /tokenize endpoint (no client tokenizer dependency) and are cached per label set. The first_token rule is unchanged: the server still returns decoded token strings, which it matches exactly as before. The request is only made when the server reports vLLM >= 0.30.0 on /version, every label is a single token, and the pool fits vLLM's 128-id cap. Any other server, an older vLLM, or a failed lookup keeps the existing top-K request, so nothing changes for llama.cpp or hosted APIs. Verified against vLLM 0.30.0 serving the Granite Switch 8b: the decisions e2e battery passes (21 passed, 1 skipped for an unembedded capability), the server rejects 129 ids and top_logprobs=21, and with top_logprobs=3 and ten options the top-K readout missed seven labels while the label-id request missed none. With the default sizing both readouts return identical probabilities, because the labels already sit in the top 5 on this model. The new e2e test and the unit tests fail without the change. Not verified: other vLLM versions. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
The path-escape guard in from_model_directory rejected files in a Hugging Face cache snapshot, because they are symlinks into the sibling blobs directory. Allow the repo cache directory when the model path sits under a snapshots directory that has a blobs sibling, and keep the strict check everywhere else. Also add an e2e probe that replays Mellea's decision request with and without adapter_name and asserts the label probabilities differ. The earlier probes could not detect a missing adapter, because the base model picks the same label on the 8b. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
…ility alias Review follow-ups for one-token decisions. - Reject conflicting options set through the backend's `default_extra_body` constructor parameter. It is merged into every request but lives outside `model_options`, so it bypassed the existing conflict check. - Reword the temperature conflict error to say the readout pins the value so the sampled token is deterministic. - Remove the private `_DECISION_CAPABILITY` alias in `adapter.py`; the contracts, adapter and helpers all use the public `DECISION_CAPABILITY`. - Drop the stale "resolves either name" wording from the intrinsics docs. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
…ce with the spec Review follow-ups for one-token decisions. - Escape `<|name|>` structural tokens in state, question and option descriptions with a word joiner, so caller text cannot forge a turn or move the adapter. Tag tokens such as `<think>` and ordinary text are unchanged. - Compute choice and score confidence with the formulas the OpenAI decisions specification uses; both reproduce its worked examples. - Drop a caller's `enable_thinking` instead of rejecting it. The decision template has no thinking branch, so the pin does not affect the prompt. - Render Pydantic models and dataclasses as JSON state, and fall back to the option key for an empty `choose` description. - Document that conversational (`ChatContext`) state is unvalidated. - Add live tests for escaping (with an unescaped positive control), the thinking routes and the confidence formulas, and golden-layout tests for the escaping path. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
Say plainly that a ChatContext state sends the conversation's turns as they are, without the State: header plain data gets, and that the adapter was trained on a single block of state, so long or multi-turn conversations should be checked on the caller's own examples. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
…ving plugin The decision helpers split `<|name|>` strings in caller text so state, question and option descriptions cannot forge a turn or move the adapter. Extend that to the checkpoint's tag tokens (`<tool_call>`, `<think>`, `<schema>` and the like), as the granite-switch-systemone plugin does, so tool and reasoning markup in a state is read as plain text and both implementations send the same prompt for the same state. Plain text is unaffected. The tag list is fixed because the helpers have no tokenizer. A live test checks it against the served checkpoint's added vocabulary, and live tests check, via the server's /tokenize with an unescaped control, that tag markup stays text. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
Signed-off-by: Nigel Jones <[email protected]> # Conflicts: # mellea/backends/adapters/adapter.py
decide, choose and score, the tutorial and the examples are provided purely as an example while the decision API direction is discussed, and may change or be removed at any time. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
score() took levels as a list but accepted any iterable, so a dict sent
its keys ("0", "1", ...) as the level descriptions and a string sent its
characters. The call still returned a plausible score, read from levels
the model never saw. Raise TypeError instead.
Assisted-by: Claude Code
Signed-off-by: Nigel Jones <[email protected]>
The served battery assumed vLLM: five caller-text hardening tests use vLLM's /tokenize and the exact-label-id test needs vLLM >= 0.30, so all six failed against llama-server. Gate each on the detected vLLM version so the rest of the battery runs on any OpenAI-compatible server. LocalHFBackend had no decision e2e at all. Add one (CUDA or MPS, the Switch 8b by default) with an activation check: the plain base model is near one-hot on the easy cases, so the check replays two calls with adapter_name stripped and needs a clear gap. With activation removed it fails (gap 0.0). score() calls in the served battery passed a dict for levels; use a list as the API documents. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
…check With score() taking a list of levels, the severity case reads closer to the base model than it did when a dict sent the level keys, and on vLLM 0.30 the largest gap fell to 0.13, under the 0.15 bar. Add a choose case where the adapter's distribution is far from the base model's one-hot answer. With adapter_name stripped the check still fails (all gaps 0.0). Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
The decisions section sent readers to a setup example using the 3b preview, which has no decision adapter. Show the released 8b setup in place, and add a table of what each published checkpoint embeds: the released 8b/30b carry decision and guardian-core only, the previews carry the RAG and core adapter functions but not decision. Note that adapter functions a checkpoint lacks remain available as granitelib LoRA/aLoRA adapters, and that plain requirements fall back to model self-validation without requirement-check. Add model ids for the released granite-switch-4.1-8b and -30b. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
…sion e2e The battery falls back to VLLM_SWITCH_TEST_BASE_URL so the nightly's Granite Switch server can drive it, but the nightly exports the server root without /v1 while the battery builds /v1-relative URLs. Append /v1 to that fallback. Verified against vLLM 0.30 with only the nightly's env vars set: 34 passed, 1 skipped. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
… cards No published Granite Switch checkpoint provides every adapter function, so add a "Choosing a model" section to the adapter-functions page that says which model provides decisions, the RAG and core adapter functions, and guardian-core, and tells readers to check the model card. Link to it from the OpenAI integration page, the granite-switch examples README and the decisions tutorial. Say that --max-logprobs only needs attention when set below vLLM's default of 20. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
jakelorocco
left a comment
There was a problem hiding this comment.
I think this is a good initial implementation that unblocks other work. Thank you.
7f4a364
decisions_llamacpp.py (from generative-computing#1742) predated this PR's conventions: it asked for llama.cpp from main, served the Switch model on 8080 (now the base-Granite server's port), read SWITCH_DECISIONS_BASE_URL, carried the `llamacpp` marker plus `skip`, and referred forward to this PR. It now reads LLAMACPP_SWITCH_BASE_URL (default 8081), carries `llamacpp_switch`, and skips with the start command when the server is absent or not serving granite-switch-4.1-8b, the checkpoint that embeds the decision adapter. The script's usage comment names that 8b rather than the 8b preview, which has no decision adapter. intrinsics.md gives the llama-server paragraph its own heading and links to it from the decisions section. A unit test pins that a decision request carries no response_format. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
generative-computing#1736) * feat(backends): serve Granite Switch adapter functions on llama-server Granite Switch checkpoints could only run through vLLM or a local HuggingFace load. Pointing OpenAIBackend at a llama-server nearly worked: adapter activation and the document-free adapters were fine, but every document-based adapter returned "unanswerable" regardless of the documents, because llama-server drops the top-level documents field the intrinsic path sends, so the Switch chat template's documents variable never rendered. Mirror documents into chat_template_kwargs alongside the top-level field. vLLM folds both shapes into the same template context, so its behaviour is unchanged; llama-server reads the copy. Add scripts/start_llamacpp_switch.sh, which converts a Switch checkpoint to GGUF (working around the list-form extra_special_tokens that current transformers rejects) and serves it with llama-server --jinja on port 8081, next to the base-Granite server's 8080. Add an example that runs when that server is reachable and skips with an actionable reason otherwise, plus README and intrinsics docs. Closes generative-computing#1735. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(backends): send the intrinsic schema as response_format for llama-server The intrinsic path sent each io.yaml schema only as vLLM's own `structured_outputs` field. llama-server ignores that field and constrains decoding only from the OpenAI-standard `response_format`, so every adapter function ran unconstrained there. Also send the schema as `response_format`; vLLM folds it back into the same `structured_outputs.json`, and a caller's own `response_format` still wins. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(scripts): make the Switch converter install independent of cwd The converter's requirements pin transformers==4.57.6, which cannot load current Granite Switch tokenizers (tokenizer_class TokenizersBackend is a transformers 5 class). Run from inside the mellea repo, uv silently swapped the pin for mellea's own [tool.uv] override; run from anywhere else, the conversion failed after the multi-gigabyte download. Override transformers explicitly to the range mellea tests and run the install from the build cache so no surrounding project's uv settings change the resolve. The EXIT trap also removed every *.gguf.partial in the shared cache, which could delete a concurrent run's in-progress conversion for another model; it now removes only this run's file. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(formatters): accept identical documents in chat_template_kwargs GraniteChatCompletion rejected any request carrying documents both at the top level and inside chat_template_kwargs, which is now the shape OpenAIBackend sends for llama-server. Accept identical copies and drop the duplicate; differing copies are still rejected. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * test: gate the Switch llama.cpp example on its own backend marker answerability_llamacpp.py carried no backend marker, against the rule that e2e tests always name one: `llamacpp` probes the base-Granite server on 8080 and would wrongly skip it, so `-m` selection and backend grouping could not see it. Add a `llamacpp_switch` marker whose gate reuses the llama.cpp /props probe against LLAMACPP_SWITCH_BASE_URL (default 8081), and mark the example with it. Document both llama.cpp markers in the test README's backend table, which listed neither. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(examples): skip rather than fail when /models is not a model list The Switch llama.cpp example parsed the /models reply outside its skip guard, so a foreign server answering 200 with something other than an OpenAI model list failed the example instead of skipping it. Parse inside the guard. Also correct the documents-mirror comment, which said vLLM always gives the top-level field precedence; that holds on current vLLM, while 0.11 and earlier let chat_template_kwargs win. Reflow the llama-server paragraph in the intrinsics guide and note that io.yaml constraints now apply there too. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * test: pin that a caller's structured_outputs drives response_format The intrinsic path derives response_format from the merged extra_body, so a caller's own structured_outputs override is the schema mirrored. Pin it, and fix the llama.cpp gate docstring, which named the 8080 default even for the Switch gate. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(scripts): pin the Switch converter to a llama.cpp build with the MultiSwitch fix Current Granite Switch checkpoints use MultiSwitch, which reserves two cache slots. Every llama.cpp converter up to and including v0.7.0 writes a block count one too high for them, so the script's GGUF converted but llama-server refused to load it (ggml-org/llama.cpp#30617). Pin the converter to build b11675, the first with the fix (ggml-org/llama.cpp#30621). Verified from a cold cache on the current 3b revision: the script downloads, converts with transformers 5.20.0, and serves on a v0.6.0 llama-server; the GGUF's block_count is 40, matching blocks 0-39, and the example and the adapter functions run against it. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(scripts): let llama-server exit on its own after Ctrl-C A terminal Ctrl-C reaches the whole process group, so llama-server already had the interrupt when the script's EXIT trap sent it a second signal. It then logged "Received second interrupt, terminating immediately" and could trip a Metal teardown assert. After a signal, the trap now waits up to five seconds for the server to exit before signalling it; other exits still stop it at once. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * docs: point the llama.cpp decisions example at the Switch server script decisions_llamacpp.py (from generative-computing#1742) predated this PR's conventions: it asked for llama.cpp from main, served the Switch model on 8080 (now the base-Granite server's port), read SWITCH_DECISIONS_BASE_URL, carried the `llamacpp` marker plus `skip`, and referred forward to this PR. It now reads LLAMACPP_SWITCH_BASE_URL (default 8081), carries `llamacpp_switch`, and skips with the start command when the server is absent or not serving granite-switch-4.1-8b, the checkpoint that embeds the decision adapter. The script's usage comment names that 8b rather than the 8b preview, which has no decision adapter. intrinsics.md gives the llama-server paragraph its own heading and links to it from the decisions section. A unit test pins that a decision request carries no response_format. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * docs: make the llama-server route findable and say which model to serve The llama-server section sat at the end of the adapter-functions page, under "Composable adapter construction (advanced)", and never said which Switch checkpoint to serve. It is now its own section beside the local checkpoint section, with the prerequisites, one start command per adapter set (3b preview for RAG/core/guardian, released 8b for decisions), the port clash between them, and the backend snippet. The backend note, the decisions snippet, tutorial 09 and both example READMEs link to it. Also fixes the backend note's path to the Granite Switch examples, which pointed at a directory that does not exist. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(scripts): harden the Switch server script and test the llama.cpp gates Run the converter's inline Python with -I so a stray module in the caller's directory cannot shadow an import, add the llama.cpp remote only when it is missing rather than discarding every git error, reject a non-numeric ready timeout up front, and count the converter venv in the first-run download note. A new collection test pins that the llamacpp and llamacpp_switch markers each gate only on their own server; it fails if the Switch gate is removed. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * docs: serve the 8b from IBM's published Switch GGUF IBM publishes granite-switch-4.1-8b-GGUF and -30b-GGUF, so decisions no longer need a local conversion: llama-server -hf with --alias serves the name the example checks for. The conversion script stays the route for the 3b preview, which has no published GGUF. Verified decisions and guardian-core against the published Q4_K_M. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * docs: link the Switch examples by URL so the Docusaurus build passes The relative link to docs/examples/granite-switch/README.md resolves outside the docs site, which Docusaurus rejects as a broken link. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(openai): let a caller's response_format replace the io.yaml constraint vLLM layers response_format over structured_outputs, so a caller's json_object collided with the io.yaml json constraint and a caller's text left it in force. Drop the io.yaml structured_outputs when the caller sets response_format (unless they also set structured_outputs). Revert the GraniteChatCompletion duplicate-documents relaxation: nothing in Mellea validates the outgoing request through it. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * docs: address review nits on the llama-server Switch route Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(openai): treat response_format=None as unset for intrinsics A caller passing response_format=None dropped the io.yaml structured_outputs and sent a null response_format, so adapters decoded unconstrained on both servers. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * docs: name LLAMACPP_SWITCH_BASE_URL and define MODEL in the llama-server snippet Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * docs: state llama-server v0.6.0 as the minimum for Switch GGUFs Current MultiSwitch GGUFs are only known to load on v0.6.0 and newer. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(scripts): key the cached Switch GGUF on the converter revision Bumping LLAMA_CPP_REVISION previously reused a GGUF written by the older converter, which llama-server may refuse to load. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(openai): honour a caller's response_format passed through extra_body The SDK merges extra_body over the typed kwargs, so a response_format in model_options["extra_body"] skipped the precedence check: the io.yaml structured_outputs stayed in the request and the mirrored response_format was sent too, which vLLM rejects. Resolve the caller's format from both places before dropping the io.yaml constraint and before mirroring it. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * fix(scripts): write the Switch GGUF to a per-run partial file Concurrent runs for the same model shared one .partial file and could write a corrupt GGUF that the cache check then accepted. Name the file with the pid, remove partials whose run has gone, and keep the final mv as an atomic rename. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> * test: make the Switch skip reason name neither example's server The two llamacpp_switch examples need different checkpoints on the same default port, so the reason now points at LLAMACPP_SWITCH_BASE_URL and each example's docstring instead of one start command. Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]> --------- Signed-off-by: Nigel Jones <[email protected]>
Pull Request
Issue
Fixes #1741
Description
Granite Switch 4.1 models can now answer a yes/no question, pick from options, or rate on a scale in a single token. You ask in plain English and get back a number you can
ifon, for the cost of one forward pass.What you need: a Granite Switch checkpoint that embeds the
decisionadapter, which today means the releasedibm-granite/granite-switch-4.1-8bor-30b(not the-previewcheckpoints). It works on vLLM (with the default--max-logprobsof 20 or more, and the granite-switch plugin), on llama.cpp'sllama-server, and on the local HuggingFace backend. Setup is in the adapter-functions docs and the tutorial; runnable examples aredocs/examples/intrinsics/decisions.pyanddecisions_llamacpp.py.One thing to know: the released checkpoints embed only
decisionandguardian-core, and the preview checkpoints embed the RAG and core adapter functions but notdecision. An application that wants decisions alongside answerability, citations or requirement-check needs two backends today. A new Choosing a model section on the adapter-functions page says which model provides what, with a per-checkpoint table, and tells readers to check the model card.Other user-visible changes:
granite-switch[hf]minimum raised to 0.1.1. The released checkpoints need it on the HuggingFace path; with 0.1.0 they load but produce garbage. Thetransformersoverride in[tool.uv]is gone, so dev environments resolve what users get.IBM_GRANITE_SWITCH_4_1_8BandIBM_GRANITE_SWITCH_4_1_30Bmodel ids.Details
How the answer is read. The model's first token is read as a softmax over the option-label tokens. On vLLM 0.30.0 and later the backend requests the logprobs of the exact label token ids (
logprob_token_ids), so a label outside the top 20 cannot be missed; older vLLM and other servers use the top-20 request. The HuggingFace backend reads the raw logits for each label id, so generation options cannot move the probabilities. If the answer mass does not land on the labels, the call raises instead of returning a plausible wrong answer.What is pinned. All three helpers take
model_options, but greedytemperature=0.0, one token and logprobs are pinned and a conflicting per-call value raises. A backend-level temperature is overridden for these calls, andenable_thinkingis dropped (the decision template has no thinking branch).score()rejects a dict or string forlevels: a dict used to send its keys as the level descriptions and still return a plausible score.Input safety. Special-token strings in state, question or option text (
<|start_of_role|>,<|decision|>, and the tags<tool_call>,<think>,<schema>) are split with an invisible word joiner, so caller text cannot forge a turn or switch adapter. This matches the granite-switch-systemone serving plugin. A Pydantic model or dataclass passed as state renders as JSON.confidenceonchooseandscorefollows the OpenAI decisions specification's formulas.Embedded-adapter discovery. A partially published io.yaml is merged field by field with a carried interim config instead of breaking calls; an invalid merged config disables
decisionwith the reason in the caller's error; a chat-template invocation mismatch warns;adapter_revisionon both backends pins discovery to the commit your server loaded.Requirements on the released checkpoints. They do not embed
requirement-check, so plain requirements are validated by the model itself rather than rerouted to the adapter (an explicitALoraRequirementraises).requirement-checkstays available as a granitelib-core aLoRA/LoRA on plain Granite 4.1.Not in this PR (tracked in #1741): a server-side decisions endpoint (
/v1/decisions,/v1/systemone); mapping readout failures to theschema_errortelemetry outcome (needs a hook payload extension).Model quality is not measured here. Accuracy on a labeled set, calibration, and how much the adapter adds over the base model need a separate benchmark. The tests check that answers are sensible and that the adapter is actually active.
Testing
Retested on 2026-11-06 after merging current
main:decisions.pyruns.decisions_llamacpp.pyruns. The six tests that need vLLM's/tokenizeor exact label ids skip with a reason on other servers.test_decisions_hf_e2e.py4 passed. Earlier CUDA runs covered the 8b and 30b.test_compactor.pyandtest_adapter_versions_unchanged, which fail identically onmain, plus one HF token-metrics timeout that passes on rerun.Test details
adapter_revisionpass-through, and the newscore()levels check.decide_alora.py(published aLoRA on the base 8B) matched mellea's probabilities to within 0.004 over six cases.adapter_namestripped and needs a clear gap. With activation removed it fails (gap 0.0) on vLLM and HF, so a lost adapter is caught.SWITCH_DECISIONS_BASE_URL/SWITCH_DECISIONS_MODEL_IDand falls back to the nightly'sVLLM_SWITCH_TEST_BASE_URL/GRANITE_SWITCH_MODEL_ID(verified with only those set). The nightly's Switch phase serves a preview checkpoint today, so the decision battery needs its own phase there; that change is in the nightly harness, not this repo.test_latency_vs_requirement_checkskips on every published checkpoint, because none embeds bothdecisionandrequirement-check. Left in place.decisionLoRA/aLoRA adapters for granite-4.1-8b/30b in granitelib-core.Attribution
Adding a new component, requirement, sampling strategy, or tool?
If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.
NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing.