Repository navigation
Conversation
…nit Macs take TF_QWEN27_METAL_KV_PAGES A 512-key prompt chunk spans exactly two KV pages, so the paged prompt kernels take both page bases before their 32-key steps instead of reading the page table at every step. The M5 refusal of the flag goes, now that the paged kernels have run on an M5 Ultra (part of #1293).
…mits Answer the requested M5 and simdgroup contract coverage with shuffled pages, page and chunk seams, partial pages, independent nonfinite and stress references, contiguous byte replacements, and real source faults for gates 1 and 3. Keep production arithmetic unchanged.
…, with its dispatches and barriers a layer time-dsv41-metal-slots records each layer's encode (dispatches, barriers) and the median wall time of a round over synthetic weights, at 1, 2 and 4 slots of one row and one slot of four rows, so the cost of the per-slot loops shows without the release checkpoint.
…ssor writes and decode attention A decode launch over several slots ran the window key (tf_dsv41_f_kv), the ratio-2 pool and the two scatters of its kept inputs, the FP4 round trip into the compressed rows, the index-key packing and the decode attention once a slot, because each slot's state lives in buffers of its own. Each of these now has a slot form (*_segs) that indexes a per-layer table of the slots' buffers (segs.zig, written as the layer is encoded, every buffer it reaches declared with useResource) by the row's slot (Meta.rowseg). The per-row body of every kernel moved into an inline function the per-slot kernel and its slot form both call, so a row runs the same instructions alone or beside other slots; launches of one slot keep the per-slot kernels. The pool's slot form copies the kv and score words it keeps in place of the two scatters. The attention picks its prefetch form when no slot has more than two rows. Contract: each slot kernel is registered as a replacement of its per-slot kernel, bit-equal to it launched a slot at a time at 1, 2, 3 and 4 slots of 1 to 17 rows (heads 4 and 64), NaN and infinities included, with a TF_CTL 6 control (every row reading or writing the first slot's state) that goes red at the shapes gate for all but the prefetch attention.
…idate blocks and top-512 An index-source layer of a launch over several slots ran the decode scorer, a barrier, the candidate blocks (at the candidate source), a barrier and the top-512 once a slot. With the layer's slot table the scorer (tf_dsv41_ix_scores_dec_segs) runs every row over its slot's keys, key count and first position, the candidates (tf_cand_segs) over its slot's key count, leaving a slot with no keys as the per-slot path does, and the unchanged top-512 over all rows; one barrier between stages instead of one a slot. The merged path keeps every row's scores at a fixed stride (the scratch's key width), so the top-512 reads each row's first `visible` scores exactly as before; launches of one slot keep the per-slot code. As for the attention side, each kernel's row body is an inline function both forms call. Contract: both registered as replacements, bit-equal to the per-slot launchers a slot at a time at 1 to 4 slots of 1 to 17 rows, ratios 1 and 2, with and without a candidate mask, NaN and infinities included, each with a TF_CTL 6 control (the first slot's keys or key count for every row) red at the shapes gate.
…sources call segs.table declared every buffer a layer's slot kernels reach with its own useResource call, five to seven a slot a layer. segs.declare now hands every region buffer of the launch's slots (each layer's window, and the pools, index keys, carries and kept inputs of the KV sources) to the encoder in one useResources:count:usage: call, made by forward.encode and by forward.run for each command buffer before its first layer; a launch of one slot declares nothing, as before. ComputeEncoder gains useResources beside useResource. time-dsv41-metal-slots also reports the median host encode of a whole round (a command buffer encoded, never committed).
…useResource does Follows c0027b9 (metal: a Metal 4 backend under the queue, command buffer and encoder calls), whose useResource hands a Metal 4 encoder's buffers to the queue's residency set, and 494be49, which makes Metal 4 DeepSeek-V4.1's default queue. useResources now does the same for each of its buffers on a Metal 4 encoder, which has no useResources:count:usage:.
… and the per-slot bodies held to the base The slot table entry was declared in each of the five kernel sources against one Zig struct. It now lives in deepseek_v41/segs.h, which sources.zig puts before fused, compress, csa2_attn, index and cand (as kv_pages.h is shared); the contract compiles the header with a kernel that writes sizeof and every field offset and checks them against segs.zig's Seg, which the contract probes now use too. After the gates the contract also launches each per-slot kernel that now calls a moved body (tf_dsv41_f_kv, the pool, round trip and key packing, tf_dsv41_attn_dec in both prefetch forms, tf_dsv41_ix_scores_dec and tf_cand) and the base's body of it on the same inputs, random and with non-finite plants, at every probe shape, and requires the same bytes: 164 cases. The base's kernels are kept only in the test tree (tests/contract/dsv41_base), appended to today's source under tf_base_ names, so they share its helpers and nothing ships twice.
…e a multi-slot layer launch segs.table declares nothing since the useResources commit, so an encoder that runs a layer over several slots has to call segs.declare first. forward.encode and forward.run do; real_test's timeLaunch, which runs one layer over four slots, did not, so its slot kernels read buffers never declared to the encoder. It now declares them on its pass's encoder. The package exports segs so the tests can.
Carry the pending default-frame fix onto current main at model load and serving. Pre-M5 dense Qwen uses 128 rows instead of unused 512-row scratch, while M5, routed defaults, valid environment settings and explicit caller minima keep their values. Admission may fit more streams with the smaller slabs. Pin each qualified GPU generation and deferred loading, and keep the executed attention width equal. Add a budget-boundary regression and document the M3 qualification required before landing. No kernel or arithmetic change. Refs #2089
…tions Follow main ab2c91d, which qualifies the shared prefix before M5 and changes the geometry argument from chip capability to the selected shared-prefix path. Model loading now asks the same sharedPrefix reader as the runner. Keep the qualified 512-row default before M5; the explicitly unshared path keeps the new 128-row frame. Retain exact row assertions for both geometries. Follow main b4d4795, which moves startup sizing into qwen27_reserve.zig. Its serving and info reservations now choose the incoming frame width using the actual shared geometry, and pass that geometry to the changed model promptRows API. Preserve main fit/shared-prefix handling and validated overrides. No kernel or token arithmetic changes.
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.
CI for a landing train: #3180 #2954 #2797 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.