[distributed] batch_isend_irecv Compatibility Issue on B60/XCCL
@zhangxiaoli73 is already working on this.
Since Mar 11, 2026.
- Dominant language
- Python
- Stars
- 113
- Forks
- 129
- Avg merge
- 5d 9h
- Merged PRs (30d)
- 112
Description
🐛 Describe the bug
Problem Description
On Intel Arc Pro B60 with XCCL backend, torch.distributed.batch_isend_irecv(P2POp(...))
causes silent data corruption on the receive side (all-zeros or garbage data), while
individual dist.irecv / dist.isend calls work correctly.
Symptoms
- sglang-diffusion in USP mode (tp=1, ulysses=4) generates completely black videos
- TP mode (tp=4, ulysses=1) works normally
- Denoising stage latent data is correct; the issue appears in VAE parallel decoding
- VAE parallel decoding uses height-dimension sharding + halo exchange; halo exchange is called in every convolution layer
batch_isend_irecvcauses halo data transfer failure, convolution output errors, and ultimately all-black VAE output
Root Cause
The halo_exchange function was changed from individual irecv/isend to
batch_isend_irecv(P2POp(...)) after commit 574aa8c1f. This API does not work
correctly on the XCCL backend.
Current walk around
In wan_dist_utils.py's halo_exchange, check the platform via current_platform.is_xpu():
use individual irecv/isend on XPU, and batch_isend_irecv on other platforms.
Affected Locations in Codebase
| File | Function | Purpose | Status |
|---|---|---|---|
python/sglang/multimodal_gen/runtime/models/vaes/parallel/wan_dist_utils.py |
halo_exchange() |
Wan VAE parallel decoding halo exchange | Fixed |
python/sglang/multimodal_gen/runtime/distributed/group_coordinator.py |
PipelineGroupCoordinator._communicate_shapes() |
Pipeline Parallel inter-stage shape communication | To be fixed (triggered when pp>1) |
python/sglang/srt/eplb/expert_location_updater.py |
expert rebalance P2P | LLM-side MoE expert load balancing | Non-diffusion path |
Reproduction Test
# Run on XPU (4 GPUs)
torchrun --nproc_per_node=4 test_batch_isend_irecv.py
# Or use mpirun
mpirun -np 4 python test_batch_isend_irecv.py
# Test different dtypes
torchrun --nproc_per_node=4 test_batch_isend_irecv.py --dtype bfloat16
Expected results:
- Test 1 (individual basic): PASS
- Test 2 (batch basic): FAIL (on XPU/XCCL)
- Test 3 (halo individual): PASS
- Test 4 (halo batch): FAIL (on XPU/XCCL)
Environment
- Container image: intel/llm-scaler-omni:0.1.0-b6
- PyTorch: 2.9.0+xpu
- oneAPI: 2025.1
- oneCCL: 2021.15.6
- Platform: Intel Arc Pro B60 × 4
- Distributed backend: XCCL (PyTorch XPU distributed)
- CCL environment variables:
CCL_SYCL_ALLTOALL_ARC_LL=1CCL_SYCL_CCL_BARRIER=1
- Model: Wan2.1-T2V-1.3B-Diffusers (reproduced in USP mode)
- sglang-diffusion branch: xpu_0122
Reproduce Script
"""
Minimal reproduction script for batch_isend_irecv compatibility issue on XPU/XCCL.
On Intel XPU with XCCL backend, `dist.batch_isend_irecv(P2POp(...))` silently
produces corrupted data (zeros or garbage), while individual `dist.irecv/dist.isend`
calls work correctly.
Usage:
mpirun -np 4 python test_batch_isend_irecv.py
# or
torchrun --nproc_per_node=4 test_batch_isend_irecv.py
"""
import os
import argparse
import torch
import torch.distributed as dist
def init_distributed():
if "RANK" in os.environ:
# torchrun launch
rank = int(os.environ["RANK"])
world_size = int(os.environ["WORLD_SIZE"])
local_rank = int(os.environ["LOCAL_RANK"])
elif "PMI_RANK" in os.environ:
# mpirun launch
rank = int(os.environ["PMI_RANK"])
world_size = int(os.environ["PMI_SIZE"])
local_rank = rank % torch.xpu.device_count()
else:
raise RuntimeError("No distributed launch detected. Use torchrun or mpirun.")
backend = "xccl" if torch.xpu.is_available() else "nccl"
device = f"xpu:{local_rank}" if torch.xpu.is_available() else f"cuda:{local_rank}"
dist.init_process_group(backend=backend, rank=rank, world_size=world_size)
torch.xpu.set_device(local_rank) if torch.xpu.is_available() else torch.cuda.set_device(local_rank)
return rank, world_size, device
def test_individual_isend_irecv(rank, world_size, device, dtype=torch.float32):
"""Test P2P communication using individual dist.irecv / dist.isend calls."""
send_tensor = torch.full((4, 8), float(rank + 1), device=device, dtype=dtype)
recv_tensor = torch.zeros((4, 8), device=device, dtype=dtype)
reqs = []
if rank > 0:
prev_rank = rank - 1
reqs.append(dist.irecv(recv_tensor, src=prev_rank))
reqs.append(dist.isend(send_tensor, dst=prev_rank))
if rank < world_size - 1:
next_rank = rank + 1
reqs.append(dist.isend(send_tensor, dst=next_rank))
reqs.append(dist.irecv(recv_tensor, src=next_rank))
for req in reqs:
req.wait()
dist.barrier()
# Verify: rank 0 should receive from rank 1, middle ranks from both neighbors, last rank from prev
if rank < world_size - 1:
expected_val = float(rank + 2) # value from next rank
actual_val = recv_tensor.mean().item()
passed = abs(actual_val - expected_val) < 1e-5
elif rank > 0:
expected_val = float(rank) # value from prev rank
actual_val = recv_tensor.mean().item()
passed = abs(actual_val - expected_val) < 1e-5
else:
passed = True
expected_val = actual_val = 0.0
return passed, expected_val, actual_val, recv_tensor
def test_batch_isend_irecv(rank, world_size, device, dtype=torch.float32):
"""Test P2P communication using dist.batch_isend_irecv(P2POp(...))."""
send_tensor = torch.full((4, 8), float(rank + 1), device=device, dtype=dtype)
recv_tensor = torch.zeros((4, 8), device=device, dtype=dtype)
p2p_ops = []
if rank > 0:
prev_rank = rank - 1
p2p_ops.append(dist.P2POp(dist.irecv, recv_tensor, prev_rank))
p2p_ops.append(dist.P2POp(dist.isend, send_tensor, prev_rank))
if rank < world_size - 1:
next_rank = rank + 1
p2p_ops.append(dist.P2POp(dist.isend, send_tensor, next_rank))
p2p_ops.append(dist.P2POp(dist.irecv, recv_tensor, next_rank))
if p2p_ops:
reqs = dist.batch_isend_irecv(p2p_ops)
for req in reqs:
req.wait()
dist.barrier()
if rank < world_size - 1:
expected_val = float(rank + 2)
actual_val = recv_tensor.mean().item()
passed = abs(actual_val - expected_val) < 1e-5
elif rank > 0:
expected_val = float(rank)
actual_val = recv_tensor.mean().item()
passed = abs(actual_val - expected_val) < 1e-5
else:
passed = True
expected_val = actual_val = 0.0
return passed, expected_val, actual_val, recv_tensor
def test_halo_exchange_pattern(rank, world_size, device, use_batch, dtype=torch.float32):
"""
Simulate the halo exchange pattern used in WanVAE parallel decode.
Each rank owns a local slice of a height-sharded tensor and exchanges
top/bottom halo rows with neighbors.
"""
local_h, w = 8, 16
# Fill with rank-specific values so correctness is verifiable
x = torch.full((1, 4, local_h, w), float(rank + 1) * 10, device=device, dtype=dtype)
# Make top/bottom rows distinctive
x[..., 0, :] = float(rank + 1) * 100 # top row
x[..., -1, :] = float(rank + 1) * 200 # bottom row
halo_size = 1
top_row = x[..., :halo_size, :].contiguous()
bottom_row = x[..., -halo_size:, :].contiguous()
recv_top = torch.zeros_like(top_row)
recv_bottom = torch.zeros_like(bottom_row)
if use_batch:
p2p_ops = []
if rank > 0:
p2p_ops.append(dist.P2POp(dist.irecv, recv_top, rank - 1))
p2p_ops.append(dist.P2POp(dist.isend, top_row, rank - 1))
if rank < world_size - 1:
p2p_ops.append(dist.P2POp(dist.isend, bottom_row, rank + 1))
p2p_ops.append(dist.P2POp(dist.irecv, recv_bottom, rank + 1))
if rank == 0:
recv_top.zero_()
if rank == world_size - 1:
recv_bottom.zero_()
if p2p_ops:
reqs = dist.batch_isend_irecv(p2p_ops)
for req in reqs:
req.wait()
else:
reqs = []
if rank > 0:
reqs.append(dist.irecv(recv_top, src=rank - 1))
reqs.append(dist.isend(top_row, dst=rank - 1))
if rank < world_size - 1:
reqs.append(dist.isend(bottom_row, dst=rank + 1))
reqs.append(dist.irecv(recv_bottom, src=rank + 1))
if rank == 0:
recv_top.zero_()
if rank == world_size - 1:
recv_bottom.zero_()
for req in reqs:
req.wait()
dist.barrier()
# Verify recv_top: should be bottom_row of (rank-1), i.e. rank * 200
# Verify recv_bottom: should be top_row of (rank+1), i.e. (rank+2) * 100
passed = True
details = []
if rank > 0:
expected_top = float(rank) * 200 # bottom_row value of prev rank
actual_top = recv_top.mean().item()
ok = abs(actual_top - expected_top) < 1e-3
passed = passed and ok
details.append(f"recv_top: expected={expected_top}, actual={actual_top}, {'OK' if ok else 'FAIL'}")
else:
details.append("recv_top: zeroed (rank 0)")
if rank < world_size - 1:
expected_bottom = float(rank + 2) * 100 # top_row value of next rank
actual_bottom = recv_bottom.mean().item()
ok = abs(actual_bottom - expected_bottom) < 1e-3
passed = passed and ok
details.append(f"recv_bottom: expected={expected_bottom}, actual={actual_bottom}, {'OK' if ok else 'FAIL'}")
else:
details.append("recv_bottom: zeroed (last rank)")
return passed, details
def main():
parser = argparse.ArgumentParser(description="Test batch_isend_irecv on XPU/XCCL")
parser.add_argument("--dtype", choices=["float32", "float16", "bfloat16"], default="float32")
args = parser.parse_args()
dtype_map = {"float32": torch.float32, "float16": torch.float16, "bfloat16": torch.bfloat16}
dtype = dtype_map[args.dtype]
rank, world_size, device = init_distributed()
if rank == 0:
backend = "xccl" if torch.xpu.is_available() else "nccl"
print(f"=== batch_isend_irecv compatibility test ===")
print(f"Backend: {backend}, World size: {world_size}, Dtype: {args.dtype}")
print(f"Device: {device}")
print()
dist.barrier()
# --- Test 1: Basic individual irecv/isend ---
passed1, exp1, act1, _ = test_individual_isend_irecv(rank, world_size, device, dtype)
dist.barrier()
if rank == 0:
print("[Test 1] Individual irecv/isend (basic):")
all_passed = torch.tensor([1 if passed1 else 0], device=device)
dist.all_reduce(all_passed)
if rank == 0:
status = "PASS" if all_passed.item() == world_size else "FAIL"
print(f" Result: {status} ({all_passed.item()}/{world_size} ranks passed)\n")
# --- Test 2: Basic batch_isend_irecv ---
passed2, exp2, act2, recv2 = test_batch_isend_irecv(rank, world_size, device, dtype)
dist.barrier()
if rank == 0:
print("[Test 2] batch_isend_irecv (basic):")
all_passed2 = torch.tensor([1 if passed2 else 0], device=device)
dist.all_reduce(all_passed2)
if rank == 0:
status = "PASS" if all_passed2.item() == world_size else "FAIL"
print(f" Result: {status} ({all_passed2.item()}/{world_size} ranks passed)")
if not passed2:
print(f" [Rank {rank}] expected={exp2}, actual={act2}, recv_tensor={recv2.flatten()[:4].tolist()}")
dist.barrier()
if rank == 0:
print()
# --- Test 3: Halo exchange pattern (individual) ---
passed3, details3 = test_halo_exchange_pattern(rank, world_size, device, use_batch=False, dtype=dtype)
dist.barrier()
if rank == 0:
print("[Test 3] Halo exchange pattern (individual irecv/isend):")
all_passed3 = torch.tensor([1 if passed3 else 0], device=device)
dist.all_reduce(all_passed3)
if rank == 0:
status = "PASS" if all_passed3.item() == world_size else "FAIL"
print(f" Result: {status} ({all_passed3.item()}/{world_size} ranks passed)")
if not passed3:
for d in details3:
print(f" [Rank {rank}] {d}")
dist.barrier()
if rank == 0:
print()
# --- Test 4: Halo exchange pattern (batch_isend_irecv) ---
passed4, details4 = test_halo_exchange_pattern(rank, world_size, device, use_batch=True, dtype=dtype)
dist.barrier()
if rank == 0:
print("[Test 4] Halo exchange pattern (batch_isend_irecv):")
all_passed4 = torch.tensor([1 if passed4 else 0], device=device)
dist.all_reduce(all_passed4)
if rank == 0:
status = "PASS" if all_passed4.item() == world_size else "FAIL"
print(f" Result: {status} ({all_passed4.item()}/{world_size} ranks passed)")
if not passed4:
for d in details4:
print(f" [Rank {rank}] {d}")
dist.barrier()
# --- Summary ---
if rank == 0:
print("\n=== Summary ===")
tests = [
("Individual irecv/isend (basic)", all_passed.item() == world_size),
("batch_isend_irecv (basic)", all_passed2.item() == world_size),
("Halo exchange (individual)", all_passed3.item() == world_size),
("Halo exchange (batch)", all_passed4.item() == world_size),
]
for name, ok in tests:
print(f" {'PASS' if ok else 'FAIL'} {name}")
if not all(ok for _, ok in tests):
print("\n** batch_isend_irecv is NOT compatible with current backend. **")
print("** Use individual irecv/isend as workaround. **")
else:
print("\nAll tests passed.")
dist.destroy_process_group()
if __name__ == "__main__":
main()
Versions
- Container image: intel/llm-scaler-omni:0.1.0-b6
PyTorch version: 2.9.0+xpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A
OS: Ubuntu 24.04.2 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Clang version: Could not collect
CMake version: version 3.28.3
Libc version: glibc-2.39
Python version: 3.12.3 (main, Jan 22 2026, 20:57:42) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-6.14.0-1011-intel-x86_64-with-glibc2.39
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
Is XPU available: True
XPU used to build PyTorch: 20250201
Intel GPU driver version:
* libze1: 1.24.3-1~25.10~ppa1
* intel-opencl-icd: 25.40.35563.7-1~25.04~ppa1
Intel GPU models onboard:
* Intel(R) Graphics [0xe211]
* Intel(R) Graphics [0xe211]
* Intel(R) Graphics [0xe211]
* Intel(R) Graphics [0xe211]
Intel GPU models detected:
* [0] _XpuDeviceProperties(name='Intel(R) Graphics [0xe211]', platform_name='Intel(R) oneAPI Unified Runtime over Level-Zero', type='gpu', device_id=0xE211, uuid=868011e2-0000-0000-1800-000000000000, driver_version='1.13.35563+7', total_memory=20343MB, max_compute_units=160, gpu_eu_count=160, gpu_subslice_count=20, max_work_group_size=1024, max_num_sub_groups=64, sub_group_sizes=[16 32], has_fp16=1, has_fp64=1, has_atomic64=1)
* [1] _XpuDeviceProperties(name='Intel(R) Graphics [0xe211]', platform_name='Intel(R) oneAPI Unified Runtime over Level-Zero', type='gpu', device_id=0xE211, uuid=868011e2-0000-0000-1c00-000000000000, driver_version='1.13.35563+7', total_memory=23256MB, max_compute_units=160, gpu_eu_count=160, gpu_subslice_count=20, max_work_group_size=1024, max_num_sub_groups=64, sub_group_sizes=[16 32], has_fp16=1, has_fp64=1, has_atomic64=1)
* [2] _XpuDeviceProperties(name='Intel(R) Graphics [0xe211]', platform_name='Intel(R) oneAPI Unified Runtime over Level-Zero', type='gpu', device_id=0xE211, uuid=868011e2-0000-0000-5400-000000000000, driver_version='1.13.35563+7', total_memory=23256MB, max_compute_units=160, gpu_eu_count=160, gpu_subslice_count=20, max_work_group_size=1024, max_num_sub_groups=64, sub_group_sizes=[16 32], has_fp16=1, has_fp64=1, has_atomic64=1)
* [3] _XpuDeviceProperties(name='Intel(R) Graphics [0xe211]', platform_name='Intel(R) oneAPI Unified Runtime over Level-Zero', type='gpu', device_id=0xE211, uuid=868011e2-0000-0000-5800-000000000000, driver_version='1.13.35563+7', total_memory=23256MB, max_compute_units=160, gpu_eu_count=160, gpu_subslice_count=20, max_work_group_size=1024, max_num_sub_groups=64, sub_group_sizes=[16 32], has_fp16=1, has_fp64=1, has_atomic64=1)
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A
CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 57 bits virtual
Byte Order: Little Endian
CPU(s): 64
On-line CPU(s) list: 0-63
Vendor ID: GenuineIntel
BIOS Vendor ID: Intel(R) Corporation
Model name: Intel(R) Xeon(R) w7-3565X
BIOS Model name: Intel(R) Xeon(R) w7-3565X CPU @ 2.5GHz
BIOS CPU family: 179
CPU family: 6
Model: 143
Thread(s) per core: 2
Core(s) per socket: 32
Socket(s): 1
Stepping: 8
CPU(s) scaling MHz: 30%
CPU max MHz: 4800.0000
CPU min MHz: 800.0000
BogoMIPS: 4992.00
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 intel_ppin cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect user_shstk avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req vnmi avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr ibt amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 1.5 MiB (32 instances)
L1i cache: 1 MiB (32 instances)
L2 cache: 64 MiB (32 instances)
L3 cache: 82.5 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-63
Vulnerability Gather data sampling: Not affected
Vulnerability Ghostwrite: Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Versions of relevant libraries:
[pip3] dpcpp-cpp-rt==2025.2.1
[pip3] impi-rt==2021.16.1
[pip3] intel-cmplr-lib-rt==2025.2.1
[pip3] intel-cmplr-lib-ur==2025.2.1
[pip3] intel-cmplr-lic-rt==2025.2.1
[pip3] intel-opencl-rt==2025.2.1
[pip3] intel-openmp==2025.2.1
[pip3] intel-pti==0.13.1
[pip3] intel-sycl-rt==2025.2.1
[pip3] jj-pytorchvideo==0.1.5
[pip3] mkl==2025.2.0
[pip3] mypy_extensions==1.1.0
[pip3] numpy==2.3.5
[pip3] oneccl==2021.16.1
[pip3] oneccl-devel==2021.16.1
[pip3] onemkl-sycl-blas==2025.2.0
[pip3] onemkl-sycl-dft==2025.2.0
[pip3] onemkl-sycl-lapack==2025.2.0
[pip3] onemkl-sycl-rng==2025.2.0
[pip3] onemkl-sycl-sparse==2025.2.0
[pip3] onnxruntime==1.24.2
[pip3] open_clip_torch==3.3.0
[pip3] optree==0.19.0
[pip3] pytorch-lightning==2.6.1
[pip3] pytorch-triton-xpu==3.5.0
[pip3] rotary-embedding-torch==0.8.9
[pip3] tbb==2022.2.0
[pip3] tcmlib==1.4.0
[pip3] torch==2.9.0+xpu
[pip3] torch-stoi==0.2.3
[pip3] torchao==0.9.0
[pip3] torchaudio==2.9.0+xpu
[pip3] torchcodec==0.8.0
[pip3] torchdiffeq==0.2.5
[pip3] torchmetrics==1.8.2
[pip3] torchsde==0.2.6
[pip3] torchvision==0.24.0+xpu
[pip3] triton==3.5.0
[pip3] umf==0.11.0
[conda] Could not collect
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.