fix(qwen4_exp): fix nvfp4 ftw weight loading, qsa indexer, and ple tables - #293
fix(qwen4_exp): fix nvfp4 ftw weight loading, qsa indexer, and ple tables#2933Simplex wants to merge 1 commit into
Conversation
|
Data point from a different checkpoint and a card nobody has reported yet, in case it helps scope which of these hacks are FTW-specific: the standard (non-FTW) NVFP4 checkpoint loads and serves at Environment: FreeToken git
So on sm_86 with the Triton NVFP4 path the loader, indexer and PLE init are fine for the compressed-tensors layout; the FTW checkpoint's flat |
I wanted to post this as a reference of the hacks needed to run oakmindai/Qwen3.8-Flash-Next-NVFP4-FTW which were generated by Gemini 3.7 flash.
Summary
Fixes weight loading, tensor layout mismatches, and host table initialization when running
Qwen3.8-Flash-Next-NVFP4-FTW(andQwen4Exphybrid models) from FTW checkpoints.Key Changes
python/freetoken/models/qwen4_exp/gdn.py:out_projasLinearReplicatedto match unquantized BF16 weights in NVFP4 checkpoints where linear attention is excluded from quantization (quantization_config['ignore']).python/freetoken/models/qwen4_exp/attention.py:load_state_dict()inQwen4ExpIndexerto resolve checkpoints storing indexer weights flat underself_attn.index_*(e.g.index_qk_proj.weight,index_q_norm.weight) in addition to nestedself_attn.indexer.*.python/freetoken/engine/engine.py:_load_weight_state_dictto concatenate and 16-row pad separateinput_mix_weight_down.weightandblock_inject_weight.weighttensors intoinput_mix_weight_down_block_inject.weightwhen loading FTW checkpoints.python/freetoken/models/qwen4_exp/ple.py&model.py:load_state_dict()override toNGramEmbeddingso derived hashing metadata is not strictly expected in dense checkpoint state dicts..copy_()onto meta tensors with direct CUDA int64 tensor initialization usingtorch.cuda.current_device().NGramEmbedding.row_ids().python/freetoken/models/qwen4_exp/weight.py:load_ple_table()for unifiedqwen4_ngram.bin+qwen4_ngram.jsonfiles.FREETOKEN_ZERO_PLE=1environment variable support allowing systems without 100+ GB of host RAM to attachZeroTable.Test Environment
Hardware Bandwidth Benchmarks (
ft bench bw --dtype nvfp4)Generation Benchmark (
ft serve/ OpenAI API)oakmindai/Qwen3.8-Flash-Next-NVFP4-FTWqsa_sparseattention +offloadMoEFREETOKEN_ZERO_PLE=1 ft serve --max-running-req 1 --cuda-graph-max-bs 1Verification Checklist
KAT-Coder-V2.5-Dev-FTW(clean graph capture and generation).oakmindai/Qwen3.8-Flash-Next-NVFP4-FTW.ft shelland APIft serve.Environment Details (Auto-detected)