Skip to content

Derive CAM HCCL buffer sizes per role - #234

Draft
ShwStone wants to merge 1 commit into
vllm-project:mainfrom
ShwStone:agent/cam-auto-hccl-buffer
Draft

Derive CAM HCCL buffer sizes per role#234
ShwStone wants to merge 1 commit into
vllm-project:mainfrom
ShwStone:agent/cam-auto-hccl-buffer

Conversation

@ShwStone

@ShwStone ShwStone commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • derive independent Attention and FFN CAM HCCL buffer sizes from the model, scheduler, topology, and quantization configuration
  • apply 1.1x headroom through connector-scoped HCCL process-group options for both CAM Async and CAMP2P
  • log each role's selected buffer at startup
  • warn when the memory outside gpu_memory_utilization is less than 2.5x the role-local CAM buffer, without changing the configured utilization
  • preserve the process-wide HCCL_BUFFSIZE setting for unrelated HCCL groups
  • update the CAM Async and CAMP2P guides, launch recipes, and CPU-safe coverage

Motivation

HCCL_BUFFSIZE is process-wide, so increasing it for CAM also enlarges unrelated TP, DP, PCP, or EP communication buffers. The derived size is now scoped to connector-owned HCCL process groups. HCCL_BUFFSIZE is neither overwritten nor unset, so users can still tune other HCCL groups intentionally.

The derived requirements are:

tokens_per_npu = ceil(max_num_batched_tokens / num_npus_per_dp_group)
attention_bytes = 2 * hidden_size * tokens_per_npu * (topk + 1)
ffn_bytes = num_attention_ranks * (6176 if dynamic quantization else 12288) * tokens_per_npu
role_buffer_mb = ceil(1.1 * role_bytes / 1_MiB)

The FFN formula intentionally has no topk + 1 multiplier. num_npus_per_dp_group describes the total NPU count within one Attention DP group; the currently supported topology realizes that dimension with TP.

Validation

  • uv run --locked ruff check .
  • uv run --locked ruff format --check .
  • uv run --locked pytest -q tests/unit -m 'not gpu and not vllm_runtime'
  • python3 -m compileall -q afd_plugin tests
  • bash -n recipe/npu/CAMAsyncAFDConnector/deepseek_v3_2/v0_26_accuracy/attention_dp2tp8.sh recipe/npu/CAMAsyncAFDConnector/deepseek_v3_2/v0_26_accuracy/ffn_ep16.sh recipe/npu/CAMP2pAFDConnector/deepseek_v3_2/afd_attention.sh recipe/npu/CAMP2pAFDConnector/deepseek_v3_2/afd_ffn.sh
  • git diff --check

NPU end-to-end validation is still pending.

CAM_BUFFER_SAFETY_FACTOR_DENOMINATOR = 10
CAM_MEMORY_RESERVE_FACTOR_NUMERATOR = 5
CAM_MEMORY_RESERVE_FACTOR_DENOMINATOR = 2
HCCL_BYTES_PER_MB = 1024 * 1024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BYTES_PER_MB is kind of stupid

Comment thread afd_plugin/connectors/npu/async_cam.py Outdated
logger = init_logger(__name__)


def derive_async_cam_hccl_buffer_plan(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this hccl-buffer auto planning should not just use for Async. pls impl for both async & p2p

@ShwStone
ShwStone force-pushed the agent/cam-auto-hccl-buffer branch from 5b88ed6 to e49bc17 Compare August 13, 2026 02:16
Signed-off-by: ShwStone <haowenshi@outlook.com>
@ShwStone
ShwStone force-pushed the agent/cam-auto-hccl-buffer branch from e49bc17 to 68af65c Compare August 13, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant