Repository navigation
perf: Flash Next decode 15-17% faster, byte-exact - #6
Merged
Merged
Conversation
- The family sets MLX_MAX_MB_PER_BUFFER and MLX_MAX_OPS_PER_BUFFER (MLX_ENV); the fused decode submits each layer as it is built. Every expert kernel binds the 420 MB expert stacks, and with MLX's default limit each one ended a command buffer. - Expert gate/up hands its routing (picks and weights) to expert down instead of every down simdgroup redoing the top-10 selection. Per-slot expert kernels at every window width; down writes each slot's output and the next hyper-connection norm combines them with the same arithmetic. - a[0] indexing replaced by reshape views: MLX's a[0] is a gather that copied the DeltaNet state every step. Positions and the no-ids placeholder made once per forward. - The n-gram embedding in one lookup kernel over 8 concatenated shard groups (was about 70 small operations), and the token embedding with its tiling into the four streams in one kernel; both match mx.dequantize bit for bit. - The MTP head absorbs every verify row and draws each row's first draft in the verify's GPU pass; the rows past the kept ones are dropped from its cache afterwards. Skipped for streams with drafts off. Output is byte-identical to serial decoding and teacher-forced NLL is unchanged. In-engine tok/s on an M3 Ultra: prose 92.4 -> 106.9, code 100.2 -> 115.7, 23k-token agent prompt 96.6 -> 113.3, file edit 119.5 -> 137.1.
bertholomus
referenced
this pull request
in bertholomus/TensorFold
Oct 7, 2026
…uest's "loop_guard"), default off GitHub #6: a long agentic turn can loop in its reasoning ("OK. / Writing. / Let me write.") to max_tokens and answer nothing. call_gate.ThinkLoop watches a thinking reply: when, in 3 windows of 1024 reply tokens in a row, fewer than 2 % of the window's token 8-grams are new (GitHub #9's novelty signal, on token ids), the reply gets the thinking budget's close (a newline, </think>, a blank line) and goes on to its answer (generate_gated's cut). A decision on the committed tokens alone; replies that do not loop are untouched. Off by default: TF_LOOP_GUARD=1 makes it the server's default, "loop_guard": true / false sets it a request. Not under a grammar or a thinking budget.
bertholomus
referenced
this pull request
in bertholomus/TensorFold
Oct 7, 2026
…ORCH_ALLOW_TF32_CUBLAS_OVERRIDE=1) GitHub #6: the recipe runs the engine in an nvcr.io/nvidia/pytorch container, which sets TORCH_ALLOW_TF32_CUBLAS_OVERRIDE=1: every fp32 cuBLAS GEMM runs in TF32, here the prompt chunks' router logits, indexer weights and mHC mixes. That gives other prompt bits than the reference and the gates, and so other replies for a seed: with the override, the report's body at seed 3001 (T 0.6 / top_p 0.95) loops to the 32,768-token cap with 112,801 reasoning chars, as reported; without it the reply answers in 1,077 tokens. cuda_engine now sets the switch to 0 before the engine exists (torch reads it at its first cuBLAS handle; a line says so when it was 1) and fp32_gemms() raises if fp32 GEMMs still run in TF32 (a 4096-term sum of (1 + 2^-12)^2 is 4098 in fp32, 4096 in TF32). Servers started with the switch at 0 are unchanged.
1 task done
joshuaswarren
added a commit
to joshuaswarren/TensorFold
that referenced
this pull request
Nov 26, 2026
…dy shaders for ashhart#1544 Rewrites the omarchy-derived Vulkan compute shaders from the behavior spec, from cast/copy through the gated-delta state machines to the argreduce pair. omarchy_trig.h becomes vulkan_trig.h (single inv_freq helper, Synthena ashhart#6), gated_delta_prefill_ash becomes gated_delta_prefill_oracle, accepting both -DASH_QWEN35 and -DORACLE_QWEN35. PRESERVE_F32 requests OpExecutionMode DenormPreserve (f32) via spirv_execution_mode; sdpa_decode_native pins the single-key bit-exact V transport (Synthena ashhart#7) and the 7168-key shared bound. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Flash Next (
qwen4_exp) decodes 15-17% faster with byte-identical output and unchanged teacher-forced NLL.What changed:
MLX_MAX_MB_PER_BUFFERandMLX_MAX_OPS_PER_BUFFERthroughMLX_ENV, and the fused decode submits each layer as it is built. Every expert kernel binds the 420 MB expert stacks; with MLX's default limit each one ended a command buffer.a[0]indexing replaced by reshape views: MLX'sa[0]is a gather that copied the DeltaNet state every step.mx.dequantizebit for bit).Measured on an M3 Ultra, in-engine tok/s (fixed prompts and seeds, output compared between variants):
Through the server: short answers 105-107, code 112, file edits 190, 18k context 98.5, the agent prompt 103-115. The README table and the recipe are updated; the hero image still shows the old Flash Next numbers.
Tests: 252 passed. On the model: serial bits in every verify window at the 2,048-key boundary and at 18k (including a window cut and continued); NLL 1.5443 at 18k, the same as before.