Sign up Log in
n/ai · 27d ago · 222 views
u/user80MasterDiamond member
n/aiu/user80 Diamond member · 27d ago

Some explorations in self-hosting DeepSeek

Built an inference framework:
The official tilelang code has been replaced with a homegrown torch + HIP implementation, and end-to-end validation passes on a small model (5 layers / 1024 dims).
Speed comparison (same small model):

Before Now Speedup
prefill(128) 515 ms 66 ms 7.8×
decode(1) 362 ms 40 ms 9.1×

Homegrown HIP kernels (quant.hip / fused.hip, gfx906, loaded via ctypes):
: act_quant, fp4_act_quant, fp8/fp4 GEMM (matrix-vector, decode path), RMSNorm, RoPE, SwiGLU, Sinkhorn, hc_mixes, hc_pre/hc_post, sparse_attn. The quant kernels are 4–38× faster than torch; the rest are bit-exact or only differ by bf16 rounding.

Right now decode is CPU-bound (the GPU sits idle most of the time): it used to be ~100ms CPU / 33ms CUDA. I've gotten it down to ~21ms CPU by doing MoE dispatch sort-and-group, a single sync, and fused kernels. The remaining overhead is torch's per-operator

model-00048-of-00048.safetensors: 5%|▍ | 5.07G/102G [04:39<1:23:33, 19.2MB/s]

model-00048-of-00048.safetensors: 5%|▍ | 5.08G/102G [04:39<1:24:48, 19.0MB/s]47
381G /AI/DeepSeek-V4.1-Flash-1017/
But the model itself is still downloading

47/48 shards are in place (381GB), the last one 00048 (102GB) is at 12% and will finish in about 1.2 hours.
Only then can I do real inference testing

Translated by AI from 简体中文

2
2
Log into join the discussion.

2 replies

Sort order
  1. superai Silver 27d ago

    量化都会让模型变笨。要是能跟 GPT-4 打,那就会有市场。

    Translated by AI from 简体中文

    0
  2. user80 Master OP Diamond member 27d ago

    That's putting it too absolutely. Quantization can indeed cause precision loss, but how much depends on the quantization format, calibration method, operator implementation, and the model itself. You can't judge how much model capability drops just from the fact that FP4 or FP8 is being used....

    FP8 is pretty much the industry standard, and from human perception there's no noticeable difference.

    Translated by AI from 简体中文

    0