[Bug]: cumem_tag sleep/wake corrupts cross-rank PP broadcast (TP+PP, varied prompts) → cudaErrorIllegalAddress

在 vLLM 中启用 --sleep-mode-backend=cumem_tag ,配置 TP=2, PP=2(4 个 worker)部署,使用 AWQ-INT4 量化模型(如 cyankiwi/Qwen3.6-27B-AWQ-BF16-INT4 ),通过 /sleep 和 /wake_up 接口

[Bug]: cumem_tag sleep/wake corrupts cross-rank PP broadcast (TP+PP, varied prompts) → cudaErrorIllegalAddress

[Bug]: cumem_tag sleep/wake corrupts cross-rank PP broadcast (TP+PP, varied prompts) → cudaErrorIllegalAddress

快速结论:该报错在启用 --sleep-mode-backend=cumem_tag 且使用 TP=2, PP=2 配置时触发,当不同 prompt 绕过 prefix cache 强制触发完整 prefill 时,约 5 个 sleep/wake 周期后必然出现 cudaErrorIllegalAddress。优先排查是否使用了 cumem_tag 后端,并回退到默认 cumem 后端作为临时方案。

问题场景

在 vLLM 中启用 --sleep-mode-backend=cumem_tag,配置 TP=2, PP=2(4 个 worker)部署,使用 AWQ-INT4 量化模型(如 cyankiwi/Qwen3.6-27B-AWQ-BF16-INT4),通过 /sleep/wake_up 接口进行约 5 个周期的 sleep/wake 操作,且每次使用不同的 prompt(迫使执行完整 prefill)时触发。

报错原文

cudaErrorIllegalAddress
Raised by Worker_PP0_TP1 and Worker_PP1_TP1 inside _pp_receive_prev_sampled_token_ids_to_input_batch at the cross-rank torch.distributed.broadcast(...) call

cumem_allocator.cpp:235 CUDA Error: invalid argument

EngineCore: No available shared memory broadcast block found in 60 seconds

原因分析

根本原因是 cumem_tag 后端在 sleep/wake 过程中,跨 PP rank 的 torch.distributed.broadcast 通信路径存在竞态条件。具体表现为:

  • 当 prefix cache 命中时(固定 prompt),_is_all_reqs_chunked_prefill() 会短路 broadcast 调用,因此不会触发该 bug。
  • 当使用不同 prompt 时,强制完整 prefill,暴露了 broadcast 路径上的数据损坏。
  • 该 bug 仅出现在 TP>1 且 PP>1 的跨 rank PP 路径,TP=1, PP=1 时不会复现。

环境排查

  • vLLM 版本:上游 main 分支(commit gc585e86e7,0.1.dev1+)
  • CUDA / PyTorch:需确认运行时的 CUDA 版本和 PyTorch 版本(Issue 中未指定具体版本号)
  • 显卡:4× NVIDIA RTX 3090 (24 GiB, sm_86),单节点,NVLink 关闭
  • 启动参数:确认是否包含 --tensor-parallel-size 2 --pipeline-parallel-size 2 --sleep-mode-backend cumem_tag --enable-sleep-mode
  • 其他相关参数:--kv-cache-dtype fp8 --enable-prefix-caching --enable-chunked-prefill --max-model-len 262144 --gpu-memory-utilization 0.7 --max-num-batched-tokens 16384 --max-num-seqs 8 --disable-custom-all-reduce
  • NCCL 环境变量:NCCL_P2P_LEVEL=NVL NCCL_P2P_DISABLE=0 NCCL_IB_DISABLE=1

解决步骤

  1. 临时工作区(立即生效):移除 --sleep-mode-backend=cumem_tag 启动参数,回退到默认 cumem 后端。wake 延迟会从 ~1.3s 增加到 5-15s,但不会触发 PP broadcast 损坏。
  2. 应用上游修复补丁(确认已 merge):
    • PR #45552:在 cumem.py 中,在 unmap 之前和 wake 时各增加一次 torch.cuda.synchronize(),修复单 rank 竞态。
    • PR #45554:在 CuMemAllocator._quiesce_distributed_before_vmm_mutation 中,通过 gloo barrier 进行跨 rank 协调。
  3. 可优先尝试的防御性措施:
    • /sleep 前增加 drain barrier(等待正在处理的请求完成,超时返回 503)。
    • /wake_up 后增加 settle barrier(等待 2s 后再接受 /sleep 请求)。
  4. 完全恢复方法:docker rm -f vllm-main 删除容器后重新创建。

验证方法

应用修复后,使用 varied prompts(不同 prompt)执行至少 10 个 sleep/wake 周期,监控:

  • cudaErrorIllegalAddress 报错
  • /health 不返回 200 状态码的假阳性
  • /is_sleeping 不挂起
  • 推理结果正确(inference_ok 为 ✅)

同时使用 fixed prompt 验证 prefix cache 短路路径不会退化(预期 20+ 周期无故障)。

参考来源

vllm-project/vllm #45519

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 7496

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注