patch_vllm_preserve_sm12x_target.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python3
  2. """Preserve explicitly selected CUDA 13 Blackwell subarchitecture targets."""
  3. import os
  4. import sys
  5. from pathlib import Path
  6. if os.environ.get("VLLM_PRESERVE_SM12X_TARGET", "") not in {
  7. "1",
  8. "true",
  9. "TRUE",
  10. "yes",
  11. "YES",
  12. }:
  13. print("Blackwell target preservation not requested; skipping")
  14. raise SystemExit(0)
  15. source_root = Path(sys.argv[1]) if len(sys.argv) > 1 else Path.cwd()
  16. target = source_root / "CMakeLists.txt"
  17. cuda13_default = (
  18. 'set(CUDA_SUPPORTED_ARCHS '
  19. '"7.5;8.0;8.6;8.7;8.9;9.0;10.0;11.0;12.0")'
  20. )
  21. cuda13_sm121 = (
  22. 'set(CUDA_SUPPORTED_ARCHS '
  23. '"7.5;8.0;8.6;8.7;8.9;9.0;10.0;11.0;12.0;12.1")'
  24. )
  25. cuda13_subarchitectures = (
  26. 'set(CUDA_SUPPORTED_ARCHS '
  27. '"7.5;8.0;8.6;8.7;8.9;9.0;10.0;10.3;11.0;12.0;12.1")'
  28. )
  29. text = target.read_text()
  30. if cuda13_subarchitectures in text:
  31. print("CUDA 13 Blackwell subarchitecture allow-list already present; skipping")
  32. elif text.count(cuda13_sm121) == 1:
  33. target.write_text(text.replace(cuda13_sm121, cuda13_subarchitectures, 1))
  34. print("Enabled selected SM103 and SM12x targets for CUDA 13 vLLM build")
  35. elif text.count(cuda13_default) == 1:
  36. target.write_text(text.replace(cuda13_default, cuda13_subarchitectures, 1))
  37. print("Enabled selected SM103 and SM12x targets for CUDA 13 vLLM build")
  38. else:
  39. raise SystemExit(
  40. "Unable to preserve the selected Blackwell target: expected CUDA 13 "
  41. "CUDA_SUPPORTED_ARCHS entry was not found exactly once"
  42. )