Repository navigation
gpu: a row table's rows go to the card as read and decode there, in one owner for every row format - #1068
Conversation
…threads on this machine The PLE reader's prefetch helper split a ubatch's rows over a fixed twelve threads (PLE_WORKERS), a count chosen on one machine. A floating helper now reads over as many threads as the worker pool has participants here (threads::helper::Parts::pool: the cores the process's cpu mask leaves, or BLOOMERY_THREADS), and one that the pool's shape cannot be read for reads alone. HelperOptions::spread is the one constructor: a pinned helper still reads every token alone, and a token too small to split stays on the helper. DeepSeek V4.1's engram reader takes the same rule in place of its own one. Every helper is listed with its part count and where it comes from, and the helper record prints both (parts=, parts_from=); bloomery-serve-qwen38 prints its helpers at load beside the nvtier record.
…ne owner for every row format A Qwen3.8 PLE fill decoded its rows on the step thread and copied the values (10,240 B a position) to the card, except NVFP4 rows read from the NVMe tier in two planes, which the card decoded. The decode and the reader now sit in one format-neutral owner, gpu::rows: - RowFormat names a row's encoding (IQ4_NL blocks; bloomery's F8 rows and NVFP4 rows at the table's scale) and how a read lays it (whole rows, or NVFP4 code and scale planes). Its host decode is the gguf decoders'. - RowKernels::enqueue copies a read's bytes to the card as they are (1,440 B a position for IQ4_NL and NVFP4) and decodes them with one launch for each layout: NVFP4 planes (moved from ple.rs), NVFP4 rows, IQ4_NL and F8. Each value is the host decode's bit for bit; the host refuses an undefined span by name before anything is enqueued. Rows past the staging (F8 rows, a byte a value) go up in parts, in order. - RowRead, the NVMe tier's reader, holds a prompt call's reads ahead keyed by position, count and row ids and drains a stale one, as body38's PleRead did. PleHost names the rows and lands them through the owner on every path that copied values: the step, a pass, a ubatch (late or not) and a slot's rows. On the host it gathers the rows from the mapping instead of decoding them. A verify's rows, which its staging takes as values, decode on the host. gate_ple's rows clause runs every layout against the host decode, from a position past the first and through a staging that takes F8 rows in parts, and the refusals of each.
There was a problem hiding this comment.
Verdict: CLEAN: No proven must-fix defect remains in the reviewed findings.
Non-blocking
⚠ Supply the dispatch proof: crates/gpu/src/rows.rs:374.
The one-token F8 arena allocates 2,560 / 16 × 9 = 1,440 B for 2,560 input bytes. The loop performs two H2D calls and two decode launches: one more H2D call and two more launches per token than the base [derived].
Attach the base/head PTX scan comparison, new clauses' FAIL-first results, and same-lease A/B commands with output to complete the dispatch proof.
Checked
Duplicates: dryer reported 0 candidate pairs in the crates it scanned; GPU and GPU-gate crates were outside that scan.
Complexity: enqueue is new at 27, with span validation followed by chunk dispatch. rows_clauses 13→22 adds format/refusal cases. run 20→21 adds entries; Q38::open 71→72 adds helper records; Kernels38::load 17→18 adds a loader. No correctness defect found in these functions.
Silent failure: 3 added candidates followed. Unsupported formats reach a named error; source construction limits plane counts to 1 or 2; failed read-ahead naming is retried and refused by the fill.
Tests: source mutation audit only. Assertions reject dropped row validation, an accepted zero-worker count, and missing pinned-reader normalization. Helper assertions cover the default part count, recorded metadata, and pool-plan refusal. Row comparisons catch substituting row zero and dropping the stored scale plane; read-ahead assertions cover replaced guesses and buffer reuse.
Gates: no tolerance relaxed. The unsafe-count increase has a dated PIN and reason; row-kernel coverage replaces the moved entry.
Escape catalog: C1–C4 do not match the changes.
Notes
Static review only; tests and GPU gates were not executed here. The reported card runs lack the required nvidia-smi card/driver line, so gpu.json records no complete GPU evidence.
Card check: needs-gpu. This pull request changes crates/gpu-deepseek41/src/chain/glue.rs, crates/gpu-gates/src/bin/gate_ple.rs, crates/gpu-gates/src/bin/generate_ds41.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
Qwen3.8의 행 테이블(PLE) 값을 읽은 그대로 카드로 올려 카드에서 풀고, 그 일을 모든 행 형식이 쓰는 공용 owner 하나로 모았습니다.
What and why
The Qwen3.8 per-layer embedding row table came in three formats (IQ4_NL, F8 E4M3 rows, NVFP4 rows), and
body38.rsdecoded each one on the host into f32 before uploading it. This PR addscrates/gpu/src/rows.rs, one owner that uploads the bytes as read and decodes them on the card with one kernel per layout. It also moves the read-ahead buffer handling (PleRead, nowRowRead) there, and moves the NVFP4 planes kernel out ofple.rs.PleHostinbody38.rskeeps only row naming, hashing and history. The verify path still decodes on the host because its staging receives values.A second commit makes the helper that reads a large row range split the read over the worker pool's threads (
threads::helper::Parts,HelperOptions::spread). The part count comes fromthreads::report(), so the constantPLE_WORKERS = 12inbody38.rsand the fixed single worker in the DeepSeek V4.1 engram reader are gone. The helper record now carriesparts=andparts_from=, andbloomery-serve-qwen38prints it at load.Undefined input is refused by name before the upload (an E4M3 NaN scale byte, a scale that leaves f32's range, an F8 NaN byte, a planes span larger than staging), and the output is left unchanged.
The speed result is no change: IQ4_NL and NVFP4 upload 1,440 B per position instead of 10,240 B of f32, but at these batch sizes the upload is not the limit, and every cell below is within run-to-run noise and its sample ranges overlap. The PR makes no speed claim.
Release notes: Under the hood: PLE row tables decode on the card through one shared owner, and the row-reading helper splits large reads over the worker pool's threads.
Code shape
cores::half_to_f32,iq::iq4_word,cores::table16_word,mxfp4::ue4m3_halfandq8f32::Mxfp8Bytes::valueare reused, and the host side calls the gguf decoders (dequant_row,E4m3Rows,Nvfp4Rows). The helper part count has one source,threads::report().rows.rsis format code and has no model branch.body38.rslost its decode code.ple.rs,PleRead,PLE_WORKERSand the fixed worker count ingpu-deepseek41/src/chain/glue.rsare removed.gate_plerows clause, four refusals).tools/unsafe-ratchet.txtgpu count moves 2879 to 2891 with aPINline, because code moved in and new code arrived, not because old code was relaxed. Theple_rows_nvfp4rows in the PTX shape tables become the four newrows_*entries.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": the NVFP4 planes kernel incrates/gpu/src/ple.rsandPleReadincrates/gpu/src/arch/qwen3moe/body38.rsmoved intocrates/gpu/src/rows.rs, and the old copies are deleted. The DeepSeek V4.1 engram card decode kernels (ds41_glue_engram_rows_q3k,_iq4nl,_q5kincrates/gpu-deepseek41/src/chain/glue.rs) do the same kind of work and are left as they are.What I ran
Card: NVIDIA GB10. Base
996b23be30a2cd4332906bbd18af9c03d75e7452, headb15f054ef56418bbc18d9807f5068c040bdd9cc7.Gates on the card:
gate-gpu-ple:gate_ple: 36 clauses, 0 failed. The newrowsclause compares all four layouts (NVFP4 planes, NVFP4 rows, IQ4_NL rows, F8 rows) with the host decode bit for bit at tensor scale 1e0 and 3.3242362e-5, over 10485760 values at offset 7680 (bits=true PASSfor all eight). The four refusals keep the output (e_kept=true PASS), and the four new kernels haveld_local=0 st_local=0.gate-gpu-qwen4exp-e2e:gate_qwen4exp_e2e ran 449 s (exit 0). Eager against graph, pass against step and the ubatch path agree on logits bit for bit.gate-gpu-qwen4exp-nvfp4:gate_qwen4exp_nvfp4 ran 107 s (exit 0)on the real NVFP4 folder.gate-gpu-ds41-step:PASSED: gate_deepseek41_step --feed.gate-gpu-qwen38-serve:lookup_off_1_moves_slots_with_its_cache: PASSand the three matchinglookup_off_2,lookup_lookup_1andlookup_lookup_2checks.Host tests that cover the changed code:
bloomery-threads(--test pool --test helper, includinga_parted_helper_is_listed_with_the_pools_threads), the ggufnvfp4ande4m3tests (9 passed) andarch::qwen3moe::body38::tests(7 passed).The user-facing binary, built with the release feature set and run on the three Qwen3.8 files, with
--ctx-size 16896:' Paris. The capital of Germany is Berlin. ...'(24 tokens) and the long request (prompt_n 4701) generated 48 tokens.The NVFP4 and FP4-Local loads print
helper name=engram-prefetch asked=float pinned=float cpus=20 parts=20 parts_from=pool.Speed, base against head, from one A/B on the GB10 with a 4,096-id prompt, 128 generated tokens and three rounds per side, on four arms (
fp4l-off,fp4l-mtp,nvfp4-off,q4-off). The greedy output is identical between base and head (24 requests, 3,072 tokens, no first difference). No cell moved beyond run-to-run noise.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.