Full Post Body
Environment
- GPU: Tesla V100 32GB (SM70)
- Stack: Custom LLM inference engine xLLM, Q4_K quantized FFN fused CUDA kernels
- Role: Independent Researcher, self-maintained inference framework with 70+ repos & 900+ commits
1. Experiment Result: Discontinued ffn_down raw Q4_K fusion patch
I tested standalone raw-Q4_K caching for ffn_down and rolled back all related patches, as the overall latency regresses against the existing gate-up-SiLU 3-in-1 fused kernel.
- Standalone ffn_down optimization: reduces single ffn_down runtime from ~153ms → 137ms
- Major downside: enabling ffn_down raw cache disables gate-up-SiLU fusion;
ffn_gate_uplatency jumps from ~206ms → 318ms - Full split sweep best config:
g=26 d_start=16, TPOT = 12.19ms - Baseline stable config (
gate_up_siluwith raw cache cap=64): TPOT = 11.96ms
Conclusion: Under the 64 raw tensor safety cache limit for V100 32GB VRAM, the minor speedup of ffn_down quantization cannot offset severe performance loss on gate/up layers. We will not retain this optimization path.
2. Low-overhead performance fix: Cache static cudaGetDeviceProperties value
Profiling via Nsight Systems identified redundant device property lookup inside nxt_paged_attention_v2():
- Hot call count: 1152 invocations (36 transformer layers × 32 decode steps)
- Root cause:
cudaGetDeviceProperties(&prop, 0)executed on every kernel launch - Fix: Cache
sharedMemPerBlockas a static global value once at initialization; all numeric computation paths remain unchanged.
Full Validation Results
-
Build & code quality
cmake --build build_cuda -j4: Passgit diff --check: Pass
-
Functional correctness
test_q4k_gate_up_silu 5: Passtest_engine_correctness: 4/4 unit tests passedcompute-sanitizer --tool memcheck: ERROR SUMMARY = 0- Deterministic batch text output comparison: fully identical pre/post patch
-
Benchmark performance
- Before patch: 71.34 tok/s, TPOT = 9.66 ms
- After static cache patch: 73.03 tok/s, TPOT = 9.66 ms
-
Profiling confirmation
Nsight Systems CUDA API summary verifies
cudaGetDevicePropertiescalls are completely eliminated from decode hot paths.
Code Change Scope
Only single-file modification pending commit:
operators/page_attention_v2.cu | 16 lines modified (+/-)