Repository navigation
feat(hip): tensor parallelism over RCCL, behind hip/collective.zig (slice 13) - #655
Conversation
…, DeltaNet, norms, RoPE, MoE routing and decode plans The kernels a model engine composes, built by hipcc for -Dhip-arch with the caps table's instruction switches and embedded as one code object a source group, launched from Zig: elementwise ops and casts, norms and the merged decode tails, RoPE, the attention walks (flat, planned over a page table with the query heads of a KV head read together, the 64-row prompt tile flat and paged), the DeltaNet recurrence token-serial and chunked, the linear attention's conv and gates, the MoE router, pick and route, argmax and top-k, and a lane round's plan kernels. A typed Ops layer checks shapes; an arena hands out a forward's scratch, and a counting stream measures it without launching. hip-kernel-test checks each against a host or float64 reference, and the merged and paged forms against the forms they replace, bit for bit where they promise it; -Dhip-device-lib names ROCm's bitcode. The sources hold device code only: plain kernels by C name, templates instantiated for the types the launches use.
…it and dense, with tensor-parallel cuts core/quant reads a checkpoint's MLX affine projections (bits 2, 3, 4, 5, 6 and 8, any group) or dense ones, detects the format from the tensors, cuts a projection by output rows, by a rank's whole input groups or into its two K halves, splits an expert stack across ranks, and hands a backend the upload. Every cut keeps the codes and group tables byte for byte: a test quantizes with affine4_host and checks each cut dequantizes to the same bits as the rows and columns it covers, and it fails when a cut is off by one group.
…st, one family of bits at every row count core/registry selects, for a format, op (product, group, routed plan, routed with activation) and path (decode or prompt), the cheapest entry the GPU, the run's switches and the shape allow, by a per-GPU tuning table read at build time (core/tuning), so every rank picks alike. Its family rule checks that one (op, path) keeps one family of entries at every row count from 1 to 256 for each width and group: a row's bits never depend on how many rows share its launch. The rule's test fails when a tuning table lets another family take some rows.
… GEMM tile, stream and K-parallel tiles The MLX affine 2- to 8-bit products a model's projections run, chosen per product by the kernel registry over a per-GPU tuning table (gfx1030's for RDNA2, gfx1100's for RDNA3 to RDNA4): the decode row, column, stream and split tiles, the RDNA2 wide tile, the prefill dot2 GEMM and K-parallel tiles, the gfx11 matrix-core GEMM tile (compiler WMMA builtins, no rocWMMA), routed plans and products sharing x, with the routed gate and up's activation as an epilogue. The tile sources hold device code only; each kernel the Zig launches resolve is instantiated explicitly. hip-kernel-test checks every entry on the served models' shapes and a ragged sweep of every width and group against float64, the entries the registry picks between by rows for equal bytes, and a row's bytes alone and in a round of 2 to 32 rows.
…A header needed From ThinkOffApp's gfx1151 runs on this PR and ashhart#621: Ubuntu's HIP 7.1 keeps its device bitcode in LLVM's clang resource directory, and the kernels build there with -Dhip-device-lib set to it, without rocWMMA's header.
87304f6 to
3605629
Compare
…e fork's hand ports The kernel was written for TensorFold after FLA's chunk_gated_delta_rule; no code came from vLLM or FLA, and the header only came along from the opengfx1030/vllm-rdna ports.
Qwen3.5 / Qwen3.6 text checkpoints for the HIP engine, host side only: the geometry (dense and MoE, MTP layer count, rotary, layer types) from config.json, the MLX affine quantization table per module, one tensor index over the safetensors shards, the projections, the routed experts stacked, and the tensor-parallel cuts on core/quant. `zig build test` runs its tests; TF_QWEN_DIR indexes a real checkpoint. Draft: the geometry is a third Qwen text parser beside qwen27/config.zig and the Metal 2B's admission. ashhart#491 proposes one shared config and weight path instead; this is refit to that once agreed.
mlx-serve's conversions (Qwen3.8-27B-MLX-Serve-4/6/8bit) bake the trunk's `1 + w` into its norms but ship the MTP head's norms zero-centered. Read as gains, the head drafted nothing: 0 of 127 drafts accepted on the 27B. Norms averaging under 0.5 now get the 1 added; the baked heads (9B, 35B, 27B-3bit-mtp) average 1.2 and above and are kept.
3605629 to
9851ef6
Compare
…, and reads layers, mrope and end ids config_checks.zig takes qwen27/config.zig's rules to the HIP geometry: the activation (silu), the attention gate (the swish gate, att * sigmoid(gate), and no bias), the recurrent state type (fp32, under either key), the sizes the kernels index with 32-bit counts, each layer's kind from layer_types in any order, the mrope sections (three, filling half the rotary width, interleaved), max_position_embeddings, and the end ids of config.json and generation_config.json. The Qwen3.8-27B names <|im_end|> only in generation_config.json. 0 and 1 count as false and true, as the 0.8B 2-bit conversion writes them. Co-authored-by: ashhart <[email protected]>
9851ef6 to
ba96d09
Compare
…el-free set The device count, a context's free and total memory (hipMemGetInfo, looked up on its own so the admission set is unchanged), a buffer's base address, a pinned host buffer's sub-range and typed view, and raw.zig: device copies, fills and pinned transfers on a forward's raw stream handle, none of them on the counting stream. hip-gpu-test checks each on the GPU.
ops/tp.hpp in the ops group, device code only: an activation plus an fp32 rank sum rounded once, a rank's local expert ids and the masks of the experts another rank answers, and a token's softmax probability (MTP's confidence). Zig launches in launches/tp.zig, `Ops.addWide`, `moeLocalize`, `moeForeignItems`, `moeZeroForeign` and `tokenProb`. hip-kernel-test checks each against a host reference.
… and model checks The HIP branch's engine (ashhart#490) on ashhart#463's runtime and the kernel launches of ashhart#617 and ashhart#621: the lane rounds with MTP drafts, the paged attention cache and the radix prompt cache (ashhart#625), chunked prompts (ashhart#623), CUDA-graph rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (ashhart#624); `tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels. The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its only reader is the plan.
…anks come from --tp The two-Mac engines take their ranks from --speed-up's settings file; the HIP engine takes them from --tp and the flags beside it. A HIP serve given --speed-up is refused, with or without --tp, so the two never mean different things for one model.
A request with drafts off resumed nothing and kept nothing; it now resumes from the deepest shared snapshot and keeps its marks as a drafted one does. The kept states are the target's alone (pages, DeltaNet states), so a serial pass keeps what a drafted one reads and the other way round.
…refill kernel goes gatedDelta sent 64 rows or any prefill to gdn_prefill.hip (fp16 products, __expf), so a prompt cut on either side of 64 rows was a different sum. Every length now runs the fp32 recurrence. The new test cuts a 200-row prompt at 1, 63, 64, 65 and 136 rows and checks the rows and state equal one call's bits; it fails with the chunked kernel.
…recurrence at every length)
…rrence at every length)
|
Hello @BlivionIaG, Thank you for the tensor-parallel HIP engine, and for the tp 4 table on four V620s (gfx1030). We have no AMD card. This lands on your receipts plus our host checks, after #617 and after #631. It meets #631 in zig/src/hip/root.zig. This head contains the fp32 recurrence, so that V620 table does not cover it. The receipt still needed is tp 2 on gfx1100 and gfx1030, and tp 4 on gfx1030, for the 35B-A3B, on this head. Thank you. |
|
Qwen3.5, Qwen3.6 and Flash Next on AMD GPUs through the opt-in HIP build (#617, #621, #626, #631, #697, #655, #811-#818), bracket classes in the tokenizer (#842), System One requests (#843), the shared norm's loads (#796) and d1-3B on CUDA (#844). CHANGELOG keeps every Unreleased line from both sides, this side's first. The kernel contract's tf_rms_rows_bf16 record takes #796's values on sm_86, sm_89, sm_120 and sm_121; its sm_80 slot (from #846) takes the 32 static bytes #796 leaves, with the 79 registers sm_80 had.
|
Thank you, @BlivionIaG, for tensor parallelism on HIP, and for the tp 4 comparison with vLLM on the V620s. Your commits ship in TensorFold 1.0.12 under your name: Our We have no AMD card, so this lands on your receipts plus our host checks: the policy, link, rccl and slicing tests pass on macOS and Linux. Your runs at the landed head, 19 passed on two W7800s, two V620s and four V620s, are in the CHANGELOG. Still open: tp 8, RDNA3.5 and RDNA4. Posted by Ash's AI Assistant Synthena |
The contributor's three new commits landed above with the same lines; the others are ashhart#631's changes under other hashes, already in. This keeps the PR's head in the history with no change to the tree.
…rt#844 onto the candidate Qwen3.5, Qwen3.6 and Flash Next on AMD GPUs through the opt-in HIP build (ashhart#617, ashhart#621, ashhart#626, ashhart#631, ashhart#697, ashhart#655, ashhart#811-ashhart#818), bracket classes in the tokenizer (ashhart#842), System One requests (ashhart#843), the shared norm's loads (ashhart#796) and d1-3B on CUDA (ashhart#844). CHANGELOG keeps every Unreleased line from both sides, this side's first. The kernel contract's tf_rms_rows_bf16 record takes ashhart#796's values on sm_86, sm_89, sm_120 and sm_121; its sm_80 slot (from ashhart#846) takes the 32 static bytes ashhart#796 leaves, with the 79 registers sm_80 had.
…and graph steps together
…s over the link and the graph vote
Slice 13 of #491: tensor parallelism over RCCL, behind the
hip/collective.ziginterface #631 introduced. Stacks on #631 and #696 (the server's std options); review three commits:feat(hip): tensor parallelism over RCCL, graphs at any world size, and the window fix. The graph and loader commits before them are #631's.What this changes
comm/rccl.zig: opens RCCL at run time (librccl.so.1, or the policy'srccl_libfirst) and runs all-reduce, all-gather and broadcast on the engine's streams.comm/link.zig: the ranks' TCP link. Rank 0 listens and sends the communicator's id and its policy, and a rank whose GPU differs from rank 0's is refused. The link then carries rank 0's steps.comm/group.zig: joins the two into acollective.Group, andhip.joinGroupbecomes its join (feat(qwen3_5): the Qwen3.5 / 3.6 engine on HIP (slice 12) #631's wasnoGroup). The server andtf-qwen35-testgo through it.--tpagain (1, 2, 4 or 8 ranks,--rank,--master,--master-port). A rank above 0 serves no HTTP and runs rank 0's steps.feat(qwen3_5): HIP rounds replay split graphs at any world size, RCCL outside them): a round under tensor parallelism replays the graphs feat(qwen3_5): the Qwen3.5 / 3.6 engine on HIP (slice 12) #631 cuts at each collective, the collectives issued between them. Rounds no longer run eager under tp unlessgraphs=on;graphs=offstill turns them off.fix(qwen3_5): every rank sizes its streams for rank 0's window): a follower started without--contextsized its streams for the 32,768-token default while rank 0 served a longer window, and the first prompt past it stopped rank 1 (Invalid, a page table larger than its own).Engine.firstgives every rank rank 0's values over the same all-gather asleast.pthread_createunder Zig's per-thread alternate signal stack, so the HIP build's native module declaresstd_optionswithout it. The server takes it through feat(server): a backend's std options reach the server binary #696, split out because it touches the shared server.Receipt
Environment: head d47b0f8, on feat(qwen3_5): the Qwen3.5 / 3.6 engine on HIP (slice 12) #631 at 73e4989 and feat(server): a backend's std options reach the server binary #696,
main0efbd44 (1.0.8). Zig 0.17.0, HIP 7.14, RCCL from the same ROCm, Fedora Linux, on Radeon PRO W7800 (gfx1100) and Radeon PRO V620 (gfx1030).Model checks on Qwen3.6-35B-A3B MLX 4-bit with its MTP head, at 66d8a19:
The rounds under tensor parallelism are compared to one rank: drafted == serial, solo == together, resumed == fresh, and graph == eager (split graphs; 19 checks pass where 14 did before).
Graphs at any world size: decode logits byte-identical graphs on and off; served
serve_check15/15 (drafted == serial, solo == together) and the rewind gate 16/16 at tp 2 and tp 4.Decode tok/s, before (eager under tp) and after (split graphs),
serve_bench.py:One loss: Qwen3.5-9B at tp 2 on the W7800s (-5.5% at one stream, -8% at four). At tp 1 graphs are unchanged.
The window fix, failing before: at 10926cf, a tp 2 server whose rank 1 had no
--contextstopped rank 1 on the first 65,536-token prompt, on the W7800s and on the V620s, every time; at 66d8a19 the same run serves 65,536 and 131,072 cold (27.2 s and 79.1 s on the W7800s).Loading with feat(qwen3_5): the Qwen3.5 / 3.6 engine on HIP (slice 12) #631's page release, at tp 2 and tp 4: see feat(qwen3_5): the Qwen3.5 / 3.6 engine on HIP (slice 12) #631's receipt (2 × W7800 28 s and 4.5 GiB peak PSS, 4 × V620 25 s and 6.5 GiB, against 34 s / 20.5 GiB and 27 s / 21 GiB before); model checks at d47b0f8 pass 19/0 at tp 2 and tp 4.
Serving receipt with the repo's tools, Qwen3.6-35B-A3B MLX 4-bit MTP at revision f84b054c, one model process set at a time; raw JSON, the exact token arrays, request settings and scripts: receipts-qwen35-hip/receipts/qwen35-hip. One GPU is feat(qwen3_5): the Qwen3.5 / 3.6 engine on HIP (slice 12) #631's head (10926cf build).
Cold prefill (
bench_cache.py, exact token arrays,--prompt-cache-gib 0, three cold runs each, 0 cached tokens):Decode and concurrency (
bench_openai.py --tokens 256 --reps 3 --temperatures 0;bench_concurrent.py --levels 1,4 --alone --serial), tok/s:Every reply equals its solo run and its
"draft": falserun in every column (30/30 and 4/4).Memory of the server processes only (all ranks): device peak 26.2 / 27.9 / 26.1 / 27.7 / 35.6 GiB at the native window with one stream; host RSS while serving 0.5 GiB at tp 1 and about 1 GiB a rank under tp. During the load the RSS high-water mark is about 19.5 GiB a rank: each rank maps the whole checkpoint, and the mappings share one page cache.
One rank: the tp 1 columns are feat(qwen3_5): the Qwen3.5 / 3.6 engine on HIP (slice 12) #631's head; the window fix only runs when there is more than one rank.
Tests run:
zig build test test-golden -Dcpu=apple_m1: golden 0 unexpected; one inherited failure,core.checkpoint_metal's split-checkpoint test, which logs the same error onmain;zig build test: 57/57 steps, 693/700 tests (7 skipped);hip-kernel-test66/66 on gfx1100 and on gfx1030;zig fmt --checkis clean;lean_check.py: 539 problems, the same asmain.Not run, and why: RDNA3.5 and RDNA4 groups (no such cards here), and a standard-server comparison (vLLM on these GPUs).
Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (checked under tp 2 and 4)