【Hackathon 10th Spring No.50】为 FastDeploy 新增 MiniCPM4.1-8B 模型 - #8118
Open
codecason wants to merge 1 commit into
Open
【Hackathon 10th Spring No.50】为 FastDeploy 新增 MiniCPM4.1-8B 模型#8118codecason wants to merge 1 commit into
codecason wants to merge 1 commit into
Conversation
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.
Motivation
为 MiniCPM4.1-8B 增加完整的 FastDeploy 支持,包括模型架构、混合推理、在线权重量化和长上下文注意力路径。
本实现使用原始 Hugging Face BF16 checkpoint,支持 BF16、在线 WINT4 和在线 WINT8 部署。同时新增 InfLLM-V2 注意力后端与 CUDA 算子,用于在支持的 NVIDIA GPU 上验证长上下文推理。
关联 RFC PR:
PaddlePaddle/community#1318。
PaddlePaddle/community#1543。
Modifications
Usage or Command
在终端配置:
一次性执行编译、单元测试、CUDA 算子测试和端到端测试:
也可以分别执行各阶段:
启动在线 WINT4 Serving:
bash scripts/run_minicpm41_wint_server.sh wint4 "${MODEL_PATH}"将
wint4替换为wint8即可启用在线 INT8 权重量化。Accuracy Tests
使用原始
openbmb/MiniCPM4.1-8Bcheckpoint,在单张 NVIDIA RTX A6000(SM86)上完成验证:pre-commit:passed。Performance Tests
以下结果于 2026 年 8 月 25 日在单张 NVIDIA RTX A6000(SM86,TP=1)上测得。所有模式均使用原始 MiniCPM4.1-8B BF16 checkpoint,配置为
max_model_len=1024、max_num_seqs=1、max_num_batched_tokens=256、关闭 prefix caching,并固定 32 个 GPU KV-cache blocks。Serving benchmark 在并发数 1 下发送 16 个随机请求,名义输入/输出长度为 128/64 token。所有模式完成相同的 2,895 个输入 token 和 1,010 个输出 token。
E2E 加速比为“量化模式输出吞吐 / BF16 输出吞吐”。显存压缩比为“BF16 驻留显存 / 量化模式驻留显存”,并保持相同的 KV cache 配置。估算参数存储根据 safetensors 元数据计算,包含未量化的 BF16 权重与持久化 BF16 scales。
在线量化将 worker 启动时间从 BF16 的 25.41 秒增加到 WINT4 的 27.41 秒和 WINT8 的 28.09 秒。
InfLLM-V2 Attention 算子加速比
Attention 加速比统一按“Dense Attention 延迟 / InfLLM-V2 完整链延迟”计算,大于 1 表示 InfLLM-V2 更快。Prefill 与 Decode 的执行路径和实验设置不同,因此分别报告。
Prefill Attention
实验设置:独占 NVIDIA RTX A6000(SM86),batch 1、BF16 Q/K/V 与 KV cache,生产形状
QH=32、KVH=2、D=128、block_size=64。InfLLM-V2 设置为dense_len=8192、selected_blocks=96、query_tile_size=128、query_chunk_size=4096;预热 20 次并执行 100 次 CUDA event 计时,取中位数。Dense 侧测量完整 FlashAttention prefill;InfLLM-V2 侧包含 compressed-K 更新、dense prefix、Stage 1、paged-cache gather、两个 FlashAttention 分区和 LSE 合并。Checklist
[FDConfig],[APIServer],[Engine],[Scheduler],[PD Disaggregation],[Executor],[Graph Optimization],[Speculative Decoding],[RL],[Models],[Quantization],[Loader],[OP],[KVCache],[DataProcessor],[BugFix],[Docs],[CI],[Optimization],[Feature],[Benchmark],[Others],[XPU],[HPU],[GCU],[DCU],[Iluvatar],[Metax]]pre-commit。develop,不适用release分支 Cherry-Pick 要求。