已合并
升级LLM分支到2.3.0 #850
wangshuyang31创建于 2025年12月17日
升级LLM分支到2.3.0 #850
已合并
共 24 个文件变更+49-64
| @@ -248,7 +248,8 @@ def get_megatron_module(): | |||
| 248 | from megatron.training.training import setup_model_and_optimizer | 248 | from megatron.training.training import setup_model_and_optimizer |
| 249 | from megatron.core.enums import ModelType | 249 | from megatron.core.enums import ModelType |
| 250 | from megatron.core.distributed import finalize_model_grads | 250 | from megatron.core.distributed import finalize_model_grads |
| 251 | - from mindspeed.utils import set_actual_seq_len, set_position_ids, get_actual_seq_len | 251 | + from mindspeed.utils import set_position_ids |
| 252 | + from mindspeed.core.context_parallel.get_batch_utils import set_actual_seq_len, get_actual_seq_len | ||
| 252 | from megatron.core.optimizer.distrib_optimizer import DistributedOptimizer | 253 | from megatron.core.optimizer.distrib_optimizer import DistributedOptimizer |
| 253 | from megatron.core.optimizer.optimizer import Float16OptimizerWithFloat16Params | 254 | from megatron.core.optimizer.optimizer import Float16OptimizerWithFloat16Params |
| 254 | 255 | ||
| @@ -202,11 +202,11 @@ def initialize_megatron( | |||
| 202 | load_args_from_checkpoint(args) | 202 | load_args_from_checkpoint(args) |
| 203 | 203 | ||
| 204 | _ori_vari_length = None | 204 | _ori_vari_length = None |
| 205 | - _ori_vari_length = args.variable_seq_lengths | 205 | + _ori_vari_length = args.no_pad_to_seq_lengths |
| 206 | - args.variable_seq_lengths = False | 206 | + args.no_pad_to_seq_lengths = False |
| 207 | validate_args(args, args_defaults) | 207 | validate_args(args, args_defaults) |
| 208 | if _ori_vari_length is not None: | 208 | if _ori_vari_length is not None: |
| 209 | - args.variable_seq_lengths = _ori_vari_length | 209 | + args.no_pad_to_seq_lengths = _ori_vari_length |
| 210 | 210 | ||
| 211 | set_global_variables(args) | 211 | set_global_variables(args) |
| 212 | 212 | ||
| @@ -260,7 +260,8 @@ def get_megatron_module(): | |||
| 260 | from megatron.training.training import setup_model_and_optimizer | 260 | from megatron.training.training import setup_model_and_optimizer |
| 261 | from megatron.core.enums import ModelType | 261 | from megatron.core.enums import ModelType |
| 262 | from megatron.core.distributed import finalize_model_grads | 262 | from megatron.core.distributed import finalize_model_grads |
| 263 | - from mindspeed.utils import set_actual_seq_len, set_position_ids, get_actual_seq_len | 263 | + from mindspeed.utils import set_position_ids |
| 264 | + from mindspeed.core.context_parallel.get_batch_utils import set_actual_seq_len, get_actual_seq_len | ||
| 264 | from megatron.core.optimizer.distrib_optimizer import DistributedOptimizer | 265 | from megatron.core.optimizer.distrib_optimizer import DistributedOptimizer |
| 265 | from megatron.core.optimizer.optimizer import Float16OptimizerWithFloat16Params | 266 | from megatron.core.optimizer.optimizer import Float16OptimizerWithFloat16Params |
| 266 | 267 | ||
| @@ -291,7 +291,8 @@ def get_megatron_module(): | |||
| 291 | from megatron.training.training import setup_model_and_optimizer | 291 | from megatron.training.training import setup_model_and_optimizer |
| 292 | from megatron.core.enums import ModelType | 292 | from megatron.core.enums import ModelType |
| 293 | from megatron.core.distributed import finalize_model_grads | 293 | from megatron.core.distributed import finalize_model_grads |
| 294 | - from mindspeed.utils import set_actual_seq_len, set_position_ids, get_actual_seq_len | 294 | + from mindspeed.utils import set_position_ids |
| 295 | + from mindspeed.core.context_parallel.get_batch_utils import set_actual_seq_len, get_actual_seq_len | ||
| 295 | from megatron.core.optimizer.distrib_optimizer import DistributedOptimizer | 296 | from megatron.core.optimizer.distrib_optimizer import DistributedOptimizer |
| 296 | from megatron.core.optimizer.optimizer import Float16OptimizerWithFloat16Params | 297 | from megatron.core.optimizer.optimizer import Float16OptimizerWithFloat16Params |
| 297 | 298 | ||
| @@ -3,9 +3,6 @@ defaults: | |||
| 3 | - qwen25_32b | 3 | - qwen25_32b |
| 4 | 4 | ||
| 5 | megatron_training: | 5 | megatron_training: |
| 6 | - use_ascend_coc: True | ||
| 7 | - coc_fused_kernel: True | ||
| 8 | - coc_parallel_num: 2 | ||
| 9 | model: qwen25_32b | 6 | model: qwen25_32b |
| 10 | use_fused_rmsnorm: true | 7 | use_fused_rmsnorm: true |
| 11 | use_mcore_models: true | 8 | use_mcore_models: true |
| @@ -29,7 +26,7 @@ megatron_training: | |||
| 29 | hidden_dropout: 0.0 | 26 | hidden_dropout: 0.0 |
| 30 | distributed_backend: nccl | 27 | distributed_backend: nccl |
| 31 | no_shared_storage: true | 28 | no_shared_storage: true |
| 32 | - variable_seq_lengths: true | 29 | + no_pad_to_seq_lengths: true |
| 33 | dataset_additional_keys: ['labels',] | 30 | dataset_additional_keys: ['labels',] |
| 34 | data_path: ./data | 31 | data_path: ./data |
| 35 | split: 100,0,0 | 32 | split: 100,0,0 |
| @@ -3,9 +3,6 @@ defaults: | |||
| 3 | - qwen25_32b | 3 | - qwen25_32b |
| 4 | 4 | ||
| 5 | megatron_training: | 5 | megatron_training: |
| 6 | - use_ascend_coc: True | ||
| 7 | - coc_fused_kernel: True | ||
| 8 | - coc_parallel_num: 2 | ||
| 9 | model: qwen25_32b | 6 | model: qwen25_32b |
| 10 | use_fused_rmsnorm: true | 7 | use_fused_rmsnorm: true |
| 11 | use_mcore_models: true | 8 | use_mcore_models: true |
| @@ -29,7 +26,7 @@ megatron_training: | |||
| 29 | hidden_dropout: 0.0 | 26 | hidden_dropout: 0.0 |
| 30 | distributed_backend: nccl | 27 | distributed_backend: nccl |
| 31 | no_shared_storage: true | 28 | no_shared_storage: true |
| 32 | - variable_seq_lengths: true | 29 | + no_pad_to_seq_lengths: true |
| 33 | dataset_additional_keys: ['labels',] | 30 | dataset_additional_keys: ['labels',] |
| 34 | data_path: ./data | 31 | data_path: ./data |
| 35 | split: 100,0,0 | 32 | split: 100,0,0 |
| @@ -27,7 +27,7 @@ megatron_training: | |||
| 27 | hidden_dropout: 0.0 | 27 | hidden_dropout: 0.0 |
| 28 | distributed_backend: nccl | 28 | distributed_backend: nccl |
| 29 | no_shared_storage: true | 29 | no_shared_storage: true |
| 30 | - variable_seq_lengths: true | 30 | + no_pad_to_seq_lengths: true |
| 31 | dataset_additional_keys: ['labels',] | 31 | dataset_additional_keys: ['labels',] |
| 32 | data_path: ./data | 32 | data_path: ./data |
| 33 | split: 100,0,0 | 33 | split: 100,0,0 |
| @@ -27,7 +27,7 @@ megatron_training: | |||
| 27 | hidden_dropout: 0.0 | 27 | hidden_dropout: 0.0 |
| 28 | distributed_backend: nccl | 28 | distributed_backend: nccl |
| 29 | no_shared_storage: true | 29 | no_shared_storage: true |
| 30 | - variable_seq_lengths: true | 30 | + no_pad_to_seq_lengths: true |
| 31 | dataset_additional_keys: ['labels',] | 31 | dataset_additional_keys: ['labels',] |
| 32 | data_path: ./data | 32 | data_path: ./data |
| 33 | split: 100,0,0 | 33 | split: 100,0,0 |
| @@ -7,7 +7,7 @@ megatron_training: | |||
| 7 | finetune: true | 7 | finetune: true |
| 8 | stage: dpo | 8 | stage: dpo |
| 9 | is_pairwise_dataset: true | 9 | is_pairwise_dataset: true |
| 10 | - variable_seq_lengths: true | 10 | + no_pad_to_seq_lengths: true |
| 11 | tokenizer_not_use_fast: true | 11 | tokenizer_not_use_fast: true |
| 12 | dpo_loss_type: sigmoid | 12 | dpo_loss_type: sigmoid |
| 13 | # gpt_args: | 13 | # gpt_args: |
| @@ -26,14 +26,14 @@ megatron_training: | |||
| 26 | hidden_dropout: 0.0 | 26 | hidden_dropout: 0.0 |
| 27 | distributed_backend: nccl | 27 | distributed_backend: nccl |
| 28 | no_shared_storage: true | 28 | no_shared_storage: true |
| 29 | - variable_seq_lengths: true | 29 | + no_pad_to_seq_lengths: true |
| 30 | dataset_additional_keys: ['labels',] | 30 | dataset_additional_keys: ['labels',] |
| 31 | no_shuffle: false | 31 | no_shuffle: false |
| 32 | data_path: ./deepscaler | 32 | data_path: ./deepscaler |
| 33 | split: 100,0,0 | 33 | split: 100,0,0 |
| 34 | swap_optimizer: true | 34 | swap_optimizer: true |
| 35 | moe_alltoall_overlap_comm: true | 35 | moe_alltoall_overlap_comm: true |
| 36 | - reset_position_ids: true | 36 | + reset_attention_mask: true |
| 37 | 37 | ||
| 38 | actor_config: | 38 | actor_config: |
| 39 | model: deepseekv3_671b | 39 | model: deepseekv3_671b |
| @@ -27,7 +27,7 @@ megatron_training: | |||
| 27 | hidden_dropout: 0.0 | 27 | hidden_dropout: 0.0 |
| 28 | distributed_backend: nccl | 28 | distributed_backend: nccl |
| 29 | no_shared_storage: true | 29 | no_shared_storage: true |
| 30 | - variable_seq_lengths: true | 30 | + no_pad_to_seq_lengths: true |
| 31 | dataset_additional_keys: ['labels'] | 31 | dataset_additional_keys: ['labels'] |
| 32 | data_path: ./deepseek/deepscaler | 32 | data_path: ./deepseek/deepscaler |
| 33 | split: 100,0,0 | 33 | split: 100,0,0 |
| @@ -36,7 +36,7 @@ megatron_training: | |||
| 36 | seed: 1 | 36 | seed: 1 |
| 37 | swap_optimizer: true | 37 | swap_optimizer: true |
| 38 | moe_alltoall_overlap_comm: true | 38 | moe_alltoall_overlap_comm: true |
| 39 | - reset_position_ids: true | 39 | + reset_attention_mask: true |
| 40 | 40 | ||
| 41 | actor_config: | 41 | actor_config: |
| 42 | model: deepseekv3_671b | 42 | model: deepseekv3_671b |
| @@ -27,7 +27,7 @@ megatron_training: | |||
| 27 | hidden_dropout: 0.0 | 27 | hidden_dropout: 0.0 |
| 28 | distributed_backend: nccl | 28 | distributed_backend: nccl |
| 29 | no_shared_storage: true | 29 | no_shared_storage: true |
| 30 | - variable_seq_lengths: true | 30 | + no_pad_to_seq_lengths: true |
| 31 | dataset_additional_keys: ['labels'] | 31 | dataset_additional_keys: ['labels'] |
| 32 | data_path: ./deepseek/deepscaler | 32 | data_path: ./deepseek/deepscaler |
| 33 | split: 100,0,0 | 33 | split: 100,0,0 |
| @@ -36,7 +36,7 @@ megatron_training: | |||
| 36 | seed: 1 | 36 | seed: 1 |
| 37 | swap_optimizer: true | 37 | swap_optimizer: true |
| 38 | moe_alltoall_overlap_comm: true | 38 | moe_alltoall_overlap_comm: true |
| 39 | - reset_position_ids: true | 39 | + reset_attention_mask: true |
| 40 | 40 | ||
| 41 | actor_config: | 41 | actor_config: |
| 42 | model: deepseekv3_671b | 42 | model: deepseekv3_671b |
| @@ -3,9 +3,6 @@ defaults: | |||
| 3 | - qwen25_32b | 3 | - qwen25_32b |
| 4 | 4 | ||
| 5 | megatron_training: | 5 | megatron_training: |
| 6 | - use_ascend_coc: True | ||
| 7 | - coc_fused_kernel: True | ||
| 8 | - coc_parallel_num: 2 | ||
| 9 | model: qwen25_32b | 6 | model: qwen25_32b |
| 10 | use_fused_rmsnorm: true | 7 | use_fused_rmsnorm: true |
| 11 | use_mcore_models: true | 8 | use_mcore_models: true |
| @@ -29,11 +26,11 @@ megatron_training: | |||
| 29 | hidden_dropout: 0.0 | 26 | hidden_dropout: 0.0 |
| 30 | distributed_backend: nccl | 27 | distributed_backend: nccl |
| 31 | no_shared_storage: true | 28 | no_shared_storage: true |
| 32 | - variable_seq_lengths: true | 29 | + no_pad_to_seq_lengths: true |
| 33 | dataset_additional_keys: ['labels'] | 30 | dataset_additional_keys: ['labels'] |
| 34 | data_path: ./data | 31 | data_path: ./data |
| 35 | split: 100,0,0 | 32 | split: 100,0,0 |
| 36 | - reset_position_ids: true | 33 | + reset_attention_mask: true |
| 37 | seed: 1 | 34 | seed: 1 |
| 38 | 35 | ||
| 39 | actor_config: | 36 | actor_config: |
| @@ -26,14 +26,14 @@ megatron_training: | |||
| 26 | hidden_dropout: 0.0 | 26 | hidden_dropout: 0.0 |
| 27 | distributed_backend: nccl | 27 | distributed_backend: nccl |
| 28 | no_shared_storage: true | 28 | no_shared_storage: true |
| 29 | - variable_seq_lengths: true | 29 | + no_pad_to_seq_lengths: true |
| 30 | dataset_additional_keys: ['labels'] | 30 | dataset_additional_keys: ['labels'] |
| 31 | data_path: ./data | 31 | data_path: ./data |
| 32 | split: 100,0,0 | 32 | split: 100,0,0 |
| 33 | no_shuffle: false | 33 | no_shuffle: false |
| 34 | full_shuffle_instruction_dataset: false | 34 | full_shuffle_instruction_dataset: false |
| 35 | seed: 1 | 35 | seed: 1 |
| 36 | - reset_position_ids: true | 36 | + reset_attention_mask: true |
| 37 | 37 | ||
| 38 | actor_config: | 38 | actor_config: |
| 39 | model: qwen25_32b | 39 | model: qwen25_32b |
| @@ -3,9 +3,6 @@ defaults: | |||
| 3 | - qwen25_7b | 3 | - qwen25_7b |
| 4 | 4 | ||
| 5 | megatron_training: | 5 | megatron_training: |
| 6 | - use_ascend_coc: True | ||
| 7 | - coc_fused_kernel: True | ||
| 8 | - coc_parallel_num: 2 | ||
| 9 | model: qwen25_7b | 6 | model: qwen25_7b |
| 10 | use_fused_rmsnorm: true | 7 | use_fused_rmsnorm: true |
| 11 | use_mcore_models: true | 8 | use_mcore_models: true |
| @@ -29,12 +29,12 @@ megatron_training: | |||
| 29 | hidden_dropout: 0.0 | 29 | hidden_dropout: 0.0 |
| 30 | distributed_backend: nccl | 30 | distributed_backend: nccl |
| 31 | no_shared_storage: true | 31 | no_shared_storage: true |
| 32 | - variable_seq_lengths: true | 32 | + no_pad_to_seq_lengths: true |
| 33 | dataset_additional_keys: ['labels',] | 33 | dataset_additional_keys: ['labels',] |
| 34 | data_path: ./data | 34 | data_path: ./data |
| 35 | split: 100,0,0 | 35 | split: 100,0,0 |
| 36 | swap_optimizer: true | 36 | swap_optimizer: true |
| 37 | - reset_position_ids: true | 37 | + reset_attention_mask: true |
| 38 | 38 | ||
| 39 | actor_config: | 39 | actor_config: |
| 40 | model: qwen3_235b_a22b | 40 | model: qwen3_235b_a22b |
| @@ -27,7 +27,7 @@ megatron_training: | |||
| 27 | hidden_dropout: 0.0 | 27 | hidden_dropout: 0.0 |
| 28 | distributed_backend: nccl | 28 | distributed_backend: nccl |
| 29 | no_shared_storage: true | 29 | no_shared_storage: true |
| 30 | - variable_seq_lengths: true | 30 | + no_pad_to_seq_lengths: true |
| 31 | dataset_additional_keys: ['labels'] | 31 | dataset_additional_keys: ['labels'] |
| 32 | data_path: ./data | 32 | data_path: ./data |
| 33 | split: 100,0,0 | 33 | split: 100,0,0 |
| @@ -21,14 +21,15 @@ | |||
| 21 | actor_config: | 21 | actor_config: |
| 22 | context_parallel_size: 2 | 22 | context_parallel_size: 2 |
| 23 | context_parallel_algo: ulysses_cp_algo | 23 | context_parallel_algo: ulysses_cp_algo |
| 24 | + attention_mask_type: general | ||
| 24 | 25 | ||
| 25 | # 与remove_padding特性一起使用 | 26 | # 与remove_padding特性一起使用 |
| 26 | rl_config: | 27 | rl_config: |
| 27 | use_remove_padding: true | 28 | use_remove_padding: true |
| 28 | 29 | ||
| 29 | megatron_training: | 30 | megatron_training: |
| 30 | - reset_position_ids: true | 31 | + reset_attention_mask: true |
| 31 | - variable_seq_lengths: true | 32 | + no_pad_to_seq_lengths: true |
| 32 | ``` | 33 | ``` |
| 33 | 34 | ||
| 34 | 对于直接偏好对齐(DPO)算法,通过如下配置可以使能: | 35 | 对于直接偏好对齐(DPO)算法,通过如下配置可以使能: |
| @@ -36,7 +37,7 @@ megatron_training: | |||
| 36 | ```yaml | 37 | ```yaml |
| 37 | # 填写在megatron_training | 38 | # 填写在megatron_training |
| 38 | megatron_training: | 39 | megatron_training: |
| 39 | - variable_seq_lengths: true | 40 | + no_pad_to_seq_lengths: true |
| 40 | context_parallel_size: 2 | 41 | context_parallel_size: 2 |
| 41 | context_parallel_algo: ulysses_cp_algo | 42 | context_parallel_algo: ulysses_cp_algo |
| 42 | ``` | 43 | ``` |
| @@ -46,7 +47,7 @@ megatron_training: | |||
| 46 | `context_parallel_algo` 表示选用的长序列并行方法,如果不配置此参数,默认取**ulysses_cp_algo** | 47 | `context_parallel_algo` 表示选用的长序列并行方法,如果不配置此参数,默认取**ulysses_cp_algo** |
| 47 | 48 | ||
| 48 | 特别的,此特性与**remove_padding**一起使用时,配置说明如下: | 49 | 特别的,此特性与**remove_padding**一起使用时,配置说明如下: |
| 49 | -直接叠加使能remove_padding的配置即可:将use_remove_padding、reset_position_ids、variable_seq_lengths都设置为true。 | 50 | +直接叠加使能remove_padding的配置即可:将use_remove_padding、reset_attention_mask、no_pad_to_seq_lengths都设置为true。 |
| 50 | 51 | ||
| 51 | ### Ring Attention | 52 | ### Ring Attention |
| 52 | ```yaml | 53 | ```yaml |
| @@ -60,8 +61,7 @@ rl_config: | |||
| 60 | use_remove_padding: true | 61 | use_remove_padding: true |
| 61 | 62 | ||
| 62 | megatron_training: | 63 | megatron_training: |
| 63 | - reset_position_ids: true | 64 | + no_pad_to_seq_lengths: true |
| 64 | - variable_seq_lengths: true | ||
| 65 | reset_attention_mask: true | 65 | reset_attention_mask: true |
| 66 | ``` | 66 | ``` |
| 67 | 67 | ||
| @@ -76,4 +76,4 @@ megatron_training: | |||
| 76 | 76 | ||
| 77 | 特别的,此特性与**remove_padding**一起使用时,配置说明如下: | 77 | 特别的,此特性与**remove_padding**一起使用时,配置说明如下: |
| 78 | 78 | ||
| 79 | -除了需要将use_remove_padding、reset_position_ids、variable_seq_lengths都设置为true之外(使能remove_padding),还需要将reset_attention_mask设置为true; 否则这些配置都不要配,默认**false**。 | 79 | +除了需要将use_remove_padding、reset_attention_mask、no_pad_to_seq_lengths都设置为true之外(使能remove_padding),还需要将reset_attention_mask设置为true; 否则这些配置都不要配,默认**false**。 |
| @@ -34,8 +34,8 @@ | |||
| 34 | 34 | ||
| 35 | ```yaml | 35 | ```yaml |
| 36 | megatron_training: | 36 | megatron_training: |
| 37 | - variable_seq_lengths: true | 37 | + no_pad_to_seq_lengths: true |
| 38 | - reset_position_ids: true | 38 | + reset_attention_mask: true |
| 39 | 39 | ||
| 40 | rl_config: | 40 | rl_config: |
| 41 | use_remove_padding: true | 41 | use_remove_padding: true |
| @@ -111,7 +111,7 @@ class MegatronConfig(BaseConfig): | |||
| 111 | is_instruction_dataset: Whether the dataset is instruction-based (default: False) | 111 | is_instruction_dataset: Whether the dataset is instruction-based (default: False) |
| 112 | is_pairwise_dataset: Whether the dataset is pairwise format that has a chosen sequence and rejected | 112 | is_pairwise_dataset: Whether the dataset is pairwise format that has a chosen sequence and rejected |
| 113 | sequence, which usually used in reinforce learning (default: False) | 113 | sequence, which usually used in reinforce learning (default: False) |
| 114 | - variable_seq_lengths: Whether to use variable sequence lengths (default: False) | 114 | + variable_seq_length: Whether to use variable sequence lengths (default: False) |
| 115 | no_shuffle: Whether to shuffle the dataset (default: False) | 115 | no_shuffle: Whether to shuffle the dataset (default: False) |
| 116 | stage: Stage of the model (default: None) | 116 | stage: Stage of the model (default: None) |
| 117 | sequence_parallel: Whether to use sequence parallelism (default: False) | 117 | sequence_parallel: Whether to use sequence parallelism (default: False) |
| @@ -311,7 +311,8 @@ class MegatronConfig(BaseConfig): | |||
| 311 | self.no_save_rng = None | 311 | self.no_save_rng = None |
| 312 | self.is_instruction_dataset = False | 312 | self.is_instruction_dataset = False |
| 313 | self.is_pairwise_dataset = False | 313 | self.is_pairwise_dataset = False |
| 314 | - self.variable_seq_lengths = False | 314 | + self.variable_seq_length = False |
| 315 | + self.no_pad_to_seq_lengths = False | ||
| 315 | self.no_shuffle = False | 316 | self.no_shuffle = False |
| 316 | self.stage = None | 317 | self.stage = None |
| 317 | self.sequence_parallel = False | 318 | self.sequence_parallel = False |
| @@ -55,26 +55,22 @@ def validate_rl_args( | |||
| 55 | if actor_config.context_parallel_size > 1 and actor_config.context_parallel_algo is not None: | 55 | if actor_config.context_parallel_size > 1 and actor_config.context_parallel_algo is not None: |
| 56 | if actor_config.context_parallel_algo not in ["ulysses_cp_algo", "megatron_cp_algo"]: | 56 | if actor_config.context_parallel_algo not in ["ulysses_cp_algo", "megatron_cp_algo"]: |
| 57 | raise ValueError("Now just support ulysses CP and megatron cp(ring)") | 57 | raise ValueError("Now just support ulysses CP and megatron cp(ring)") |
| 58 | - if actor_config.attention_mask_type not in ["causal"]: | 58 | + |
| 59 | - raise ValueError("Now just support causal attention_mask_type") | ||
| 60 | if actor_config.context_parallel_algo == "megatron_cp_algo" and actor_config.context_parallel_size > 1 and rl_config.use_remove_padding: | 59 | if actor_config.context_parallel_algo == "megatron_cp_algo" and actor_config.context_parallel_size > 1 and rl_config.use_remove_padding: |
| 61 | if not actor_config.reset_attention_mask: | 60 | if not actor_config.reset_attention_mask: |
| 62 | raise ValueError("when use ring cp and remove_padding, reset_attention_mask must be true") | 61 | raise ValueError("when use ring cp and remove_padding, reset_attention_mask must be true") |
| 63 | - if actor_config.context_parallel_size <= 1 or actor_config.context_parallel_algo != "megatron_cp_algo" or not rl_config.use_remove_padding: | ||
| 64 | - if actor_config.reset_attention_mask: | ||
| 65 | - raise ValueError("Just when use ring cp >=2 with remove_padding, reset_attention_mask must be true; otherwise should be false") | ||
| 66 | 62 | ||
| 67 | # 校验移除填充特性相关配置 | 63 | # 校验移除填充特性相关配置 |
| 68 | if rl_config.use_remove_padding: | 64 | if rl_config.use_remove_padding: |
| 69 | - if actor_config.pipeline_model_parallel_size > 1 and not actor_config.variable_seq_lengths: | 65 | + if actor_config.pipeline_model_parallel_size > 1 and not actor_config.no_pad_to_seq_lengths: |
| 70 | raise ValueError( | 66 | raise ValueError( |
| 71 | - "'use_remove_padding' feature requires 'variable_seq_lengths=True' when using pipeline parallelism!" | 67 | + "'use_remove_padding' feature requires 'no_pad_to_seq_lengths=True' when using pipeline parallelism!" |
| 72 | - "If you want to use context parallelism under this premise and encounter the mindspeed_llm validation error about variable_seq_lengths, " | 68 | + "If you want to use context parallelism under this premise and encounter the mindspeed_llm validation error about no_pad_to_seq_lengths, " |
| 73 | "you just need to delete the validation code of mindspeed_llm, and it will not cause problems.") | 69 | "you just need to delete the validation code of mindspeed_llm, and it will not cause problems.") |
| 74 | 70 | ||
| 75 | - if not actor_config.reset_position_ids: | 71 | + if not actor_config.reset_attention_mask: |
| 76 | raise ValueError( | 72 | raise ValueError( |
| 77 | - "'use_remove_padding' feature requires 'reset_position_ids=True'! ") | 73 | + "'use_remove_padding' feature requires 'reset_attention_mask=True'! ") |
| 78 | 74 | ||
| 79 | if rl_config.is_multimodal: | 75 | if rl_config.is_multimodal: |
| 80 | raise ValueError( | 76 | raise ValueError( |
| @@ -316,7 +316,7 @@ class BaseTrainingEngine(ABC): | |||
| 316 | cu_seqlens_padded_ring = cu_seqlens_padded | 316 | cu_seqlens_padded_ring = cu_seqlens_padded |
| 317 | if self.megatron_config.attention_mask_type == 'causal': | 317 | if self.megatron_config.attention_mask_type == 'causal': |
| 318 | cu_seqlens_padded_ring = (cu_seqlens_padded / get_ring_degree(self.megatron_config)).to(torch.int) | 318 | cu_seqlens_padded_ring = (cu_seqlens_padded / get_ring_degree(self.megatron_config)).to(torch.int) |
| 319 | - self.set_actual_seq_len(cu_seqlens_padded_ring.tolist()) | 319 | + self.set_actual_seq_len(cu_seqlens_padded_ring) |
| 320 | 320 | ||
| 321 | if cp_size > 1: | 321 | if cp_size > 1: |
| 322 | input_ids, position_ids, batch, index = self._get_batch_data_with_cp(batch, input_ids, position_ids, labels) | 322 | input_ids, position_ids, batch, index = self._get_batch_data_with_cp(batch, input_ids, position_ids, labels) |
| @@ -8,15 +8,12 @@ megatron_training: | |||
| 8 | use_mcore_models: true | 8 | use_mcore_models: true |
| 9 | sequence_parallel: true | 9 | sequence_parallel: true |
| 10 | use_flash_attn: true | 10 | use_flash_attn: true |
| 11 | - reset_position_ids: true | 11 | + reset_attention_mask: true |
| 12 | no_masked_softmax_fusion: true | 12 | no_masked_softmax_fusion: true |
| 13 | attention_softmax_in_fp32: true | 13 | attention_softmax_in_fp32: true |
| 14 | no_gradient_accumulation_fusion: true | 14 | no_gradient_accumulation_fusion: true |
| 15 | use_fused_swiglu: true | 15 | use_fused_swiglu: true |
| 16 | use_fused_rotary_pos_emb: true | 16 | use_fused_rotary_pos_emb: true |
| 17 | - use_ascend_coc: True | ||
| 18 | - coc_fused_kernel: True | ||
| 19 | - coc_parallel_num: 2 | ||
| 20 | bf16: true | 17 | bf16: true |
| 21 | use_distributed_optimizer: true | 18 | use_distributed_optimizer: true |
| 22 | tokenizer_type: PretrainedFromHF | 19 | tokenizer_type: PretrainedFromHF |
| @@ -31,7 +28,7 @@ megatron_training: | |||
| 31 | hidden_dropout: 0.0 | 28 | hidden_dropout: 0.0 |
| 32 | distributed_backend: nccl | 29 | distributed_backend: nccl |
| 33 | no_shared_storage: true | 30 | no_shared_storage: true |
| 34 | - variable_seq_lengths: true | 31 | + no_pad_to_seq_lengths: true |
| 35 | dataset_additional_keys: ['labels',] | 32 | dataset_additional_keys: ['labels',] |
| 36 | data_path: /data/for_dt/datasets/pe-nlp/data | 33 | data_path: /data/for_dt/datasets/pe-nlp/data |
| 37 | split: 100,0,0 | 34 | split: 100,0,0 |
| @@ -69,7 +69,7 @@ def make_megatron_config(args): | |||
| 69 | 'tokenizer_type': args.tokenizer_type, 'tokenizer_name_or_path': args.tokenizer_path, 'global_batch_size': 2, | 69 | 'tokenizer_type': args.tokenizer_type, 'tokenizer_name_or_path': args.tokenizer_path, 'global_batch_size': 2, |
| 70 | 'seq_length': 512, 'save_interval': 10000, | 70 | 'seq_length': 512, 'save_interval': 10000, |
| 71 | 'train_iters': 1000, 'distributed_backend': 'nccl', 'no_shared_storage': True, | 71 | 'train_iters': 1000, 'distributed_backend': 'nccl', 'no_shared_storage': True, |
| 72 | - 'variable_seq_lengths': True, 'micro_batch_size': 1, 'tensor_model_parallel_size': args.train_tp, | 72 | + 'no_pad_to_seq_lengths': True, 'micro_batch_size': 1, 'tensor_model_parallel_size': args.train_tp, |
| 73 | 'pipeline_model_parallel_size': args.train_pp, 'lr': '1e-7', 'lr_decay_style': 'constant', | 73 | 'pipeline_model_parallel_size': args.train_pp, 'lr': '1e-7', 'lr_decay_style': 'constant', |
| 74 | 'min_lr': 0.0, 'weight_decay': 0.0, 'lr_warmup_fraction': 0.0, 'clip_grad': 10000.0, | 74 | 'min_lr': 0.0, 'weight_decay': 0.0, 'lr_warmup_fraction': 0.0, 'clip_grad': 10000.0, |
| 75 | 'adam_beta1': 0.9, 'adam_beta2': 0.999, 'initial_loss_scale': 4096, 'finetune': True, | 75 | 'adam_beta1': 0.9, 'adam_beta2': 0.999, 'initial_loss_scale': 4096, 'finetune': True, |