Repository navigation
[recipe] fix: allow MoE recipe construction without CUDA - #5732
Conversation
Signed-off-by: Yu Yao <yaoyu.094@gmail.com>
|
/ok to test 962083c |
|
Light review - LGTM. Clean, well-scoped fix: apply_flex_dispatcher_backend now short-circuits when CUDA is unavailable and the backend is deepep/hybridep, setting the flex config without probing device properties. This lets offline packing build MoE recipes (e.g. qwen3_30b_a3b_peft_config) on a CPU-only host. Arch validation is correctly deferred to validate_flex_dispatcher_backend, which still runs at runtime. Observations:
Suggested test cases
No perf tests impacted. |
| if not torch.cuda.is_available() and moe_flex_dispatcher_backend in ("deepep", "hybridep"): | ||
| model_config.moe_token_dispatcher_type = "flex" | ||
| model_config.moe_flex_dispatcher_backend = moe_flex_dispatcher_backend | ||
| model_config.moe_shared_expert_overlap = False | ||
| return |
There was a problem hiding this comment.
This CPU/no-CUDA branch intentionally skips the GPU arch check and sets flex/backend directly. That's fine because validate_flex_dispatcher_backend re-checks the arch at runtime — but the safety of this path depends on that validator always running before the flex dispatcher is actually used. Consider a brief comment here pointing to validate_flex_dispatcher_backend so a future reader knows the arch gate is deferred, not dropped.
What does this PR do?
Public Qwen3-MoE SFT and PEFT recipes enable a flex dispatcher while they are being constructed. The official offline-packing workflow constructs these recipes before a GPU training job, but
apply_flex_dispatcher_backend()unconditionally queried CUDA device 0. On a CPU preprocessing host this raised during recipe construction, before packing could start.The changed path is:
prepare_gpt_sft_packed_data.py-> public Qwen3-MoE recipe factory ->apply_flex_dispatcher_backend()->torch.cuda.get_device_properties(0)The helper now records the requested supported flex backend without probing device properties when CUDA is unavailable. GPU processes keep the existing architecture check, and CUDA probe errors still propagate when CUDA is reported available. Runtime validation is unchanged.
Scope is limited to CPU-side construction of supported DeepEP and HybridEP recipe configs. It does not make those backends executable without GPUs and does not change training-time hardware validation.
Regression evidence
The focused regression constructs the public
qwen3_30b_a3b_peft_configwith a real MoE-shaped provider and asserts that CUDA device properties are not queried when CUDA is unavailable.Applied as a test-only change to
2e77041c194d106beb7462e226d7ca06b33ea63f:Result: failed at
torch.cuda.get_device_properties(0)withrecipe construction probed CUDA device properties.With this fix, the unchanged command passes:
1 passed.Validation