Commit Graph
203 Commits
Author SHA1 Message Date
Xiaoze Fan 382bda03d1 docs: add a guide to speeding up decode 2026-11-04 00:12:09 +00:00
Xiaoze Fan 33cbb3c54e feat(utils): add once-per-message logger methods (#858)
debug_once / info_once / warning_once log on rank 0, once per distinct message and args. select_kernel, which logged its choice once per layer, and the hand-rolled log-once guards now use them.
2026-11-03 15:31:08 -08:00
Mukkesh Ganesh 03e5ea0672 feat(server): report per-request prefill and decode timings in api responses (#814)
* feat(server): report per-request prefill and decode timings in api responses

* fix(server): take timings spans from the scheduler and gate them behind --enable-timings-report

* fix(scheduler): count accepted drafts as min(n, emitted) and stamp reqstats with perf_counter
2026-11-03 14:44:25 -08:00
ZihaoMuandLZ-QWQ 9cacd0896c fix(moe): publish rocm cpu expert inputs before notification (#764)
* fix(moe): prevent stale cpu expert inputs in rocm graphs

* fix(moe): publish rocm cpu inputs with graph events

* fix(moe): qualify rocm kernel io with ordered copy fallback

* fix(moe): enable locked hybrid staging on rocm

---------

Co-authored-by: LZ-QWQ <lz1830837889@163.com>
2026-11-02 21:29:42 -08:00
Chen Cheng d026ffd3b9 feat(gguf): read nvfp4 weight scales on qwen4exp ggufs (#845) 2026-11-02 19:49:03 -08:00
Xiaoze Fan 3d23551c5b perf(cpu-moe): speed up the nvfp4 W4A8 kernels (#851)
The VNNI dots were compute bound per core; with fewer instructions per weight they reach the DRAM read bandwidth.
The W4A8 kernel now follows FREETOKEN_CPU_MOE_ISA.
2026-11-02 15:05:17 -08:00
Xiaoze Fan dacac5f5fa feat(spec): add MTP drafts for the Qwen3.5 family and Qwen3.8-Flash-Next (#844)
* feat(spec): add the MTP proposer for the qwen3_5 family

* test(models): read the qwen3_5 MTP head of bf16 and block-fp8 checkpoints

* feat(spec): verify qwen4_exp targets on qsa_sparse graphs with PLE verify handlers

* feat(spec): add the qwen4_exp MTP draft from the checkpoint or a Strata pack

* docs(cli): document the speculative decoding flags

* fix(spec): refuse MTP draft sources the draft cannot read before the target loads

* docs(qwen4_exp): describe the verify path in the PLE docstrings

* fix(spec): refuse a missing relative MTP draft path before the target loads

* fix(moe): read MTP head experts on the host and require both stacked tensors

* refactor(spec): tell the final prefill chunk from prompt_len instead of the scheduler's ChunkedReq

* refactor(spec): let each MTP draft family check its own weight source

* fix(qwen4_exp): size the disk PLE eager staging for decode and verify rows

* perf(kernel): read the KV-index gather's chunk count from the grid, not a constexpr

* refactor(moe): let each family name its MTP expert tensors

* refactor(spec): force the MTP draft's MoE resident in the proposer and check it after load

* fix(spec): refuse MTP with dummy weights

* refactor(spec): move HiddenRelay under spec/mtp, its only user

* refactor(spec): drop MTPDraft.config, fold its embed hooks into embed_tokens

* refactor(models): note FeatureSink's graph binding, drop its runtime_checkable

* fix(models): read quantized MTP fc projections under the quant config
2026-11-02 11:37:09 -08:00
Mukkesh Ganesh ea2916d31c feat(gguf): serve gpt-oss gguf checkpoints on gpt_oss (#838)
* feat(gguf): serve gpt-oss gguf checkpoints on gpt_oss

* fix(gguf): refuse missing gpt-oss bias tensors, honor swa pattern, scale nvfp4 before bias

* fix(gguf): honor gpt-oss yarn truncate, gate the bf16 float cast, scale nvfp4 before the down bias
2026-11-02 08:58:07 -08:00
A5bhinav ee43b2a113 fix(server): refuse n != 1 on /v1/completions instead of ignoring it (#842) 2026-10-29 17:15:32 -07:00
Chen Cheng ecbbce4577 fix(moe): skip inactive gguf routes in hybrid decode (#823)
* fix(moe): skip inactive gguf routes in hybrid decode

* perf(moe): run the inactive-route memset and zeroing only in hybrid decode

Only hybrid decode hands the GGUF kernel -1 routes, so mul_mat_id takes an inactive flag
and MMQ does the ids_src1 memset and the zeroing pass only when it is set. Prefill and
fused / offload decode go back to the main-branch MMQ calls.

* perf(moe): compare expert ids unsigned in mm_ids_helper

A negative (inactive) id compared unsigned sorts after every expert and equals none, so the
helper needs no remap to INT_MAX; the remap made nvcc unroll its token loop half as far.
2026-10-28 22:28:13 -07:00
Xiaoze Fan c2c3e828e8 feat(spec): verify draft tokens on the target side (#836)
* feat(spec): add the speculative verify infrastructure

* feat(scheduler): run decode steps as speculative verify steps

* chore(engine): mark the speculative decoding config fields with one comment

* feat(server): add short aliases for the speculative decoding flags
2026-10-28 21:18:02 -07:00
Chen Cheng d2977fbc13 feat(kernel): add an iq1_m mmq kernel for moe steps above 8 tokens (#835) 2026-10-28 20:48:55 -07:00
festeraeb c94535c909 fix(attention): size the decode KV tile to the shared-memory budget (#840)
Assisted-by: Claude (Anthropic)
2026-10-28 20:05:27 -07:00
Xiaoze Fan d043fb61f8 refactor(layers): share one GatedDeltaNet op in layers/linear_attn (#841)
* refactor(layers): share one GatedDeltaNet op in layers/linear_attn

* test(layers): restore the global context in the GDN test and fix stale comments
2026-10-28 17:22:50 -07:00
Xiaoze Fan a2ce636083 refactor(attention): move linear-attention metadata into a LinearAttnBackend (#837)
* refactor(attention): move linear-attention metadata into a LinearAttnBackend

* refactor(attention): make LinearAttnBackend a BaseAttnBackend with FLACaptureData

* refactor(attention): key every linear-attention row by fla_metadata.cache_indices
2026-10-27 23:56:59 -07:00
Xiaoze Fan e328cf6381 refactor: add engine and scheduler seams for multi-row decode steps (#833)
* refactor: add engine and scheduler seams for multi-row decode steps

* refactor: rename the graph steps argument to rows_per_req

* refactor: drop VerifyInfo and require rows_per_req on verify batches

* refactor: fix stale seam comments and read decode_rows_per_req directly

* refactor: reword two GraphRunner comments for multi-row graphs

* fix(engine): scale the GPU-decode MoE pool limits by decode_rows_per_req

* refactor: drop the unread Context.moe_offload_cache field

* test: trim the multi-row seam tests
2026-10-27 16:03:01 -07:00
Xiaoze Fan 9221fd7fc2 feat(scheduler): add radix_lookahead keys to the prefix cache (#834)
* feat(scheduler): key the prefix cache by token bigrams behind radix_lookahead

* refactor(scheduler): make radix_lookahead a bool

* test(scheduler): admit radix_lookahead test requests at their prefix hit
2026-10-26 22:38:53 -07:00
Julien Pierre 075cf57296 fix(server): recover Qwen tool calls after unclosed think (#825) 2026-10-26 19:49:11 -07:00
Xiaoze Fan 408e6ae8c7 feat(gguf): serve image input on minimax-m3 ggufs from a minimax_m3 mmproj (#829)
* feat(gguf): serve image input on minimax-m3 ggufs from a minimax_m3 mmproj

* docs(models): drop the minimax-m3 gguf vision note
2026-10-26 17:15:46 -07:00
Xiaoze Fan edab62cdb3 feat(gguf): serve image input on muse-glimmer ggufs from a muse-glimmer mmproj (#830)
* feat(gguf): serve image input on muse-glimmer ggufs from a muse-glimmer mmproj

* docs(models): drop the muse-glimmer gguf vision note
2026-10-26 17:15:34 -07:00
Mukkesh Ganesh 380693af9c feat(gguf): serve image input on qwen3vl ggufs from a deepstack qwen3vl_merger mmproj (#827) 2026-10-26 15:21:04 -07:00
Xiaoze Fan ba31db2ea7 chore(release): 0.2.1 (#824) v0.2.1 2026-10-25 17:36:06 -07:00
Chris Qian 0bf7dbbf23 fix(models): discover safetensors shards from the index (#819)
* fix(models): find index-only checkpoints that keep shards in a subdirectory

* fix(models): make the checkpoint index authoritative for shard discovery

The index is read directly so safetensors_weight_map stays the only
header-based reader, and _host_ram_fits_parallel sizes the shards the
reader will actually open, so the low-RAM serial fallback fires again
for subdirectory layouts.

* fix(models): fall back to root shards when the index is unusable

Share one index parser between iter_weight_files and safetensors_weight_map
instead of a third copy; warn and glob the root when the index is broken,
absent or empty; reject index keys that escape the model folder; let the hub
download fetch the index itself; tell the truth in the diagnose docstring.

* revert(models): back out the defensive index fallback, keep the no-index test

Per review: a broken index is a broken checkpoint, so the loader keeps the plain one rule -- use the index if there is one, otherwise glob the root. The no-index fallback test stays as the only coverage of the root glob and the consolidated.safetensors rule.
2026-10-24 19:10:52 -07:00
Mukkesh Ganesh 271ff07b30 feat(gguf): serve image input on deepseek4 ggufs from a deepseek4v mmproj (#816)
* feat(gguf): serve image input on deepseek4 ggufs from a deepseek4v mmproj

* fix(gguf): skip an unusable deepseek4v mmproj instead of refusing the trunk
2026-10-24 13:31:24 -07:00
Jesús Jódar Piernas 756108f048 fix(e2e): respect cuda device visibility in aime memory probe (#821) 2026-10-24 12:42:27 -07:00
Jesús Jódar Piernas 2d93085545 feat(flint): add nvfp4 modelopt and gguf support (#797)
* feat(flint): add nvfp4 modelopt and gguf support

* refactor(flint): address final review scope requests
2026-10-24 12:37:57 -07:00
LZ_QAQ 32056cf460 fix(ple): add rocm disk wait-sync support (#776)
* fix(ple): add rocm disk wait-sync support

* fix(kernel): validate hip wait-sync support before enabling it

* refactor(ple): share decode fills and sync flag allocation
2026-10-23 15:35:47 -07:00
Xiaoze Fan fd863cce3e feat: add --embed-weights host for a pinned host embedding table (#806)
* feat: add --embed-weights host for a pinned host embedding table

* refactor: check the tie from the model config and share the op walk
2026-10-23 14:41:37 -07:00
Chen Chengandzihaomu 6505b6a005 fix(kernel): convert fp32 to e4m3 in one rounding on sm_89 (#805)
* fix(kernel): convert fp32 to e4m3 in one rounding on sm_89

* fix(kernel): avoid nvidia fp8 cast asm on hip

---------

Co-authored-by: zihaomu <zihaomu@outlook.com>
2026-10-23 14:27:34 -07:00
Mukkesh Ganesh 0c50eb9d82 perf(attention): drop redundant activation copies in glm5 dsa prefill (#795)
* perf(attention): drop redundant activation copies in glm5 dsa prefill

* fix(attention): guard the dsa sparse kernels' int32 q/o addressing
2026-10-23 12:39:33 -07:00
Mukkesh Ganesh 0b98e9d900 feat(gguf): serve image input on glm5-next ggufs from a glm5v mmproj (#810) 2026-10-23 12:28:53 -07:00
cherry77-cloud 507a8bfa81 fix(rotary): preserve fp32 inputs in mrope torch fallbacks (#641) 2026-10-23 00:11:06 -07:00
Xiaoze Fan e0a7e23c9d feat(server): add /v1/cache/flush to drop the prefix cache when idle (#811)
* feat(server): add /v1/cache/flush to drop the prefix cache when idle

* refactor(scheduler): run every cache flush at the idle safe point

* test: cover cache flush on the overlap loop and on a live server
2026-10-22 23:43:14 -07:00
Manish Biswal 20d5d93132 feat(gguf): read NVFP4 token_embd rows in the vendored get_rows (#801)
* feat(gguf): read NVFP4 token_embd rows in the vendored get_rows

Signed-off-by: iamanishx <manishbiswal754@gmail.com>

* fix(tests)

Signed-off-by: iamanishx <manishbiswal754@gmail.com>

---------

Signed-off-by: iamanishx <manishbiswal754@gmail.com>
2026-10-22 20:19:24 -07:00
Mukkesh Ganesh ed359eee0a feat(gguf): serve qwen3vl and qwen3vlmoe gguf checkpoints text only (#807) 2026-10-22 18:14:03 -07:00
Xiaoze Fan 19a60a5b65 perf(moe): fuse sigmoid + selection-bias routing into a triton kernel (#804)
* perf(moe): fuse sigmoid + selection-bias routing into a triton kernel

BREAKING CHANGE: glm_moe_dsa keeps its router selection bias in fp32. An FTW converted by an older build stores it as bf16 and still loads, but routes with the rounded bias; restore it with `scripts/ftw_hotfix.py --repo nvidia/GLM-5.2-NVFP4` or reconvert.

* fix(hotfix): scope the bias restore to GLM-5.2 and drop new router comments
2026-10-22 17:48:21 -07:00
Xiaoze Fan 20d1bfbeb9 ci: auto-label perf, gguf and other topics by title (#808) 2026-10-22 17:36:54 -07:00
cherry77-cloud 7974c9cc8c perf(moe): skip inactive block-fp8 decode routes (#665) 2026-10-22 15:43:34 -07:00
Manish Biswal 00fe83b729 fix(tests): pin host-dependent probes in nvfp4 kernel and graph capture tests (#799)
Signed-off-by: iamanishx <manishbiswal754@gmail.com>
2026-10-22 15:06:25 -07:00
Xiaoze Fan 609191d81f feat(gguf): take image input on Qwen and Gemma-4 GGUF checkpoints from an mmproj (#803)
* feat(gguf): load the vision tower from a llama.cpp mmproj

Qwen3.5 / Qwen3.6 / Qwen3.8 (qwen3vl_merger) and Gemma-4 26B-A4B / 31B (gemma4v) / 12B (gemma4uv) take image input from a separate mmproj file: --mmproj, else one in the model's own folder. The tower runs in bf16 (quantized mmproj files are dequantized) and its config comes from the GGUF metadata plus per-arch defaults.

* docs(gguf): describe mmproj image input without a model list

* test(gguf): drop the mmproj tests

* fix(gguf): escape the model folder when globbing for mmproj files

* fix(gguf): skip auto-discovered mmproj files the text model cannot use

* fix(gguf): serve text from a GGUF that carries vision tensors itself
2026-10-22 14:56:19 -07:00
Xiaoze Fan c63fc133e2 docs: set admission rules for new tests (#796)
* docs: set admission rules for new tests

* docs: tighten the tests README

- list where older model-specific tests sit (flat in models/, subsystem dirs, dsv4/) and add dsv4/ to the table
- say that layer kernels and fused ops go in kernels/, whole layer modules in layers/
- drop the silent-bug examples repeated from the admission list
- keep reusing a file's fixtures only when they are not stand-ins for FreeToken objects
2026-10-22 13:17:44 -07:00
Mukkesh Ganesh 546c5fe2e4 feat(gguf): serve DeepSeek-V4 Flash and Pro GGUF checkpoints on deepseek4 (#774)
* feat(gguf): serve DeepSeek-V4-Flash GGUF checkpoints on deepseek4

* fix(gguf): refuse reap-style per-layer expert prunes in deepseek4 ggufs

* fix(gguf): apply the deepseek4 review fixes

- route the offload experts through swiglu_clamp so the GGUF MoE path applies the limit
- map model.embed -> embed on the HF row so the bf16 exemption matches
- default a wholly missing rope.scaling block to the family yarn values with a warning;
  refuse a partly present one
2026-10-21 18:40:37 -07:00
Xiaoze Fan b10c0c479b docs: add a guide to speeding up prefill with offloaded experts (#785) 2026-10-21 14:28:09 -07:00
Xiaoze Fan 161ffa5a61 perf(moe): scan the hybrid eviction pool in chunks and add fetch rounding modes (#778) 2026-10-21 11:38:13 -07:00
LZ_QAQ cc4aa085b6 fix(moe): enable prefill hit-d2d on rocm (#771)
* fix(kernel): order the batch-memcpy probe against the current stream

Adapt the stream dependency and busy-stream regression from #414
(https://github.com/FlashML-org/FreeToken/pull/414). Warm the JIT
before queuing the backlog so compilation cannot mask the race.

* fix(moe): enable prefill hit-d2d on rocm
2026-10-20 23:15:17 -07:00
LZ_QAQ fe5a5ec9c5 fix(tests): support ROCm in AIME GPU memory checks (#763) 2026-10-20 20:48:55 -07:00
Xiaoze Fan 127aa0a920 chore(release): 0.2.0 (#773) v0.2.0 2026-10-20 17:02:26 -07:00
Xiaoze Fan c5b5b7243a feat(moe): fetch locked-layer experts through pinned staging (#742)
* feat(moe): fetch locked-layer experts through pinned staging and probe the pin limit

Under hybrid, layers whose banks the pin quota could not take keep GPU slots of their own pools and fetch part of their misses through pinned staging that CPU threads fill (--moe-locked-fetch, --moe-locked-max-fetch). --moe-cpu-layers auto without FREETOKEN_PIN_BUDGET_GB now loads the banks unpinned, pins the staging, then pins layers middle-out until CUDA refuses one and OS-locks the rest.

* fix(moe): resize the locked fetch on cache rebuild and gather staging by device address

* feat(moe): log decode moe stats per layer group with --moe-collect-stats

* perf(moe): default the locked fetch to max(2, min(4, logical cpus / 4)) copy threads

* feat(moe): take the locked fetch share from the ft bench bw profile by default

* fix(moe): fuse the locked fetch into publish and gather kernels and address review findings

* refactor(moe): gather the locked staging with fast_index_copy_multi

* refactor(moe): move the locked fetch setup out of the engine and address review findings

* fix(moe): fail the boot when the locked staging cannot be pinned and keep locked layers out of the hybrid share log
2026-10-20 14:59:05 -07:00
Mukkesh Ganesh cc56b6bdcf feat(gguf): serve GLM-5.3-Flash GGUF checkpoints on glm5-next (#721)
* feat(gguf): serve GLM-5.3-Flash GGUF checkpoints on glm5-next

Adds the llama.cpp glm5-next GGUF reader (unsloth GLM-5.3-Flash-GGUF, both
the glm5-next and the older glm5next arch spellings) on the GGUF quant
kind from #690:

- parse_gguf_config derives the text config from the GGUF KV metadata,
  with per-block attention.head_count_kv laying out the KDA/DSA hybrid,
  the trailing MTP block dropped like the HF loader drops it, and the
  MLA head widths from the *_length_mla keys.
- iter_gguf_weights maps every tensor to the glm5_next state dict and
  undoes the converter transforms: A_log stored as -exp(A_log) is
  inverted, the per-head attn_k_b/attn_v_b pair (k transposed) fuses
  into the dense kv_b_proj layout the MLA absorption reads, and the
  q|k|v conv kernels concatenate on the channel axis. The mixed-type
  fused KDA in_proj (Q8_0 q|k|v + BF16 b|f_a|g_a) rides #702 segments;
  the routed experts load as GGUF expert banks at their shipped types
  (unsloth dynamic quants: IQ3_S gate/up + IQ4_XS down, Q8_0 outlier
  layers pass through natively).
- passes quant_config to embed_tokens so the Q8_0 token_embd serves
  packed; registers Glm5NextGGUFForCausalLM and claims it in the AOT
  table.

Verified end to end against unsloth GLM-5.3-Flash-UD-IQ4_XS (5 split
shards): the full engine on a 32GB GPU serves coherent output with the
experts off host banks. Text-only, TP=1.

Part of #671.

* fix(gguf): refuse unread scale tensors in glm5-next ggufs

check_scales at config parse like the llama, qwen3 and gemma4 loaders
(review on #721): a .scale / .input_scale outside an NVFP4 weight now
fails with a clear error instead of loading silently unread.

* fix(gguf): serve the quantized tensors of unsloth dynamic glm5-next quants

unsloth's UD quants quantize tensors the AesSedAI-style files keep float:
the MLA kv_b halves (Q8_0), the mHC mixers and the indexer's wk /
weights_proj / compressor gate. kv_b_proj joins the registry's
unquantized_modules (glm_moe_dsa keeps its kv_b dense for the MLA
absorption for the same reason) and the reader dequantizes through the
vendored gguf-py reference on every float-expecting read; wq_b keeps
serving its checkpoint quant packed (attention.py keeps wk and
weights_proj dense). Regression test stores the kv_b halves Q8_0.

* fix(gguf): treat the glm5 pre-tokenizer spelling like glm4

llama-vocab.cpp maps both spellings to CHATGLM4 with ignore_merges;
unsloth writes glm4 and AesSedAI's writer glm5 for the same vocabulary.
Without the mapping a glm5 file loads but silently mis-tokenizes
(tok_compare: 22,840/153,725 vocab words differ from the HF reference;
0 everywhere with it).

* fix(gguf): size the mmq tail padding by ggml type and k

pad_rows added one zero row of k columns, which covers the bytes MMQ
reads past the last row only when k is at least half a padding unit
(512); glm5-next's KDA f_b / g_b (k = linear head dim 128, Q8_0 in
dynamic quants) are the first packed tensors below that and died at the
first mul_mat. pad_rows now takes the ggml type and returns enough whole
rows to cover mmq_tail_bytes for any (type, k), consistently in the
reader's fused(), the gguf linear and embedding params and the expert
host banks. Found serving the real unsloth UD-IQ4_XS: the dry load
never runs a forward.

* fix(gguf): take the older glm5-next writer variants in stride

Two long-tail writer variants the full check sweep found (the GSQ-RCO
lineage alone is ~57k downloads/month):

- the conv kernels with a trailing unit dim: llama.cpp's glm5-next
  loader tries that 4-D shape before the 3-D one, so trailing unit dims
  in ne are dropped on float reads (they carry no elements).
- attention.head_count_kv as the generic scalar (all blocks): wrong for
  the hybrid -- llama.cpp broadcasts it and then fails tensor creation
  -- so only the list is trusted and a scalar falls to the tensor-name
  census like the pre-list writer.

* fix(gguf): glm5-next review cleanups

- refuse instead of guessing metadata the model cannot express: the
  scalar attention.head_count_kv spelling (llama.cpp broadcasts it and
  then fails tensor creation; every public file carries the list),
  missing *_length_mla keys through need(), non-uniform
  swiglu_clamp_exp / swiglu_clamp_shexp, indexer.types with non-full
  layers, expert_gating_func other than sigmoid, and rope dims as a
  NotImplementedError instead of an assert.
- call check_scales directly; aot_models comment on its own line.
- drop the GGUF test files; coverage will be handled across families.
2026-10-19 23:20:40 -07:00
Your Open Source Tooling Specialist bb15d1d387 fix(server): accept localhost authority in local file URIs (#758)
Resolve the parsed URI path without prepending localhost, while
rejecting non-local authorities and retaining the media root check.
Add regression cases for localhost authority spellings and remote hosts.

Refs FlashML-org/FreeToken#757
2026-10-19 21:40:55 -07:00