Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Heuristic:Intel Ipex llm CCL Distributed Training Tips

From Leeroopedia



Knowledge Sources
Domains Distributed_Training, Optimization
Last Updated 2026-02-09 12:00 GMT

Overview

Intel XPU distributed training requires CCL backend instead of NCCL, gradient accumulation adjustment for DDP, DeepSpeed ZeRO3 patching, and rank-based device mapping.

Description

Multi-GPU training on Intel XPU hardware requires specific distributed training patterns that differ from NVIDIA CUDA workflows. Intel OneCCL replaces NCCL as the communication backend, gradient accumulation steps must be divided by world_size to maintain effective batch size, and DeepSpeed ZeRO3 requires IPEX-LLM compatibility patches. These patterns are encoded in the IPEX-LLM finetuning examples and represent essential tribal knowledge for anyone attempting distributed LLM training on Intel hardware.

Usage

Use this heuristic when setting up multi-GPU training on Intel XPU, whether using standard DDP or DeepSpeed ZeRO3. Apply these tips whenever `WORLD_SIZE > 1` or when configuring distributed training arguments.

The Insight (Rule of Thumb)

  • Action: Set `ddp_backend="ccl"` in TrainingArguments (NOT `"nccl"`).
  • Action: Divide `gradient_accumulation_steps` by `world_size` when using DDP to maintain consistent effective batch size.
  • Action: Use explicit device mapping `{"": LOCAL_RANK}` instead of `"auto"` in DDP mode.
  • Action: Set `ddp_find_unused_parameters=False` for LoRA training (all target modules are used).
  • Action: When using DeepSpeed ZeRO3, apply the `_constant_buffered_norm2` patch from IPEX-LLM.
  • Action: When using DeepSpeed ZeRO3, do NOT manually move model to XPU — ZeRO3 handles device placement internally.
  • Trade-off: CCL may have different performance characteristics than NCCL. OneCCL environment must be sourced separately.

Reasoning

NCCL is NVIDIA-specific and cannot run on Intel XPU hardware. Intel OneCCL provides equivalent collective communication primitives optimized for Intel interconnects. The gradient accumulation division is necessary because in DDP, each process independently computes gradients that are then averaged — without this correction, the effective batch size would be `batch_size * world_size` instead of the intended `batch_size`. The DeepSpeed ZeRO3 patch is needed because the standard `_constant_buffered_norm2` implementation uses CUDA-specific calls that fail on XPU.

Code Evidence

CCL backend from `alpaca_qlora_finetuning.py:268`:

ddp_backend="ccl",

Gradient accumulation DDP adjustment from `alpaca_qlora_finetuning.py:155-160`:

device_map = "auto"
world_size = int(os.environ.get("WORLD_SIZE", 1))
ddp = world_size != 1
if ddp:
    device_map = {"": int(os.environ.get("LOCAL_RANK") or 0)}
    gradient_accumulation_steps = gradient_accumulation_steps // world_size

DeepSpeed ZeRO3 patching from `alpaca_qlora_finetuning.py:147-153`:

if deepspeed is not None and "zero3" in deepspeed:
    from ipex_llm.transformers.utils \
        import _constant_buffered_norm2
    from ipex_llm.llm_patching import replace_attr
    import deepspeed as ds
    replace_attr(ds.runtime.zero.stage3.DeepSpeedZeroOptimizer_Stage3,
                 "_constant_buffered_norm2", _constant_buffered_norm2)

ZeRO3 device placement bypass from `alpaca_lora_finetuning.py:180-185`:

if deepspeed_zero3:
    deepspeed = deepspeed if deepspeed is not None else "./deepspeed_zero3_config.json"
else:
    print(f"Model loaded on rank {os.environ.get('LOCAL_RANK')}")
    model = model.to(f'xpu:{os.environ.get("LOCAL_RANK", 0)}')
    print(f"Model moved to rank {os.environ.get('LOCAL_RANK')}")

DDP unused parameters from `alpaca_qlora_finetuning.py:263`:

ddp_find_unused_parameters=False if ddp else None,

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment