Continue the prefill-only investigation for /user_4813494d/openbmb. Do NOT discuss speculative decoding/EAGLE/decode. Focus on a roofline-like bottleneck analysis of current prefill: MLP FP4 GEMM, GLA chunk path, sparse stage1, sparse stage2, host/CUDA API overhead, memory traffic, per-chunk scaling from 128K to 524K. Use local docs/code/bench assets. Return quantitative hypotheses and experiments. Do not edit files.
Assistant
I’ll inspect the current worktree and local prefill/bench assets, then distill a roofline-style set of bottleneck hypotheses with concrete measurements to run. I’ll keep this strictly on prefill and avoid unrelated paths.
Assistant
The tree is dirty, so I’m treating it as read-only. I found the prefill docs plus kernel bench material; next I’m narrowing to the current writeups, runner scripts, and the MiniCPM attention/GLA/FP4 call sites that define the actual path.
Assistant
The current docs already separate microbench time from wall time: MLP full chunks are around 133 ms/chunk, GLA around 96 ms/chunk after fused ops, sparse second stage about 80 ms/chunk, with earlier nsys showing large host/API gaps. I’m checking the code to map those numbers to actual kernels and guards.
Assistant
I’m not going to run long GPU jobs in this pass. The useful output here is a test matrix: separate fixed-per-8192-token costs from the one term that grows with accumulated context, then verify it with the existing profile buckets and microbench scripts.
Assistant
No files edited. I used the local prefill docs, MiniCPM code path, and bench scripts.
Roofline Model
Current 8192-token chunk costs are roughly:
Component
128K / 16 chunks
524K / 64 chunks
Scaling
MLP FP4 GEMM
~2.1s
~8.5s
linear
GLA path
~1.5s
~6.1s
linear
sparse stage2
~1.3s
~5.4s
linear
sparse stage1
~0.7s
~10.8s
quadratic over chunks
GPU-ish subtotal
~5.7s
~30.8s
mixed
Expected wall: ~6.8-7.5s at ~128K, ~35-45s at 524K if host/API overhead stays similar. The key scaling risk is sparse stage1: terminal chunk grows from ~83ms at 128K to ~332ms at 524K.
Quantitative Hypotheses
MLP FP4 GEMM is register/occupancy limited, not HBM limited. Existing nsys notes show NVFP4 CUTLASS at 168 regs/thread, ~19% occupancy. The high-value MLP target is not cuDNN backend switching; it is eliminating the BF16 gate/up materialization. Current path writes a 512MB BF16 intermediate per layer at full chunk, then rereads it for SwiGLU+FP4 quant. Plausible gain: 15-30ms/chunk, or ~1-2s over 524K.
GLA has little simple headroom left. Current docs show GLA cumulative improvement to ~96ms/chunk, with chunk_simple_gla lower bound around 27.6ms/chunk and already bandwidth-bound. Plausible remaining simple-tuning gain: <1% wall. Larger gains require layout/kernel redesign, not flags.
Sparse stage2 is memory/indirection plus register limited. Production shape is ~16K row-wise virtual batches, topk 96 x 64 = 6144 KV tokens per row, bf16 KV. Current per sparse layer is ~9.8-10.3ms, 8 layers ~84ms/chunk. Low-register FlashInfer variant remains a plausible 3-5% wall hypothesis; page64 and two-wrapper variants already failed to cross wall-clock noise.
Sparse stage1 becomes the long-context bottleneck. Using the 131K calibration of ~10.38ms/layer, stage1 total rises ~15x from 128K to 524K. At 524K it likely exceeds MLP as a single component. The only promising direction is an exact fused stage1 pipeline: score -> pool -> topk, avoiding full score materialization where semantics allow.
Host/CUDA API overhead is still material at 128K. Prior nsys showed only ~40% GPU busy in a 5s window, with large cudaGraphInstantiateWithFlags, sync, and lazy library load costs. At 524K, GPU work grows enough that the percentage should fall, but absolute overhead can still add several seconds over 64 chunks.
Use profile buckets for one long request at ~128K and one from bench/data_full near 524K. Compare per chunk: mlp_gate_up_ms, mlp_swiglu_fp4_quant_ms, mlp_down_fp4_quantized_ms, gla_*, stage1_score_prefill_ms, extend_sparse_fa_ms, fi_direct_topk_indices_ms.