Dockerfile 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # syntax=docker/dockerfile:1.7
  2. # DeepSeek-V4-Flash-0731 — eugr/spark-vllm-b12x overlay with the
  3. # instanttensor-hybrid-draft-loader mod baked in.
  4. #
  5. # Base: eugr/spark-vllm-b12x — the prebuilt b12x-branch image published in
  6. # NVIDIA forum comment #28 (https://forums.developer.nvidia.com/t/376220/28).
  7. # Ubuntu 24.04 + system Python 3.12; vLLM is installed into the system
  8. # site-packages (the mod's default /usr/local/lib/python3.12/dist-packages,
  9. # but the path is resolved dynamically below so this is robust to a moved
  10. # install).
  11. #
  12. # eugr's recipe applies `mods/instanttensor-hybrid-draft-loader` at
  13. # run-recipe.sh time (it patches vLLM's model_loader get_model() to keep
  14. # InstantTensor for the target while letting an embedded MTP/dspark draft
  15. # use lazy safetensors). sm121 has no runtime mod-upload step for Docker
  16. # recipes, so this overlay bakes the patch in at build time instead: the
  17. # running container already has the hybrid loader, and the recipe carries
  18. # no [mods] block.
  19. #
  20. # Build safety: the patcher refuses to patch an incompatible module (it
  21. # anchors on vLLM's exact get_model signature and self-compiles the result).
  22. # If a future eugr image bumps vLLM and that signature changes, `docker
  23. # build` fails here instead of silently shipping an unpatched image.
  24. #
  25. # Build: cd docker-images/deepseek-v4-flash-eugr && bash build.sh
  26. # (the sm121 launcher builds on demand and stamps sm121.checksum)
  27. FROM eugr/spark-vllm-b12x
  28. # Vendor the mod's patcher (vendored from eugr/spark-vllm-docker b12x branch,
  29. # mods/instanttensor-hybrid-draft-loader/patch_model_loader.py) so the build is
  30. # self-contained and the file is folded into the sm121 build checksum.
  31. COPY patches/patch_model_loader.py /tmp/patch_model_loader.py
  32. # Resolve the model_loader module path from Python itself (do not hardcode the
  33. # dist-packages prefix), then check -> apply -> check, matching the mod's run.sh.
  34. RUN set -eux; \
  35. TARGET="$(python3 -c 'import vllm, os; print(os.path.join(vllm.__path__[0], "model_executor/model_loader/__init__.py"))')"; \
  36. python3 /tmp/patch_model_loader.py --check "$TARGET"; \
  37. python3 /tmp/patch_model_loader.py "$TARGET"; \
  38. python3 /tmp/patch_model_loader.py --check "$TARGET"; \
  39. find "$(dirname "$TARGET")" -name '__pycache__' -type d -prune -exec rm -rf {} + 2>/dev/null || true; \
  40. rm -f /tmp/patch_model_loader.py
  41. # Minimal reasoning_effort (low/high/max) support for the vendored deepseek_v4
  42. # tokenizer. Applies only the required edits on top of whatever eugr ships
  43. # (keeps all of eugr's own logic; does NOT replace the files with the 0731
  44. # variant). See patches/patch_deepseek_v4_effort.py.
  45. COPY patches/patch_deepseek_v4_effort.py /tmp/patch_deepseek_v4_effort.py
  46. RUN set -eux; \
  47. python3 /tmp/patch_deepseek_v4_effort.py --check; \
  48. python3 /tmp/patch_deepseek_v4_effort.py; \
  49. python3 /tmp/patch_deepseek_v4_effort.py --check; \
  50. find "$(python3 -c 'import vllm, os; print(os.path.join(vllm.__path__[0], "tokenizers"))')" -name '__pycache__' -type d -prune -exec rm -rf {} + 2>/dev/null || true; \
  51. rm -f /tmp/patch_deepseek_v4_effort.py
  52. # Optional: read the newer `reasoning_content` message key instead of the
  53. # deprecated `reasoning` key. DEFAULT-OFF — the first-test variant stays the
  54. # pure reasoning_effort change above. Turn on at runtime with
  55. # VLLM_DSV4_REASONING_CONTENT=1 (recipe [env] / -e); or comment this block to
  56. # remove entirely. See patches/patch_deepseek_v4_reasoning_content.py.
  57. COPY patches/patch_deepseek_v4_reasoning_content.py /tmp/patch_dsv4_rc.py
  58. RUN set -eux; \
  59. python3 /tmp/patch_dsv4_rc.py --check; \
  60. python3 /tmp/patch_dsv4_rc.py; \
  61. python3 /tmp/patch_dsv4_rc.py --check; \
  62. find "$(python3 -c 'import vllm, os; print(os.path.join(vllm.__path__[0], "tokenizers"))')" -name '__pycache__' -type d -prune -exec rm -rf {} + 2>/dev/null || true; \
  63. rm -f /tmp/patch_dsv4_rc.py