12-v1_attention_backend.py.diff 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --- baked-ours/v1/attention/backend.py 2026-09-10 19:56:14.000000000 +0200
  2. +++ baked/v1/attention/backend.py 2026-09-11 10:13:47.000000000 +0200
  3. @@ -611,6 +611,26 @@
  4. self.vllm_config = vllm_config
  5. self.device = device
  6. self.kernel_block_size: int | None = None
  7. + # The DCP geometry this builder's group actually runs at: sharded
  8. + # groups use the process DCP size; DCP-replicated groups (every rank
  9. + # holds the full KV) behave as dcp=1 for metadata purposes.
  10. + from vllm.v1.kv_cache_interface import is_dcp_replicated_spec
  11. +
  12. + process_dcp_size = vllm_config.parallel_config.decode_context_parallel_size
  13. + self.dcp_replicated = is_dcp_replicated_spec(kv_cache_spec)
  14. + if process_dcp_size > 1 and not self.dcp_replicated:
  15. + from vllm.distributed.parallel_state import get_dcp_group
  16. +
  17. + try:
  18. + self.dcp_world_size = get_dcp_group().world_size
  19. + self.dcp_rank = get_dcp_group().rank_in_group
  20. + except AssertionError:
  21. + # DCP group not initialized (unit tests).
  22. + self.dcp_world_size = process_dcp_size
  23. + self.dcp_rank = 0
  24. + else:
  25. + self.dcp_world_size = 1
  26. + self.dcp_rank = 0
  27. def set_kernel_block_size(self, kernel_block_size: int) -> None:
  28. self.kernel_block_size = kernel_block_size
  29. @@ -650,10 +670,7 @@
  30. max_num_queries_for_spec,
  31. )
  32. - if (
  33. - self.vllm_config.parallel_config.decode_context_parallel_size > 1
  34. - and not supports_dcp_with_varlen
  35. - ):
  36. + if getattr(self, "dcp_world_size", 1) > 1 and not supports_dcp_with_varlen:
  37. self.reorder_batch_threshold = 1
  38. @abstractmethod