Skip to content

train 1114152941: #2074 #3125 #3273 (CI only) - #3361

Closed
ashhart wants to merge 18 commits into
mainfrom
lead/train-1114152941
Closed

ashhart wants to merge 18 commits into
mainfrom
lead/train-1114152941

Conversation

@ashhart

@ashhart ashhart commented Nov 14, 2026

Copy link
Copy Markdown
Owner

CI for a landing train: #2074 #3125 #3273 stacked on main in that order. Nothing merges from this PR: each PR above lands on its own once this tip is green, and this PR is then closed.

ashhart and others added 18 commits November 14, 2026 15:09
… tool tests, so pytest from the root imports them
…a private journal, checked graph states

The four fixes the review on this PR asked for, each with a test that fails before it:

- transport: a loopback client builds its opener with an empty ProxyHandler, so an ambient
  http_proxy never receives a request or its Authorization header; --allow-remote keeps the
  environment's proxies.
- transport: SSE lines are read with readline(1 MiB + 1), so an oversized line is refused
  without reading it whole, and one stream keeps at most 4 MiB of event data and 4096 events.
- ledger: missing journal directories are created 0700 and the database 0600 (SQLite gives its
  WAL and SHM the same mode); an existing database, WAL or SHM open to other users is refused
  by name. An existing parent directory keeps its mode.
- transport and controller: every graph read checks each fact's state against the native
  graph's states (queued, learning, learned, missed, replaced, deleting, deleted); a missing,
  non-string or unknown state stops the controller before any lesson.
…are the ones checked when SQLite opens them

The re-check of the journal fix found a gap: a file could appear between the mode checks and
SQLite opening it, and the journal accepted a 0666 database, WAL and SHM planted there.

- The journal's own directory must be a real directory owned by this user with mode 0700, or the
  ledger is refused by name; missing directories are created 0700. Only this user can then add
  or replace files in it.
- The database is created O_EXCL|O_NOFOLLOW at 0600; on a collision the existing file is opened
  O_NOFOLLOW and must be a regular file of ours with mode 0600. The lock file is opened
  O_NOFOLLOW too.
- After SQLite opens the database, and again after WAL mode creates the WAL and SHM, the directory
  and database must still be the same files (device and inode), and all three files private;
  anything else is refused before a fact is written.
- The default ledger moves to ~/.local/state/tensorfold/living-weights-v2/ledger.sqlite3, a
  directory of its own, and the docs say what the journal requires.

Regressions: a database swapped in before SQLite opens, one created in the gap after the
directory check, a WAL planted before the open, a linked database, and a shared or linked
directory are each refused, with nothing written to the planted file.
…el lands

On a loaded runner the test thread could lose the CPU between submit and cancel for long enough that the fake engine's 4,096-token reply finished first, so the request ended with length, not cancelled (two strand tests red on train #3346). The request now pauses in its prompt pass until cancelled, as the queued-cancel test's blockers do; mid-decode cancels stay covered by cancel_decode, which cancels from the host's own first-tokens event.
…d, /api/tags, /api/show, /api/ps, /api/version) over the native engine (#3117)
…, and the refused-field bodies are JSON

Every test in ollama_e2e_test.zig hung until its 30 s poll timed out, then panicked in deinit.
The cause is the fixture, not the routes: the fake engine sent prefilled and its three tokens
but never `finished`. The engine API says every request ends with `finished`
(core/engine_api.zig:37 and :420), and the server's generation loop
(server/chat_generation.zig:216) ends a reply only when it arrives, so the reply, its socket
and the open connection never ended. The other loopback fixtures (auth_scope_http_test.zig)
send it.

With that fixed, "format, tools and images are mapped or refused by name" failed on its own
bodies: `format":"xml` and the other two fragments lacked their opening quote, so each request
was refused as malformed JSON and the reply never named the field. They are now whole JSON
fields, and each refusal is checked to name its field.

test-ollama-e2e-host runs these loopback tests alone. No route or server code changes.
baidu/Unlimited-OCR-2 at its released bf16 weights on M5-class GPUs: the
publisher's preprocessing (bit-exact), the SAM and CLIP image encoder,
the DASH MoE decoder with greedy generation, chunked prefill
(bit-identical at any cut), serving through tensorfold-native --vision
with the family's chat template, and every kernel under the contract.

The SAM encoder, the decoder's attention, its page2d rotary and its MoE
gate are written from the papers and from the release's modules
measured through their inputs and outputs. tf-uocr-blocks gates each
encoder step alone against float32, tf-uocr-vision and tf-uocr-decode
gate a page's stages, and tools/zig/uocr_reference.py makes their cases
from the release's own code. Fed torch bf16's reply, tf-uocr-decode
accepts a departure only as a tie: the same two contenders on both
sides, each margin within one bf16 step (the reference records every
step's two highest logits); --reply-reported reports them instead.

The server's built-in templates share one helper (hf_text_parse.zig):
Nemotron Parse's replaces the checkpoint's, this family's fills in when
the checkpoint ships none, and a --chat-template wins over both.
Under slots_only without --prompt-cache-gib, plan sets aside the slots that fit past the engine's own window and each other stream's fixed part and page, TF_KV_SHARE at most, before windows and held count the rest. The rest of the default cache still becomes pages after the windows. Plans that already kept all n are unchanged, so is every plan without slots_only or with an asked cache.

GLM's advice under 4 states a stream names TF_KV_SHARE alone where its slots now fit, and --prompt-cache-gib only beside a named cache too small for them.
A row said which products its entry takes by rows, items and pairs, and
nothing about the weights' width. Timings on gfx1151 show a choice that
turns with it: of the two K-parallel tiles a plain prompt of 1 row can
run on, one is ahead on 2-bit and 3-bit codes and the other from 4-bit up.

`max_bits` is the most bits a weight code holds for the row to take a
product (0, the default: any). The registry's cost check refuses wider
codes for plain products and plans alike.

A bound that does not parse refuses its row instead of being ignored:

- a bound that is no code width (2, 3, 4, 5, 6 or 8) stops the build of
  the table that writes it, naming the entry and the bound, where 7 or 9
  would have read as "up to 6" or "any"; a row made by hand with such a
  bound takes no product. The registry and the kernel cases read the
  widths from one list, beside the row type;
- `tuning.build` copies an entry's fields by name and dropped the ones
  the row type lacks, so a misspelled bound left its row taking every
  product. Such a field now stops the build, naming the entry and the
  field. Every field the four tables carry is the row type's.

`hip-affine-tune` prints the bound with a row it proposes. No table sets
the bound yet, so no choice changes.

Refs #2923
…-parallel tile

A plain prompt product of 1 or 2 rows ran on `kp0` (8 columns a lane set,
1 row a pass) on every card. On gfx1151 `kp3` (4 columns, 2 rows a pass)
is ahead at 2 rows at every width, and at 1 row from 4-bit codes up; at
1 row of 2-bit or 3-bit codes `kp0` stays ahead. A resumed prompt ends in
such a piece whenever 1 or 2 tokens follow the kept state.

gfx1151's table now gives `kp0` one row of codes of at most 3 bits and
`kp3` the other plain products of up to 2 rows. Costs stay as they were,
so `kp0` keeps the products its row still takes and no row is shadowed.
Nothing else is chosen differently: products of 3 rows and more, routed
plans, decode and the other three tables keep their tiles.

Both tiles are one template and write the 128-row tile's bytes. Tests:

- launches: at every width gfx1151 picks `kp3` at 2 rows and, at 1 row,
  `kp0` for 2-bit and 3-bit codes and `kp3` from 4-bit up, with the
  matrix cores on or off; it keeps `kp1` and `kp2` past 2 rows and the
  reference tile with the dot2 GEMM tiles off; gfx1030, gfx1100 and
  gfx1201 still pick `kp0`.
- tuning: gfx1151's bound is set, so a table that lost it fails.
- kernel suite: `kp0`, `kp3` and the 128-row dot2 tile, launched by id
  whatever the card's table picks, write the same bytes at 1 and 2 rows,
  every width and group, fp32 and rounded into out16; an output left
  unwritten fails too.

Refs #2923
@ashhart

ashhart commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

Stopped: this train's PRs land after the 1.2.9 cut instead.

@ashhart ashhart closed this Nov 14, 2026
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.

4 participants