Repository navigation
feat: Qwen3.6-35B-A3B serves --parallel N on CUDA, each reply equal to its solo run - #84
Closed
philip-pentatonic wants to merge 40 commits into
Closed
philip-pentatonic wants to merge 40 commits into
philip-pentatonic wants to merge 40 commits into
Conversation
…e, so the prompt end's GDN states are freed With the cache entry one token before the prompt's end, no entry holds the prompt state that prefill returns, but generate and _generate_tp kept it in a local while draft_decode and decode_tp committed into a clone: its GDN states and conv rows (153,944,064 B for the 27B on one GPU) stayed alive for the whole reply, one set more than the four the one-stream admission counts (cuda/geometry.py gdn_geometry). draft_decode and decode_tp take inplace=True to commit into the state they are given; the engine passes it on both ranks, and the first commit frees the prompt end's states as before. Default calls still commit into a copy. Tests: the engine hands the decode a state no entry holds, with inplace (host, one GPU and both ranks of two); an inplace decode gives the same tokens and moves the state it was given (tests/cuda). Not yet run on a GPU. (cherry picked from commit 7df24fa)
…o tensors Two host checks compared a state with one holding the same tensors, so they could not fail: a prefill with keep_at and its reference resumed from one prefix, whose key/value buffers they share, and the same prompt's kept state resumed with nothing to prefill, which holds the kept state's tensors. Each run now resumes its own prefix, and the second kept state is compared with a fresh prefill of the prompt's first n - 1 tokens. (cherry picked from commit c181313)
prefill_tp's keep_at ran in no test: the host tests replace prefill_tp with a stand-in, and the CUDA file has no two-rank case. The new test runs the real prefill_tp on the row-wise CPU stand-ins, on one process holding every weight (rank sum and share are the identity), for rank 0 and rank 1, and compares the prompt state, first token and kept state with prefill's. (cherry picked from commit 8b3dedb)
…chat template and tokenizer Renders a two-turn chat as the CUDA server does (ChatTemplate, then Tokenizer.encode) with the checkpoint's tokenizer files, and checks what the one-stream engine and PrefixCache resume the second turn from: - reply sent back without its reasoning: turn 2 agrees with turn 1's prompt on every token but the last (198 against 271); an entry for the whole prompt does not match, the entry at entry_end does; - reasoning sent back, or thinking off: turn 2 extends all of turn 1's prompt; both entries match and the entry at entry_end resumes one token earlier. Skips unless the tokenizer files are in the Hugging Face cache; the weights are not read. (cherry picked from commit 751847c)
…ack without its reasoning With the reasoning sent back, or thinking off, the next turn extends the whole prompt. The docstrings and the README now say which case differs in the last token. Comments only. (cherry picked from commit 0c2d2b5)
…grow replaces A fresh prefill frees each key/value buffer as soon as a grow replaces it, with or without keep_at: the state at the cut, and a state kept at a chunk start, take their key/value buffers only after the chunk. The test tracks every buffer a grow replaces in a fresh 1,030-token prefill on the row-wise CPU stand-ins and checks that none is still allocated when the next attention runs, with the point at the prompt's end and at the last span's start, over one span and over spans of 64 rows. (cherry picked from commit 6b1673a)
cmd_serve returned into _serve_cuda before it registered the SIGUSR1 stack dump, so the dump its comment calls "the way to see where a silent server waits" existed only on the Mac. The registration now comes before the backend branch; nothing else moves. Test: the handler is registered before _serve_cuda runs (host; fails before the change). The CUDA dispatch test stubs the registration, as the MLX tests do. (cherry picked from commit 10e0cc7)
- Qwen27Engine.generate takes stop_eos (default True) and passes it to draft_decode on one GPU and to decode_tp on rank 0 of two. Rank 1 follows rank 0's windows and never reads it, so the request header is unchanged. - With --parallel N, Scheduler.submit takes stop_eos and each Stream carries it; MultiDecoder accepts and ends a stream at end tokens only when its own request stops at them. Rank 1 commits the paths rank 0 sends, so the ADMIT message is unchanged. - The server passes stop_eos=not ignore_eos to an engine whose generate takes it (the signature check it already makes for "draft"). With ignore_eos, end tokens inside the reply are text, as on the Mac, and finish_reason is "length" unless a stop string or a tool call ended the reply. Stop strings stay active. - Serial, drafted and concurrent decoding apply the same end rule; prompt-end cache entries are taken before decoding, so no token past an end token enters a cache. - docs: ignore_eos on MLX, GLM CUDA and the 27B CUDA engine; Flash Next and Nemotron CUDA still stop at end tokens. (cherry picked from commit 7e78fe4)
…ed build left The eleven CUDA extensions build on first use through tensorfold.cuda.build.load, which adds the GPU's -gencode flag and calls torch.utils.cpp_extension.load; neither prints anything. A start killed during a build leaves torch's lock in the build directory, and every later start waits on it without a word: the log stops at "loading ...", the GPU idles, and only a stack dump shows FileBaton.wait(). tensorfold.cuda.build.load still passes torch the same arguments. After the architecture check, and before torch's load, it looks up the build directory (torch's private _get_build_directory; without it, no line) and prints: - "building CUDA extension NAME (first start after an install or update; later starts reuse it)" when the directory holds no built module, or one older than a source; - the lock's path and "if no other build is running, a killed build left it: stop this start, delete the lock and start again" when the lock is there, again after 60 s if the same lock file is still there. The start is stopped first because a wait that ends imports whatever module the directory holds without building it: after an update, the old one. A GPU older than compute capability 9.0 is still refused before any line. Tests (host): the lines for a first build, a built module, a newer source and a lock; the repeat after the delay, and none after the load ends or the lock changes; the other arguments reach torch unchanged beside the GPU's flag; an older GPU is refused with no line; no line without the lookup; with real torch and nothing compiled, load waits on the very lock the line names until it is deleted. test_the_container_list_adds_nothing points TORCH_EXTENSIONS_DIR at a temporary directory, since load now looks up the build directory. tests/cuda/test_build.py builds one extension with nvcc, checks both lines end to end and that the named steps clear a planted lock. Not yet run on a GPU. (cherry picked from commit d23c69e)
…ndezvous - Troubleshooting: a CUDA start that stops after "loading ..." with the GPU idle; kill -USR1 prints every thread's stack, and a wait in the extension build is a build lock whose path the start log names: stop the start, delete the lock and start again. - Two ranks: the rendezvous port (TCPStore, init_process_group tcp://) and the link between the ranks are not authenticated; keep them on a private link, or firewall the port to the peer. (cherry picked from commit 4ca35a3)
Revision 3ff05202 stores the PLE table as plain BF16 rows (…ngram_embedding.shard_N.weight, [2500012, 160] a shard) with no per-shard scales or biases, where the converted checkpoints pack 4-bit words plus a scale and bias every 32 values; the loader looked for that 4-bit layout only, so a full serve of the revision stopped at layer 1's PLE. host_table.BF16Table memory-maps the rows as uint16 and gathers them a lookup at a time, ple_nvfp4 picks the layout from the shard's own header (4-bit shards to HostTable, BF16 rows to BF16Table) and refuses a mix, and stage_ple_rows copies the rows to the device as they are for glue.ple_embed_bf16, which places them per head and sums each group of 32 as the 4-bit kernel does after dequantizing. Checked against the real revision: shard 2 of embedding-model-00006-of-00131.safetensors (BF16 [2500012, 160], 800 MB) gathers rows bit-identical to an independent read of the file, 128 shards of that size make the 320,001,536-row table the digest derives, and the engine's staging and kernel place real values. Tests: the loader picks BF16Table and its gather equals the file's bytes, stage_ple_rows lands them in the buffers bit for bit, ple_embed_bf16 places rows and sums groups at (2, 32) and (16, 160), and a forward with the PLE layer live over a BF16 table keeps the window contract — a window's logits equal serial steps' bits. The README, RUNBOOK and the Flash Next recipe say the table's BF16 layout is read as it ships instead of naming it a gap, and engine.py's PLE budget sums each table's own nbytes.
The FP4 checkpoints store their block scales as `F8_E4M3` — the published Swift revision carries 73,728 of them, and across its 81 safetensors files that was the only dtype `capacity.SIZES` lacked — so the header walk died on a bare KeyError that `admit`'s rank-wide handler reported as "CUDA startup memory geometry could not be established on every rank: 'F8_E4M3'", a message that names neither the tensor nor the cause. FP8 is one byte a value like the other formats: SIZES gains F8_E4M3, F8_E5M2 and F8_E8M0; an unknown dtype now raises a ValueError naming the tensor and listing the known dtypes, through `capacity.itemsize`, which `geometry.size` and `geometry.padded` use too so an unsizable dtype names itself wherever the estimate reads headers; and the admission handler prefixes the exception type, so the next such failure reads as a cause rather than as text. Checked on the published revision (3ff05202) over its real headers: the estimate completes — 97.39 GiB within a 104.28 GiB budget, native window 262,144 tokens, weights 78.54 GiB, loading 18.85 GiB, cache workspace 18.14 GiB — and the n-gram table measures 95.37 GiB in the BF16 layout this revision ships (102.4 GB over 128 shards, not the 29.8 GiB the 4-bit layout takes), so it does not fit beside the weights and caches and its pages are read from disk. Before this commit the same command printed the dtype and stopped. Tests: an `F8_E4M3` tensor is sized at one byte a value, and a dtype the estimate cannot size reaches the operator's message with the tensor's name in it.
…rnel The FP4 table stored one uint16 bf16 bit pattern a weight and fp32 block scales, so an FP4 checkpoint cost four times its codes on the device: the published Swift revision's 60.4 GB of U8 words became 241.6 GB of patterns, plus 30.2 GB of fp32 scales where the file holds 7.55 GB of fp8e4m3, and building a single layer peaked at 16.26 GiB (a 6.25 GiB int64 gather index for one expert stack). Measured on the hardware: 5.67 GB of tables a layer for a 1.42 GB checkpoint layer — the model could not be served on a 121.56 GiB GPU at all, and the admission estimate, which counts file bytes, could not see why. `FP4` now carries the checkpoint's bytes: the codes as their stored nibbles ([N/BN, K/64, 32, BN] uint8, the low nibble the even input) and the block scales as their stored fp8e4m3 bytes ([K/16, N] uint8), with the per-tensor `weight_scale_2` a fp32 kernel argument — never a widening in memory. The kernel unpacks the nibbles through a field-arithmetic E2M1 table and rebases the fp8 exponent (the subnormals as values, the NaN codes as NaN) exactly as `e2m1_bits` and `row_scales` do, and the weight traffic halves with it: a byte a value, not two. The exact-BF16 form stays for operands that are not E2M1 — the shared expert — as patterns with fp32 scales, chosen by the table's `packed` flag, both paths compiled into one kernel. `stacked_fp4` builds the per-expert form, one factor an expert beside its rows, the gate/up join keeping each half's own. Verified on the hardware: the stored bytes are 1.01x the checkpoint's, was 4.00x. 462 CUDA tests pass — the four NVFP4 files at 50 — including two that pin the guarantee: a packed table holds the checkpoint's bytes, and a packed stack keeps each expert's slab decodable. The n-gram tables' mappings are advised MADV_RANDOM: their readers gather rows by key, so read-ahead brings in pages nobody asked for beside the weights (102 GB of table against 79 GiB of them).
A table the eager step and a CUDA graph capture both read must not allocate on first use: the pattern form now carries its ones factor from construction, so nothing allocates inside a capture. Also forwards the CUDA crash switches through the serving container when set (TORCH_USE_CUDA_DSA, CUDA_LAUNCH_BLOCKING, PYTORCH_CUDA_ALLOC_CONF).
…turable The NVFP4 grouped step walks its plan's item list and its counts on the host — items() slices plan.items and calls tolist() — a synchronising device-to-host copy. Inside a capture that is cudaErrorStreamCaptureInvalidated: a real serve died after loading the weights with "operation failed due to a previous error during capture" and nothing pointing at the cause. The tiny tests never saw it, because they capture with empty plans, where tolist() reads nothing. MoE4 declares capturable = False and the engine reads that answer instead of capturing a step that cannot be captured: it decodes eagerly, says so once, and the model serves. The tokens are the same — the eager path is the one the tiny tests exercise end to end. A device-side item loop, as the generic grouped path has, is what would let this route capture again. Two tests pin it: the route's own declaration, and an engine asked for graphs over such experts building none and still decoding.
…nes with 500 or a stream error event
The CUDA server caught only RequestError. A request the checkpoint's chat template refused (raise_exception), a chat_template_kwargs that dict() could not convert, or a temperature, top_p, top_k or seed that did not convert closed the connection with no response. Sampling was resolved after a stream's headers and role chunk, so a streamed request with a bad temperature or seed ended after the role chunk. An engine failure closed the connection too: no response for a non-streamed request, no error event and no [DONE] for a streamed one.
- Preparing a request now checks what it reads: chat_template_kwargs must be an object or null (null is read as absent; every other value, [], "", false and 0 included, is refused), a template refusal becomes "the chat template rejected the request: ...", and temperature, top_p, top_k and seed go through parse_numbers, as on the Mac. The Sampling is built there and carried on PreparedRequest, so check(), prepare() and GlmApp.check refuse the same requests, and a streamed one is refused with HTTP 400 before its headers.
- Any other failure while preparing gets HTTP 400 with its message, as on the Mac, and is logged with its traceback. A body that is not UTF-8 gets the existing "not JSON" 400.
- A failure during generation is logged with its traceback and answered as the Mac server answers it: HTTP 500 {"error": {"message"}} for a non-streamed request, an error event of type server_error then [DONE] for a streamed one.
- Valid requests make the same engine calls with the same Sampling; it is built before the stream opens instead of after.
Accepted before, refused now: a boolean in any of the four sampling fields (read as 1 or 0), a non-finite temperature or top_p, a non-integral top_k or seed (truncated before), a malformed top_p, top_k or seed on a greedy request (not read before), chat_template_kwargs as [], "", false or 0 (read as absent before), and chat_template_kwargs as a list of key/value pairs.
Tests: tests/test_cuda_server_errors.py (202 cases; 140 fail without the fix; the 60 that check valid requests reach the engine with the same Sampling, and the 2 that check a null or empty chat_template_kwargs is read as absent, pass with and without it), and tests/cuda/test_qwen27_server_errors.py for the 27B checkpoint and engine on a GPU.
(cherry picked from commit 4236863)
…t, which now carries it (ashhart#61)
…ecked before a stream opens - The CUDA server reads `stop` (a string or a list) and cuts the reply token by token: at the first token whose text completes a stop string, the reply's tokens end there, on_tokens returns True, and the match and everything after it are left out. Drafted rounds of many tokens and "draft": false rounds of one therefore give the same content, usage and token_sha. With return_token_ids, the ids listed end at the same token. - The 27B (one GPU and two ranks), and Flash Next and Nemotron on one GPU, stop in the round that holds the match; concurrent streams stop after a later round. GLM, and Flash Next and Nemotron on two ranks, decode on to an end token or the reply limit, and the server returns the reply only up to the match. - Streamed deltas hold back an end that may begin a stop string, as on the Mac (StopPolicy.visible); stop strings match the generated text, reasoning included, before it is split; tool calls are parsed from the cut text. - A non-boolean ignore_eos or a malformed stop is refused with HTTP 400 before any stream bytes (stop_options, as on the Mac). - Where the engine reads ignore_eos (GLM), end tokens inside the reply are text, as on the Mac, and finish_reason is "length" unless a stop string or a tool call ended the reply. - docs/api.md: stop on both backends. (cherry picked from commit 66339f9)
… prefill steps and kept states
…the prompt's end A chat prompt ends in the generation prompt, <think> and a newline (token 198). When the next request sends that turn back without its reasoning, its history renders an empty reasoning block, <think> and two newlines (token 271), so the entry kept for the whole prompt differs from the next prompt in its last token and does not match: the follow-up is prefilled from the last shorter entry or from scratch. Both prefix caches now keep a prompt's entry at len(prompt) - 1 (engine.entry_end; a one-token prompt keeps its whole prompt): the one-stream cache (two entries, one GPU and both ranks of two) and the concurrent PrefixCache (KEEP entries, private copies). An identical prompt sent again now resumes with one token to prefill; a prompt that extends the whole last prompt prefills one token more; stats["cached"] reports the entry's length. prefill, prefill_tp and prefill_state take keep_at and also return the state after prompt[:keep_at] and the drafter's snapshot there. The spans do not change and no forward is added: the chunk that holds the point runs each GDN chain as two launches, rows [0, cut) then [cut, W). The chain kernel steps one row at a time on fp32 state that it loads and stores as fp32, so the two launches give one launch's output rows and final state; the prompt's own state, last logits and first token keep their bits. The state between the launches, the conv rows before the cut and the key/value rows below it are the state a prefill of the first keep_at tokens commits (prefill bits do not depend on chunking). The kept state takes the prompt state's key/value buffers after the last chunk, so a buffer grown past the point is never held twice. The drafter's taps start where its window reaches back from the kept point; it absorbs the chunk's rows before the cut, is snapshotted, then absorbs the rest. Two ranks add no collective. Tests: tests/cuda/test_qwen27_prompt_end_cache.py (a cut chunk against one launch; keep_at against none, one and several spans; the kept state against a fresh prefill of the prefix; the next turn, a resumed prefill, longer and repeated prompts resumed against fresh prefills, greedy and sampled; buffers grown inside the cut chunk; the drafter's taps; the engine and the concurrent decoder end to end against the serial reference), tests/test_qwen27_prompt_end_cache_host.py (both caches' entries and resumes with stand-ins, both ranks of two; prefill_state's spans, cuts and drafter calls with a stand-in chunk; the prefill on row-wise CPU stand-ins for the kernels). tests/cuda/test_qwen27_multi.py: a prompt extending a finished reply now resumes one token earlier. Not yet run on a GPU. (cherry picked from commit 9b2021a)
…d CUDA - ashhart#65's prompt-end entry follows kept message starts, and the decoder's entries view their rows; the 27B's tests expect entries one token early. - Ternary Bonsai 2 27B (prism-ml's 2-bit pack) as a lane family: Prism rotations, 2-bit lanes, exact widening before M5, with Qwen3.8-27B's DFlash2 drafts. Recipe: docs/recipes/ternary-bonsai-2.md. - --vision: up to four images a request (data URLs, or HTTPS links with --vision-urls) on the lane engine, MLX and CUDA. Image replies keep drafting and equal "draft": false ones; an image prompt keeps no prompt-end entry. - The --vision checks and options move to serve_options.py. Fixes ashhart#18, fixes ashhart#81.
…ation, a redacted request log From ashhart#64 (Qwen3.8 MLX image input), carried into the vision branch's modules: - image URLs must be HTTPS on port 443 without a fragment, and the fetch sends a User-Agent and an Accept list of the image types it takes (hosts that refuse clients without one now serve the image); - a response must declare image/jpeg, image/png or image/webp, and the decoder opens only JPEG, PNG and WebP; - at most 16 requests decode and process images at once; others wait up to a minute, and past 128 waiting the server answers 503 so clients retry (CapacityError, on the Mac and CUDA servers); - the request log records image parts as <redacted>.
…est's engine resumes from a PrefixCache
…me bytes HostTable.gather copied a prompt's n-gram rows with one fancy index per file, so rows whose pages were not in the page cache were read from disk one page fault at a time. On a DGX Spark with a 131,072-token cache the ~31 GB tables barely fit in the page cache, and how much of them the start-up prefetch leaves cached varies from start to start. A gather of 1,024 rows or more (a prompt chunk of 64 tokens or more) now copies on up to 16 threads, 512 rows or more each. numpy's fancy indexing releases the GIL, so the page faults overlap: staging costs about 0.07 ms a fault instead of 0.25 ms. Decode steps keep the single-threaded copy. The bytes are the same. One Spark, 131,072-token cache, default 2,048-row chunks, a fresh process each with the n-gram files dropped from the page cache before it (the start-up prefetch refills what fits), release and branch alternated, every prompt new text: 606 tokens 0.37-0.55 -> 0.36-0.42 s, 1,118 tokens 0.56-0.73 -> 0.55-0.59 s, 4,186 tokens 1.95-2.31 -> 1.92-1.97 s, 8,192 tokens 3.65-4.29 -> 3.60-3.70 s, 32,768 tokens 15.1-16.5 -> 15.1-15.2 s, 120,000 tokens 65.4-65.7 -> 64.7-65.3 s. Decode unchanged. Checked: the threaded copy is byte-identical to the single-threaded one (new test, and 1,000 to 131,072 random rows of the real table); teacher-forced NLL through the prompt and the decode path identical to the release on all 119,980 values; 55 replayed benchmark replies byte-identical; drafted vs serial 9/9; needles 9/9.
… a failed copy raises, a dropped table's threads end
The Mac server has decoded Qwen `<parameter=k>` values by the tool's JSON schema since 0.3.5 (ashhart#28); the CUDA server's parser still returned every value as a string, so an array parameter reached the client as "[\"a\", \"b\"]" instead of ["a", "b"] and strict clients rejected the call. cuda/reply_text.parse_tool_calls now runs each value through the same tool_parameters.decode_parameter the Mac server uses: array, object, boolean, integer, number and null parameters decode when the text is valid JSON of that type, anything else keeps its exact text.
…and stack dumps while serving - DeepSeek-V4-Flash as the deepseek_v4 family on MLX: compressed sparse attention, mxfp4 experts, hyper-connections, DeepSeek's own prompt encoder and DSML tool calls, with DSpark or MTP draft heads converted from DeepSeek's releases. Replies equal "draft": false ones. Recipe: docs/recipes/deepseek-v4-flash.md. - Flash Next's prompt path on M1-M4: block scores as one batched matmul, two query heads a simdgroup in the GQA kernel and a simdgroup scan for the top-512 cuts; a one-row chunk keeps the indexer's product. Same bits. - kill -USR1 prints every thread's stack while serving too: armed again after the CUDA engine's warmup and after each request, since an in-process compiler takes the signal when it first loads. - The CUDA tool-call tests expect typed values as on the Mac, the null-parameter HTTP tests skip without MLX, a prepared request names its defaulted fields, and the docs say to restart both ranks after a generation error. Fixes ashhart#14.
…DA, expert-aligned prompt tiles - Checkpoint copies and snapshot loads check again before every eviction, and a resumed prompt stops holding the stored prefix it copied; the memory tests pin host RAM, so they pass on any Mac (ashhart#74). - ashhart#70's 64 GB M5 Pro measurements go into the README and recipes, labelled as 0.3.5.1. - On M1-M4, Flash Next's prompt expert gathers take row tiles that never straddle experts (the scheduling idea of ml-explore/mlx#4567), same bits. - A reader for ModelOpt and compressed-tensors NVFP4, FP8 and MXFP8 weights, W4A16 and W8A16 lane matmuls with exact weights, and Qwen3.8-27B on ModelOpt NVFP4 checkpoints. Fixes ashhart#70.
…ps (ashhart#67) PR ashhart#67's first twenty commits, rebased onto next-0.3.6.2 as one (their branch merged main twice; the moved MoE module is the only adaptation). Its commits: - nvfp4: the format's decoder, its row-invariant matmul, and the MoE tables - nvfp4: the engine's route for the checkpoint — BF16 non-experts, FP4 experts, the stacked tables checked on real d - nvfp4: the family admits modelopt checkpoints on CUDA (require_readable's refusals route) - nvfp4: the recipe's NVFP4 section — the format, the route, what the real checkpoint checks - nvfp4: the MTP layer's BF16 stacked experts ride the FP4 tables (the checkpoint excludes them from FP4) - nvfp4: the BF16 embedding as a plain B16 (the row lookup, not a matmul face) - nvfp4: the draft head from the bf16 lm_head requantized 4-bit (drafts change speed, never bits) - nvfp4: the whole expert stack decodes in one pass (e2m1_bits and row_scales stacked, load time at the 512-expert sca - nvfp4: the draft head quantized from the full bf16 lm_head, rows in token-id order (the sampler maps the subset as o - nvfp4: a tiny modelopt checkpoint builder and the loader's tests (the format, the header, the route's faces) - nvfp4: e4m3_bits exact on all 256 fp8 codes (the field form for normals, the value table for subnormals, the NaN cod - nvfp4: the family's check reads modelopt (NVFP4 group 16 refused otherwise), the Swift checkpoint listed in MODELS - nvfp4: the FP4 tables in the kernel's tile order (the K block contiguous, N tiles outer) and the decode gathering in - nvfp4: the MoE buffers at the engine's flat index (row * slots + slot, the qmm kernels' dest), count read as the pro - nvfp4: the b16 matmul reading whole BK blocks a slice (the split by the weight's shape, never the row count) and the - nvfp4: the loader's BF16 faces and the expert stack calling the helpers by their names (b16_from_rows, stack(proj)) - nvfp4: the tiny checkpoint shipping the n-gram constants the loader checks (I64 like the real one, and a table of th - nvfp4: the docs say what the engine reads (README's refusals and the Spark list, the runbook's) and what the real we - nvfp4: the CPU checks pin the NVFP4 route (the family's check on a ModelOpt config and its block size of 16, the Swi - nvfp4: the tiny fixture mirrors the published naming and the engine's widths
…s grow With expandable segments (PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True), the first request whose prompt plus max_tokens passed 8192 rows, and every request after it, failed at capture: "it->second->use_count > 0 INTERNAL ASSERT FAILED at CUDACachingAllocator.cpp:3332". Growing the buffers drops every graph but kept the pool handle. Torch counts a private pool's expandable mappings per allocation and its unmaps per free range, so once freed blocks coalesce the count stays above zero, the pool is never unregistered, and a capture into it finds a pool no graph uses. A growth now takes a new handle. RTX PRO 6000, torch 2.13 (NGC 26.07), Vontra/Qwen3.6-35B-A3B-MLX-4bit-MTP: 40 label-style requests from 8 clients, three past 8192 rows, fail from the first growth on before and pass after, with unchanged token SHA-256s equal to "draft": false. The new test_graphs_recapture_after_the_buffers_grow fails 2 of 4 cases before; tests/cuda/test_qwen36_moe.py and tests/test_qwen36_family.py: 16 passed.
…pts prefill, warm long conversations - Flash Next reads its NVFP4 exports as published: FP4 experts, MXFP8 or bf16 elsewhere, and FP8 or BF16 n-gram tables. Grouped NVFP4 experts read their routing on the GPU, so CUDA graphs replay any routing. Two ranks, --ple-on-ssd and images on NVFP4 checkpoints stop at startup until they're qualified. - On Macs a prompt fills one planned chunk at a time and running replies take rounds between its chunks, for --decode-share of each chunk's time (default 0.25; 0 is 0.3.6.2's order). Every reply still equals its solo run. - A prefill holds the DFlash2 window's taps, not every chunk's; the fitted window counts a live stream's growth; and startup names the longest request whose prompt is kept. - GLM-5.3's prompt experts take the expert-aligned gather on M1-M4. Fixes ashhart#71, fixes ashhart#72.
…s grow With expandable segments (PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True), the first request whose prompt plus max_tokens passed 8192 rows, and every request after it, failed at capture: "it->second->use_count > 0 INTERNAL ASSERT FAILED at CUDACachingAllocator.cpp:3332". Growing the buffers drops every graph but kept the pool handle. Torch counts a private pool's expandable mappings per allocation and its unmaps per free range, so once freed blocks coalesce the count stays above zero, the pool is never unregistered, and a capture into it finds a pool no graph uses. A growth now takes a new handle. RTX PRO 6000, torch 2.13 (NGC 26.07), Vontra/Qwen3.6-35B-A3B-MLX-4bit-MTP: 40 label-style requests from 8 clients, three past 8192 rows, fail from the first growth on before and pass after, with unchanged token SHA-256s equal to "draft": false. The new test_graphs_recapture_after_the_buffers_grow fails 2 of 4 cases before; tests/cuda/test_qwen36_moe.py and tests/test_qwen36_family.py: 16 passed.
Up to N requests decode together on one GPU. The family runs the 27B's concurrent path: the shared Scheduler and Stream, prompts prefilled 1,024 rows a round while other streams decode, states kept at message starts and prompt ends, caches sized once at admission, and every stream's window verified in one multi_tree_forward (routed experts keep a row's bits at any row count). MTP drafting follows Flash Next's multi decoder: every stream's unabsorbed rows go through the head in one call, then chains advance a step at a time for all streams, with the one-stream engine's stopping rule, so a stream takes the same rounds it takes alone. - multi_tree_forward(hidden=True) also returns the rows' final normed states, which the MTP head reads. - Head.forward_streams runs several streams' rows over their own caches in one call. - Admission counts N streams' states and caches (the 27B's stream geometry plus the head's keys and values) before loading, and refuses with the window that fits, as the 27B's --parallel does. - Tests: 16 streams' rows (past the experts' 1,024-pair plan) equal each window alone; concurrent equals solo and serial for mixed lengths, greedy and keyed sampling, drafts on and off, streams joining and leaving, a stream past 8,192 rows, expandable segments on and off; prefix resume; a stopped client and a failed prompt-end copy end only their own request.
…e one-stream graphs Rounds over several streams run eagerly, as the 27B's and Flash Next's do; for one stream, eager rounds cost a quarter more than the graphs. On an RTX PRO 6000, one client's chats ran 300 tok/s at --parallel 8 against 401 at --parallel 1. Now a stream decoding alone takes the one-stream engine's round (mtp_round, factored out of mtp_decode) in its Graphs: its state moves into the graphs' fixed buffers once and stays there, decoding eagerly beside other streams when they join. The same client runs 422 tok/s at --parallel 8, with the same token SHAs. Admission counts the graphs' buffers (a stream's worth). Tests: a lone stream takes the solo engine's rounds, stays resident while another joins and leaves; a long lone stream grows the buffers past 8,192 rows and recaptures while a short one joins, expandable segments on and off.
The recipe describes the concurrent rounds, admission and the lone-stream graphs, with label and chat throughput, latency and memory at --parallel 1, 4 and 8 on an RTX PRO 6000 (every reply's token SHA-256 the same at each N and with "draft": false). README and the API page list Qwen3.6 among the CUDA families that share rounds.
- Flash Next EXL3's n-gram table reports its bytes, so it starts on CUDA again. - MLX stays below 0.32.3 until the prompt kernels follow its new gather arguments (ashhart#88). - CHANGELOG.md and the version. Fixes ashhart#88.
# Conflicts: # tests/cuda/test_qwen36_moe.py
0.3.6.3 gives a request stop_eos (ignore_eos) and the scheduler carries it on each Stream; the family's concurrent decoder, from ashhart#84, ended every stream at an end token. Now generate passes stop_eos to the scheduler and each stream's rounds end at end tokens only when its request stops there, as the 27B's concurrent decoder does. Test: a drafted and a serial stream ignoring end tokens decode through one to their count beside a stream that stops there, each with its serial tokens.
Contributor
Author
|
Updated for TensorFold 0.3.6.3: 0.3.6.3 (1911880) is merged in, plus one fix, 1dfe6de. 0.3.6.3 gives each request its own end tokens ( |
Owner
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.
Builds on #78. Invited in #45. Resume points for this checkpoint's template are fixed separately in #83.
tensorfold serve Vontra/Qwen3.6-35B-A3B-MLX-4bit-MTP --parallel Ndecodes up to N requests together on one GPU. Every reply equals the same request served alone and its"draft": falserun.SchedulerandStream;multi_tree_forward.--parallel.--parallel 8 --context 262144is refused with the window that fits (114,508 on an RTX PRO 6000).multi_tree_forward(hidden=True).NVIDIA PyTorch 26.07, expandable segments, revision 81169a9, 8 client threads over HTTP, public-domain passages:
--parallel 148--context 32768: label JSON, 32 requests (≤1,410 tokens)"draft": false"draft": falseat N=8 vs at N=1Also exact at N=8 on the RTX PRO 6000:
Tests, on both GPUs:
tests/cuda/test_qwen36_moe.py: 33 passed (22 new), with and without expandable segments.tests/test_qwen36_family.py: 8 passed.Questions:
hidden=keyword onmulti_tree_forwardthe right place for the final normed rows the head needs?