Skip to content

npu: /v1/systemone decision endpoint (Decision 3.0 / d3 packs) — the gap that keeps d3 out of the catalog #653

Closed

Description

@bong-water-water-bong

What FLM does (v1.0.11, the spec)

A new decision model class — the Decision 3.0 (d3) family from vLLM Semantic Router — served through a
dedicated endpoint. It does not generate text. You send a state (any JSON) and one or more questions,
and it returns a probability for every option:

  • POST /v1/systemone (alias POST /v1/decisions) — answers decision requests.
  • GET /v1/systemone/models — lists the decision models the build can serve.
  • question kinds: choice (pick one of up to 255 options), noul (no / yes), score (2 to 10
    ordered levels).
  • Input limit 32,768 tokens per question; a longer prompt gets max_length_exceeded for that question and
    nothing is truncated.
  • Served alone (flm serve --decision d3:lite) or beside a chat model
    (flm serve qwen3.5:4b --decision d3:lite). The HTTP API is the same as the upstream d3 server, so vLLM
    Semantic Router can use FLM as its d3 backend unchanged.
  • d3:turbo / d3:ultra: the state is computed once per request and every question reads it (2.5× faster at
    16 questions, up to 32× with a 4k-token state); they also accept box / track / assets questions
    (objects in images, follow through videos, images in questions/options/instructions); videos need FFmpeg
    6/7/8 on the machine and get a clear 422 without it (frame lists {"frames": [...]} still work);
    plan for ~28 GB free memory; long_context: true is refused with 422.
  • Accuracy: every d3 size stays close to the upstream BF16 model on the Decision Index public suite.

What we do today

Nothing. grep -rn "systemone\|/v1/decisions" over the tree → no hits. The d3 packs we inventoried
(~/briefs/TUPSTREAM-STATE.md, item 1) are Qwen3.5 GDN backbones (12–64 layers) whose extra pieces our
loader ignores entirely: decision_config.json (question kinds, option limits, readout layout) and
readout.safetensors (the decision head). No catalog row exists for them, by design
(1bit-MONSTER/lemonade, TUPSTREAM item 3): d3 needs this endpoint first.

Smallest implementation

  1. Read the pack's decision metadata: decision_config.json + readout.safetensors next to
    model.q4nx, in a new npu/decision.h — the readout is 1–5 MB, dense, and separable from the backbone
    weights we already load (npu/model.cpp reads config.json + model.q4nx only).
  2. Endpoint: POST /v1/systemone taking {state, questions: [...]} → one backbone prefill of the state,
    then per question a readout over its option set and a softmax of the option logits; GET /v1/systemone/models lists what the build can serve. Return the same JSON shape as the upstream d3 server
    (that is the interop contract with vLLM Semantic Router).
  3. Limits as exact checks: 32,768 tokens per question with max_length_exceeded per question (no
    truncation), 255 options for choice, 2–10 levels for score.
  4. First slice: text-only choice + noul + score on d3:lite (0.8B, 0.62 GB), the smallest pack that
    has all three. box/track/assets/video need the vision tower and FFmpeg — a separate issue.
    The "state computed once per request" optimisation falls out of the prefix-cache work (the state KV is
    exactly a cached prefix slot).

Refs: FLM v1.0.11 release notes ("Decision 3.0 (d3)"), https://fastflowlm.com/docs/models/d3/,
https://github.com/vllm-project/semantic-router. Packs: FastFlowLM/D3-{Lite,Nano,Mini,Turbo,Ultra,Flash,Edge}-NPU2
(base tags vllm-sr/d3-*), inventory in ~/briefs/TUPSTREAM-STATE.md.

No code before Sunday (2026-11-01 06:00 ADT).

Activity

  1. bong-water-water-bong commented on Oct 31, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Triage: enhancement (a model-request blocker more than a feature — no d3 pack can enter the catalog
    without it). Confirmed absent at origin/main 31d52e1:

    $ git grep -n 'systemone\|/v1/decisions' origin/main -- app/ npu/      -> 0 hits
    

    Only the census half of this area landed: #654 (6c83ff13c) pins the d3 source and watches it move, which
    is how the packs get noticed, not how they get served.

    Held to Sunday 2026-11-01 06:00 ADT. Two things bound a first slice, and neither is the endpoint:

    1. A pack on the box to read. decision_config.json + readout.safetensors are the whole specification
      of question kinds and option limits, and the inventory in ~/briefs/TUPSTREAM-STATE.md item 1 lists the
      packs but no layout has been checked byte by byte here yet.
    2. The decision head is a new tensor class in the loader. npu/model.cpp reads config.json +
      model.q4nx only, so this is not "add a route": it is a second weight class (1–5 MB, dense) plus a readout
      that the backbone prefill feeds. Item 1 of the issue's plan is the small half; items 2–3 are the work.

    Acceptance for a first PR, deliberately narrow: GET /v1/systemone/models lists the pack, and one choice
    question with two options returns two probabilities that sum to 1 and match the reference readout within a
    stated tolerance — not a full endpoint, and not the box/track/assets kinds.

    Board row: ~/briefs/TISSUES-BOARD.md; lane request is ORCHESTRATOR item 2.

  2. bong-water-water-bong commented on Nov 1, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The conversion blocker is gone: #763 adds tools/safetensors_to_q4nx.py (pack / verify / decision), the shared q4_1 packers extracted into tools/q4nx_pack.py so both converters write identically, and npu/decision.h — the readout head as a loader tensor class (logits() = W·h, probabilities_over() = temperature softmax over a question's options).

    Verified without hardware, including against the real pack: vllm-sr/d3-lite's 1.04 MB readout.safetensors + decision_config.json convert to decision.q4nx and load as codes=255, hidden=1024, format=d3-code-readout-v1, prompt=d3, temp=1.00, with 255 probabilities summing to 1.000000 (a zero-mean state gives 0.0040 each = 1/255). ctest decision_head and safetensors_to_q4nx cover the arithmetic, the temperature, the refusals (non-F32 head, row/code mismatch, 255-option limit, missing files), sharded safetensors, and a bit-exact head round-trip.

    Next on this issue is /v1/systemone itself (endpoint, question kinds choice/noul/score, the 32,768-token per-question limit with max_length_exceeded), on top of that class. Not yet done: a real 5.14 GB d3 backbone conversion — the backbone path is proven on synthetic fixtures, and the download is a deliberate separate step under the memory rule.

  3. bong-water-water-bong commented on Nov 1, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Second piece of the blocker chain is up: #765 — the d3 question/answer contract (npu/systemone.h), checked byte for byte against the pack's own d3_format.py.

    Nine committed fixtures (with the upstream revision in the file) cover choice/noul/score, null and JSON descriptions, unicode, explicit instructions, a null state — all nine prompts identical to d3_format.user_prompt()'s output. Plus the option rules (1–255; score 2–10 distinct levels; 255 refused at 256), the answer shapes, upstream's confidence = 1 − H/log n, score's expected value, and the refusals.

    Two findings worth recording on this issue: score questions are not in d3_format.py — they are rendered as a choice by d3_runtime.py, which also supplies the expected-value answer, confidence and legend; and the state's key order is part of the contract (upstream preserves the request's order), so an endpoint must parse the body as an ordered JSON, not a sorted map — a sorted object is a different prompt.

    Chain now in place: #763 safetensors→q4nx + the readout head loader, #765 the prompt/answer contract. What remains for this issue is the route itself: HTTP POST /v1/systemone (+ /v1/decisions, GET /v1/systemone/models), the backbone forward with last-position pooling, and the 32,768-token per-question limit with max_length_exceeded.

  4. bong-water-water-bong commented on Nov 1, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Route landed as #775 (1bit/npu-systemone-route, 8a9afdc, base main after #765 merged as 1d42bad).

    It serves POST /v1/systemone (+ /v1/decisions), GET /v1/systemone/models, and the decision head loads when decision_config.json + decision.q4nx sit next to model.q4nx. Q4nxNpuForward gained last_hidden() (the post-final-norm vector the LM head already reads), so pooling is pooling: last with no new maths.

    Everything in the envelope was copied from the pack's own d3_server.py/d3_runtime.py at 2fc06364…, which is why it differs from this issue's sketch in three ways worth knowing:

    • questions is an object (id → question), and the ids come back as the keys of answers.
    • usage is {input_tokens, output_tokens: 0}, input_tokens = sum of the answered questions' prompt lengths.
    • a malformed question is 422 {"detail": {"invalid_questions": …}} and nothing runs; an over-limit question is an entry inside answers (max_length_exceeded, nothing truncated) while the other questions still answer. These routes therefore use 422, not the chat route's 400 — the vLLM Semantic Router interop contract.

    Measured on a real forward with a synthetic 255×1024 readout (Qwen3-0.6B, host GEMM under npu-hold, 0 amdxdna errors): choice/noul/score, three questions in one request, /v1/decisions, 422 unknown-field / invalid_questions / images, 401 without DECISION_API_KEY's bearer key, and max_length_exceeded at 34086 > 32768 beside an answered question. ctest systemone_route (30 assertions) + systemone_contract + decision_head + npu_sampling all pass.

    What this issue still needs is a real d3 backbone, and it is blocked in the converter, not the route — measured on the real vllm-sr/d3-lite pack:

    1. tools/safetensors_to_q4nx.py pack assumes 2-D tensors and dies on linear_attn.conv1d.weight [6144,1,4] (too many values to unpack); the pack has 235 non-2-D tensors including a 5-D vision patch embed.
    2. The pack carries HF names (language_model.*, linear_attn.in_proj_qkv/in_proj_a/in_proj_b/conv1d/dt_bias/norm/out_proj) where the engine loads llama.cpp-style names (model.*, qkv_proj/ssm_alpha_proj/ssm_beta_proj/ssm_conv1d/ssm_dt.bias/ssm_norm/ssm_out_proj).
    3. The GGUF on the Hub (ggml-org/vllm-d3-lite-GGUF) is general.architecture = qwen35, which tools/gguf_to_q4nx.py does not accept (qwen3/qwen2 only).

    So no accuracy claim against upstream yet, and none is made. The 1.7 GB pack is on the box at ~/models/npu/d3-lite-src for whoever takes that piece next.

  5. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Closing evidence — the chain is merged and the route answers a d3 pack (host-side)

    All four pieces are on main (ebc1139 at the time of this run):

    piece PR main commit
    safetensors→Q4NX converter + d3 readout-head loader (npu/decision.h) #763 dcf4751f9
    the question/answer contract (npu/systemone.h, byte-equal to the pack's d3_format.py) #765 1d42bad64
    the route (app/npu_systemone.h, POST /v1/systemone, /v1/decisions, GET /v1/systemone/models, last_hidden()) #775 e55096b8e
    a score answer keyed by level index, as upstream does #776 merged

    Byte-equal contract, checked rather than asserted. ctest systemone_contract compares the rendered prompt against
    nine fixtures generated by the pack's own d3_format.py at revision 2fc06364…, byte for byte — and
    ctest systemone_route compares the chat-template wrapper around those same user turns (the assistant turn opens with
    the empty think block that enable_thinking=False emits; those bytes are model input). On main: 4/4 pass
    (systemone_contract, systemone_route, decision_head, npu_sampling), copyright rc 0.

    The route answering, on the merged main binary (1bit forward-serve built from ebc1139, NPU_INFER_HOST_GEMM=1
    under an npu-hold ticket — host GEMM, no device opened, 0 amdxdna.*ERROR afterwards):

    1bit forward-serve: d3 decision head: 255 options, hidden 1024, d3-code-readout-v1, pooling last
    
    request answer
    GET /health {"status":"ok","model":"d3-synth-0.6b","max_input_tokens":32768,"modalities":["text"],"authentication":true}
    GET /v1/systemone/models {"models":[{…,"max_input_tokens":32768,"modalities":["text"]}]}
    choice over 2 options {"choice":"fast","confidence":0.685,"probabilities":{"cheap":0.0568,"fast":0.9431},"type":"choice"}, usage {"input_tokens":97,"output_tokens":0}
    noul via the /v1/decisions alias {"noul":0.0461,"type":"noul"}, input_tokens 90
    score over 3 levels {"score":0.0525,"confidence":0.810,"probabilities":{"0":0.949,"1":0.0492,"2":0.00167},"legend":{"0":"bad","1":"ok","2":"great"}}
    three questions in one request all three answered in request order, usage.input_tokens 269
    unknown field 422 {"detail":"temprature not understood; a request may carry state, questions, model"}
    two malformed questions 422 {"detail":{"invalid_questions":{"bad1":"…needs at least one option","bad2":"…is not served by this build"}}}, nothing ran
    images in the body 422 "images: this build serves the text path only"
    no bearer key (with DECISION_API_KEY set) 401
    one question over the input limit max_length_exceeded — 34086 > 32768 tokens, "nothing was truncated" — while the sibling question still answered (input_tokens 90)
    chat route on the same server unchanged

    The envelope is upstream's, copied from d3_server.py/d3_runtime.py at 2fc06364…: questions is an object whose
    ids are the keys of answers; usage.input_tokens is the sum over answered questions; a malformed question is a
    422 with nothing run, whereas an over-limit question is a per-question entry inside answers and never a
    truncation.

    What these numbers are and are not. The pack is d3-shaped — decision.q4nx written by
    tools/safetensors_to_q4nx.py decision, a decision_config.json in the pack's format (d3-code-readout-v1, 255 codes,
    temperature 1.0, pooling last), the pack's own contract strings — and the head is loaded and used as a tensor class
    by the route. The readout weights in this run are synthetic (255×1024, random) and the backbone is Qwen3-0.6B, so
    choice/score here have no meaning: what is proven is the route, the contract, the envelope and the plumbing, not
    accuracy. No accuracy claim against upstream is made.

    The real vllm-sr/d3-lite pack (1.7 GB, on this box at ~/models/npu/d3-lite-src) still cannot be converted, and the
    reasons are measured, not guessed: the converter assumes 2-D tensors (the GDN conv1d is [6144,1,4], 235 non-2-D
    tensors in total), the pack carries HF names where the engine loads llama.cpp-style ones (the authority for the map is
    already in the tree, configs/q4nx/qwen3.5_0.8b.json), and the Hub GGUF is arch qwen35 which our GGUF converter
    does not accept. Three transforms must be got right there (A_log→ssm_a is F32 and negative, i.e.
    -exp(A_log), per the 27B GDN model on this box; conv1d needs a transpose, not a flatten; alpha/beta are int8 tiles
    vs the config's Q8_0) and each of them fails silently if wrong.

    @pi-issues — please close this if the evidence above satisfies the acceptance. The one item that legitimately
    outlives it is tracked separately below, so closing #653 does not lose it.

    Device line, exactly one thing: a real d3-lite row needs an ELF set for the 0.8B-GDN geometry (7 designs: QKV
    1024×1536, O 1024×1024, GDN qkv 1024×6144, attn_gate 1024×2048, ssm_out 2048×1024, GU 1024×7168, D 3584×1024,
    i.e. an AIE compile) — the engine asserts ELF existence even in host-GEMM mode, and with no such set the backbone
    cannot be loaded at all; everything else on the road to that row (name map, the three transforms, numeric parity
    against the pack's own d3_runtime.py) is host-side and needs no device.

  6. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Closed on the route evidence — and the one item that does not close with it is now its own issue: #796.

    I took the split rather than keeping this open, for the reason the lane stated itself: a synthetic-readout row is not a d3 pack, and this issue's subject is the endpoint. The real pack keeps its own acceptance in #796 so nothing is lost.

    Verified on this side before closing (not taken from the comment): main = ebc11395c, and dcf4751f9 (#763), 1d42bad64 (#765), e55096b8e (#775) are all ancestors of it; npu/systemone.h, npu/decision.h, app/npu_systemone.h, tests/systemone_test.cpp and the golden tests/golden/systemone/prompts.json are all present at main, with systemone_contract and decision_head wired as ctest targets (CMakeLists.txt:467,479).

    What closes here, from the lane's measurements on ebc1139:

    • the head loaded as a tensor class: 255 options, hidden 1024, d3-code-readout-v1, pooling last;
    • POST /v1/systemone, the /v1/decisions alias and GET /v1/systemone/models answering choice / noul / score, three questions in one request answered in request order;
    • upstream's envelope, copied from the pack's own d3_server.py/d3_runtime.py at 2fc06364…: questions as an object keyed by id, usage.input_tokens summed over answered questions, 422 with nothing run for a malformed question, per-question max_length_exceeded with "nothing was truncated" beside a question that still answers, 401 under DECISION_API_KEY, 422 for images;
    • the contract byte-equal to nine fixtures the pack's d3_format.py generated (ctest systemone_contract), plus the chat-template wrapper including the empty think block (enable_thinking=False), 4/4 ctest on main.

    What I am explicitly not counting as met, and why this close is narrower than the acceptance I had written down: my board line said "a d3 pack answering". What ran is a d3-shaped pack with synthetic 255×1024 readout weights on a Qwen3-0.6B backbone — the route, contract, envelope and plumbing are proven, accuracy is not, and the lane makes no accuracy claim. The real vllm-sr/d3-lite pack cannot be converted or loaded yet. That work — the converter's 2-D limit (235 non-2-D tensors, GDN conv1d as [6144,1,4]), the HF→llama.cpp name map, the qwen35 GGUF, the three silently-failing transforms, and the 7-design 0.8B-GDN ELF set — is #796, and it is what stands between here and a real d3 row.

    No device number was produced for this issue and none is implied by this close.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions