{"record":{"id":"246d9a22fc4d2485","repo":"hiyouga/LlamaFactory","slug":"pipeline-parallel-size-should-be-smaller-than-the","errorCode":null,"errorMessage":"Pipeline parallel size should be smaller than the number of gpus.","messagePattern":"Pipeline parallel size should be smaller than the number of gpus\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/vllm_infer.py","lineNumber":79,"sourceCode":"    max_new_tokens: int = 1024,\n    repetition_penalty: float = 1.0,\n    skip_special_tokens: bool = True,\n    default_system: str | None = None,\n    enable_thinking: bool = True,\n    seed: int | None = None,\n    pipeline_parallel_size: int = 1,\n    image_max_pixels: int = 768 * 768,\n    image_min_pixels: int = 32 * 32,\n    video_fps: float = 2.0,\n    video_maxlen: int = 128,\n    batch_size: int = 1024,\n):\n    r\"\"\"Perform batch generation using vLLM engine, which supports tensor parallelism.\n\n    Usage: python vllm_infer.py --model_name_or_path meta-llama/Llama-2-7b-hf --template llama --dataset alpaca_en_demo\n    \"\"\"\n    if pipeline_parallel_size > get_device_count():\n        raise ValueError(\"Pipeline parallel size should be smaller than the number of gpus.\")\n\n    model_args, data_args, _, generating_args = get_infer_args(\n        dict(\n            model_name_or_path=model_name_or_path,\n            adapter_name_or_path=adapter_name_or_path,\n            dataset=dataset,\n            dataset_dir=dataset_dir,\n            template=template,\n            cutoff_len=cutoff_len,\n            max_samples=max_samples,\n            preprocessing_num_workers=16,\n            default_system=default_system,\n            enable_thinking=enable_thinking,\n            vllm_config=vllm_config,\n            temperature=temperature,\n            top_p=top_p,\n            top_k=top_k,\n            max_new_tokens=max_new_tokens,","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/scripts/vllm_infer.py#L61-L97","documentation":"The mcore_adapter (Megatron-Core adapter) workflow is optional and imported lazily; at module import time workflow.py:43 checks is_mcore_adapter_available() and raises ImportError with the pip package name if the adapter is missing, because all subsequent imports (mcore_adapter.models, trainer, DPOConfig) depend on it.","triggerScenarios":"Running the MCA training path (trainers dispatched via train/mca/workflow.py, e.g. Megatron-style SFT/DPO) in an environment without the mcore-adapter wheel; the check fires at import, before any run logic.","commonSituations":"Selecting the Megatron-Core adapter backend in YAML without installing its extras; fresh environments cloned from a repo that vendors the path but not the dependency.","solutions":["pip install mcore-adapter","If you didn't intend the Megatron path, remove the mca/megatron backend selection from the training config so the standard HF path is used"],"exampleFix":"# before\n# backend selects mca path, package missing -> ImportError\n\n# after\npip install mcore-adapter","handlingStrategy":"validation","validationCode":"from llamafactory.extras.packages import is_mcore_adapter_available\nif backend == 'mca':\n    assert is_mcore_adapter_available(), 'pip install mcore-adapter'","typeGuard":"def mcore_adapter_ready() -> bool:\n    try:\n        import mcore_adapter  # noqa: F401\n        return True\n    except ImportError:\n        return False","tryCatchPattern":"try:\n    run_exp()\nexcept ImportError as e:\n    if 'mcore-adapter' in str(e):\n        raise SystemExit('pip install mcore-adapter') from e\n    raise","preventionTips":["Install backend extras when the config selects that backend","Document per-backend requirements in your training job templates"],"tags":["dependency","megatron","mcore-adapter","installation"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}