Repository navigation
Conversation
…o 16 rows The TFQ3 contract: 1-row decode equals multi-row decode. GLM broke it at 8 rows. tfq3_dispatch.dense sent a chunk of 8 or more rows to dense_prefill_nax_* (MMA), and tryKdaIn and tryDenseGlu stopped at 7 rows, so in an 8-16-row decode window the dense projections, the KDA input and the dense MLP's gate/up took other kernels than the same row alone. - dense takes the MMA kernels only for a prompt pass (wide.Io.prompt, set by denseMm, which only prompt.zig runs); decode windows keep the decode kernels at every row count. - tryKdaIn and tryDenseGlu fuse every decode window up to state.max_rows (16): the 16-row scratch fits (dense GLU: 16 x 2 x 12288 of max_yr_elems' 1,239,040). Non-TFQ3 runs are untouched; the prompt pass keeps its MMA kernels.
… read them GLM's checker accepted any word offset whose matrix fits the stream, but its 4-bit kernels read those words four at a time as uint4 (dense_decode.metal:11, 15; moe_mv.metal:64, 114, 178, 227, 257; prefill.metal:133, 248, 376). As in Flash Next (fdd80c5), a 4-bit nonmoe.tffpw record (tensor) or expert projection (layer) whose word offset is not a multiple of four words is refused by name (Tfq3Misaligned), in the one check admission and loading share. 5-bit words are read a word at a time and keep any offset; the format is unchanged. Tests: misaligned 4-bit records inside the stream refused (main accepts them), 5-bit odd offset accepted; the two earlier truncation cases move by a whole uint4 so they still test the end.
…h its records A checkpoint without TFQ3 record files must take main's paths and allocations whatever sits beside it. - GLM: initLoader mapped pw_v3_tables.bin whenever it existed and set has_tfq3 from it alone, so a stray tables file compiled TFQ3 pipelines and allocated their scratch (and a corrupt one failed the load). initLoader now returns first unless tfq3.hasRecords finds nonmoe.tffpw or a layer_NN.tffpw (up to the MTP layer's). - Flash Next: engine_load mapped the tables file even when no shard was present, outside admission and budgeting. It maps it only when tfq3_files.hasRecords finds a layer or MTP shard, as scan admits them. With records present nothing changes.
…, as GLM's tfq3_check.tables took the header and a 16 KiB length only, and let NaN or Inf in pw_v3_tables.bin reach the kernels. GLM's check (glm/tfq3_check.zig:158) also requires the six affine floats and every LUT and c64 half finite; Flash Next's now does the same, and tfq3_files.checkTables reads the whole table for it, so the scan before admission and the loader refuse the same files (Tfq3Table). The size: both families read the same table struct, FnPwV3Tables (flashnext_tfq3/common.metal:40): 64 header bytes, 256 + 1024 + 1024 LUT words and three 64-entry half4 tables, 10,816 bytes (GLM's tables_bytes). Flash Next required 16,384, the 16 KiB section alignment, reused as a floor: it refused a valid unpadded table but never admitted a short one, so it was over-strict, not unsafe. tables_bytes (10,816) is now the floor; a table is read through a no-copy view only when its 16 KiB-rounded length fits the mapping, else copied. Tests: a padded and an unpadded table pass (main refused the unpadded one), a NaN float and an Inf half are refused, and the scan counts the table's real length.
…tes; stray tables and misaligned records GLM, on a Metal GPU (test-glm-tfq3): - dense: the prompt pass (MMA) repeats exactly, and 16-, 8- and 4-row decode windows each equal 1-row decode, both widths, split-K and not (runDense passes the prompt flag; a prompt's 16 rows still take MMA). - glm_tfq3_rows_test.zig: the fused KDA input (tryKdaIn, its real 24576 + 320 x 4096 shape) and dense GLU (split-K and no-split) over 16 rows as one 16-row window, two 8-row and sixteen 1-row ones: every row's bytes equal, 4- and 5-bit; tryKdaIn now takes every window size. - a 4-bit nonmoe.tffpw record one word off, inside its stream, refused by name (Tfq3Misaligned). - a non-TFQ3 checkpoint with a stray pw_v3_tables.bin dry-loads with has_tfq3 false and main's bytes. Flash Next, on the host: a stray table file is neither a record nor scanned (hasRecords false; an MTP shard makes it true).
…cks and stray-file isolation
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.
CI for a landing train: #4996 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.