fix: reorder Dockerfile ARG before COPY for proper cache busting

This commit is contained in:
2026-05-11 18:48:07 +00:00
parent c4891e9ee2
commit 8ae2214bad
2 changed files with 11 additions and 8 deletions

View File

@@ -18,11 +18,10 @@ ENV PYTHONPATH="/root/DeepGEMM:${PYTHONPATH}"
RUN ln -sf /usr/local/lib/python3.12/dist-packages/nvidia/cu13/lib/libnvrtc.so.13 /usr/local/cuda/lib64/libnvrtc.so
RUN cd /root/DeepGEMM && python3 setup.py build_ext --inplace
# Bust cache for patch changes — ARG before COPY ensures layer invalidation
ARG PATCH_CACHE_BUSTER=26
# Copy our DeepSeek V4 patch over vLLM's model file
COPY patches/deepseek_v4.py /usr/local/lib/python3.12/dist-packages/vllm/model_executor/models/deepseek_v4.py
# Bust cache for patch changes
ARG PATCH_CACHE_BUSTER=24
RUN echo "Patch cache buster: $PATCH_CACHE_BUSTER" > /dev/null
# Verify everything imports
RUN python3 -c "import deep_gemm; print('DeepGEMM NVFP4 OK')" && \

View File

@@ -323,11 +323,15 @@ def _deepseek_v4_stage_mega_moe_inputs_kernel(
# Reconstruct the dequantized scale for FP8 activation quantization
# UE4M3 dequant: if exp == 0: value = (mant/8) * 2^(1-7) = (mant/8) * 2^-6
# else: value = (1 + mant/8) * 2^(exp-7)
e4m3_value = tl.where(
e4m3_exp == 0,
(e4m3_mant.to(tl.float32) / 8.0) * (2.0 ** -6),
(1.0 + e4m3_mant.to(tl.float32) / 8.0) * (2.0 ** (e4m3_exp.to(tl.float32) - 7.0))
)
# Use bit manipulation: 2^n = (n+127) << 23 reinterpreted as float32
e4m3_exp_for_recon = tl.maximum(e4m3_exp.to(tl.int32) - 7, -126)
# For exp=0 (subnormal): already handled separately
# For normal: (1 + mant/8) * 2^(exp-7)
two_pow_exp_bits = (e4m3_exp_for_recon + 127).to(tl.uint32) << 23
two_pow_exp = two_pow_exp_bits.to(tl.float32, bitcast=True)
normal_value = (1.0 + e4m3_mant.to(tl.float32) / 8.0) * two_pow_exp
subnormal_value = (e4m3_mant.to(tl.float32) / 8.0) * 0.015625 # 2^-6
e4m3_value = tl.where(e4m3_exp == 0, subnormal_value, normal_value)
hidden_groups_f = tl.reshape(hidden, [num_groups, GROUP_K])
scaled = hidden_groups_f * (1.0 / tl.maximum(e4m3_value, 1e-6))[:, None]