已开启
adding topology search and auto-parallel for Qwen3b model #900
aminmalekisadr创建于 1月29日
adding topology search and auto-parallel for Qwen3b model #900
已开启
合并受阻
1月29日 创建了 pull request,commit aaff1d7e
ascend-robot
1月29日 评论:
1月29日 评论:
AtlasAccount
1月29日 评论:
1月29日 评论:
ascend-robot
1月29日 评论:
1月29日 评论:
以下是根据您提交的修改文件推荐的Reviewer和Committer序列,需各模块评审通过后方可合入
| Module List | Reviewers | Committers |
|---|---|---|
| repo-Ascend/MindSpeed-RL | fengliangjun, dingzicha1997, sz19991010, yaochao20, leizhenzhen23 | fengliangjun, zhoubeirong, elvinp, wucong25, sz19991010 |


1月29日 添加了label:ascend-cla/no
aminmalekisadr
1月29日 评论:
1月29日 评论:
/check-cla


1月29日 删除了label:ascend-cla/no
1月29日 添加了label:ascend-cla/yes
ascend-robot
1月29日 评论:
1月29日 评论:
Pull Request: Auto-Parallelization and Topology-Aware Node Selection for mindspeed_rl
Summary
This PR adds automatic parallelization configuration for RLHF workloads and rack-aware topology selection for better resource allocation in multi-rack environments. These features enable the system to automatically determine optimal Tensor Parallelism (TP), Data Parallelism (DP), Pipeline Parallelism (PP), Context Parallelism (CP), Expert Parallelism (EP), and Sequence Parallelism (SP) configurations for both inference and training, and intelligently place workers based on cluster topology.
Features Added
1. Auto-Parallelization for Inference and Training
Automatically determines optimal TP/CP/DP/EP/SP/PP configuration for inference and training based on:
Key Benefits:
2. Rack-Aware Topology Selection
Intelligent node allocation that prioritizes:
Balanced Node Selection:
select_balanced_nodes()implements intelligent placement rules:Files Changed
Core Implementation
mindspeed_rl/workers/scheduler/launcher.py:auto_parallelize_inference(): Main entry point for inference auto-parallelizationauto_parallelize_inference_simple(): Core algorithm for TP/CP/EP selection (inference)auto_parallelize_training(): Core algorithm for TP/PP/CP/EP/SP selection (training)check_inference_parallel_constraints(): Validates TP/CP against model constraintscheck_training_parallel_constraints(): Validates TP/PP/CP against model constraintscheck_memory_at_runtime(): Runtime memory checking via model initializationestimate_memory_requirements(): Analytical memory estimation (fallback, with warnings)find_factors(): Helper function to find all factors of a number (for PP/CP candidates)get_cluster_topology(): Detects rack topology from Ray node resources (RACK_X)select_balanced_nodes(): Implements balanced node selection algorithm with single-rack preference and symmetric allocationget_rack_capacities(): Calculates capacity per rack for allocation decisions_select_nodes_group_within_rack(): Allocates nodes keeping TP/PP/CP groups within same rack when possibleConfiguration
mindspeed_rl/config_cls/generate_config.py:auto_parallel(bool): Enable/disable auto-parallelization for inferenceauto_parallel_check_memory(bool): Use runtime checks vs analytical estimationmindspeed_rl/config_cls/megatron_config.py:auto_parallel(bool): Enable/disable auto-parallelization for trainingmindspeed_rl/config_cls/rl_config.py:auto_parallelattribute for backwards compatibility (ignored)Integration
cli/train_grpo.py:auto_parallelflag fromactor_configfor trainingauto_parallelize_training()when enabled for actor/ref/reward configsauto_parallelize_inference()when enabled ingenerate_configDocumentation
docs/AUTO_PARALLEL_IMPLEMENTATION.md: Comprehensive documentationdocs/DEVICE_MEMORY_DETECTION.md: Device memory detection mechanismConfiguration
YAML Configuration
# Inference auto-parallelization generate_config: # Enable auto-parallelization for inference auto_parallel: true # Runtime memory checking (default: true, recommended) auto_parallel_check_memory: true # true = reliable, false = fast but unreliable # These will be auto-selected when auto_parallel=true infer_tensor_parallel_size: 2 # Will be overridden infer_pipeline_parallel_size: 1 # Will not be overridden (vLLM doesn't support PP) infer_expert_parallel_size: 1 # Will be auto-selected for MOE models # Training auto-parallelization actor_config: # Same for ref_config and reward_config # Enable auto-parallelization for training auto_parallel: true # These will be auto-selected when auto_parallel=true tensor_model_parallel_size: 1 # Will be overridden pipeline_model_parallel_size: 1 # Will be auto-selected context_parallel_size: 1 # Will be auto-selected expert_model_parallel_size: 1 # Will be auto-selected for MOE models sequence_parallel: false # Will be auto-enabled when needed (see below)Usage Examples
Basic Usage
# config.yaml generate_config: auto_parallel: true auto_parallel_check_memory: trueThe system will automatically:
With Rack Configuration
# Set rack information via Ray resources on each node ray start --resources='{"RACK_0": 1.0}' # Node in rack 0 # On another node: ray start --resources='{"RACK_1": 1.0}' # Node in rack 1The system will:
get_cluster_topology()select_balanced_nodes()for intelligent placement:If no RACK_X resources are found, falls back to sequential placement without rack awareness.
Testing
Test Configuration
Tested with:
Test Result:
Improvement for Topology search: 5%
Improvement for Auto-parallel: 18%
Breaking Changes
None - All changes are backward compatible:
auto_parallel: false)Performance Considerations
Runtime Memory Checks (Default)
Analytical Estimation (Optional)
Memory Detection
The system automatically detects device memory:
torch.cuda.get_device_properties().total_memorytorch.npu.get_device_properties()ortorch.npu.memory_info()NPU_MEMORY_GBenvironment variableSee
docs/DEVICE_MEMORY_DETECTION.mdfor details.Documentation
Comprehensive documentation provided:
docs/AUTO_PARALLEL_IMPLEMENTATION.md: Complete implementation guidedocs/DEVICE_MEMORY_DETECTION.md: Memory detection mechanismsTechnical Details
Future Enhancements
Potential improvements (not in this PR):
Request for Review and Merge
We request the MindSpeed-RL team to review and merge this PR. The changes:
Review Focus Areas
Please pay special attention to:
select_balanced_nodes()algorithm (single-rack preference, symmetric allocation)Questions or Concerns
If you have questions or concerns, please:
We're open to feedback and ready to make adjustments based on your review.
**Thank you for your time and con