ROLL icon indicating copy to clipboard operation
ROLL copied to clipboard

Error occurs when saving the model during megtron training

Open mst272 opened this issue 1 year ago • 5 comments

An error occurred when saving at step 100

The error is as follows:

(ActorWorker(reference-2) pid=12088, ip=172.19.255.125) Elapsed time: 0.4288 seconds
(ActorWorker(reference-0) pid=11942, ip=172.19.255.125) Elapsed time: 59.2630 seconds [repeated 8x across cluster]
Traceback (most recent call last):
  File "/ROLL/examples/start_rlvr_pipeline.py", line 37, in <module>
    main()
  File "/ROLL/examples/start_rlvr_pipeline.py", line 33, in main
    pipeline.run()
  File "/opt/conda/envs/verl_hiyouga/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
  File "/ROLL/roll/pipeline/rlvr/rlvr_pipeline.py", line 528, in run
    self.do_checkpoint(global_step=global_step)
  File "/ROLL/roll/pipeline/base_pipeline.py", line 82, in do_checkpoint
    ckpt_metrics = DataProto.materialize_concat(data_refs=ckpt_metrics_refs)
  File "/ROLL/roll/distributed/scheduler/protocol.py", line 734, in materialize_concat
    data = ray.get(data_refs, timeout=timeout)
  File "/opt/conda/envs/verl_hiyouga/lib/python3.10/site-packages/ray/_private/auto_init_hook.py", line 21, in auto_init_wrapper
    return fn(*args, **kwargs)
  File "/opt/conda/envs/verl_hiyouga/lib/python3.10/site-packages/ray/_private/client_mode_hook.py", line 103, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/envs/verl_hiyouga/lib/python3.10/site-packages/ray/_private/worker.py", line 2771, in get
    values, debugger_breakpoint = worker.get_objects(object_refs, timeout=timeout)
  File "/opt/conda/envs/verl_hiyouga/lib/python3.10/site-packages/ray/_private/worker.py", line 893, in get_objects
    ] = self.core_worker.get_objects(
  File "python/ray/_raylet.pyx", line 3189, in ray._raylet.CoreWorker.get_objects
  File "python/ray/includes/common.pxi", line 85, in ray._raylet.check_status
ray.exceptions.GetTimeoutError: Get timed out: some object(s) not ready.
(ActorWorker(reference-6) pid=12093, ip=172.19.255.125) Elapsed time: 61.3996 seconds [repeated 23x across cluster]

The example is as follows::

hydra:
  run:
    dir: .
  output_subdir: null

exp_name: "qwen3-code-moe"
seed: 42
logging_dir: ./output/logs
output_dir: ./output
system_envs:
  USE_MODELSCOPE: '1'


checkpoint_config:
  type: file_system
  output_dir: /ROLL/outputcheckpoint

track_with: tensorboard
tracker_kwargs:
  log_dir: ./rl_examples/llm/tensorboard/roll_exp/rlvr

num_gpus_per_node: 8

max_steps: 500
save_steps: 100
logging_steps: 1
eval_steps: 10
resume_from_checkpoint: false


rollout_batch_size: 64  # prompt
prompt_length: 2048
response_length: 4096

num_return_sequences_in_group: 8
ppo_epochs: 1
adv_estimator: "reinforce"

# clip
value_clip: 0.5
reward_clip: 10
advantage_clip: 2.0
dual_clip_loss: true

# normalize
reward_norm: null
reward_shift: false
reward_scale: false

# data mask
max_len_mask: true
difficulty_mask: true
difficulty_low_threshold: 0.1
difficulty_high_threshold: 0.95
error_max_len_clip: false

# data weight
difficulty_loss_weight: false
length_loss_weight: false

# reward
add_token_level_kl: false

# advantage
whiten_advantages: true

# dynamic sampling scheduler
# use_additional_prompts: true
# max_running_requests: 256
# is_num_return_sequences_expand: false

pretrain: /Qwen/Qwen3-Coder-30B-A3B-Instruct 
reward_pretrain: Qwen/Qwen3-Coder-30B-A3B-Instruct

validation:
  data_args:
    template: qwen3
    file_name:
      - data/code_KodCode_data.jsonl
  generating_args:
    max_new_tokens: ${response_length}
    top_p: 0.6
    top_k: 50
    num_beams: 1
    temperature: 0.7
    num_return_sequences: 1


actor_train:
  model_args:
    disable_gradient_checkpointing: false
    dtype: bf16
    model_type: ~
  training_args:
    learning_rate: 1.0e-6
    weight_decay: 0
    per_device_train_batch_size: 1
    gradient_accumulation_steps: 8
    warmup_steps: 20
    num_train_epochs: 50
  data_args:
    template: qwen3
    file_name:
      - data/code_KodCode_data.jsonl
    domain_interleave_probs:
      code_sandbox: 1.0
    dataset_dir: data
    messages: messages
    interleave_probs: "1.0"
    preprocessing_num_workers: 16
  strategy_args:
    strategy_name: megatron_train
    strategy_config:
      tensor_model_parallel_size: 4
      pipeline_model_parallel_size: 4
      expert_model_parallel_size: 2
      use_distributed_optimizer: true
      recompute_granularity: full
  device_mapping: list(range(0,32))
  infer_batch_size: 4

actor_infer:
  model_args:
    disable_gradient_checkpointing: true
    dtype: bf16
  generating_args:
    max_new_tokens: ${response_length}
    top_p: 0.99
    top_k: 100
    num_beams: 1
    temperature: 0.99
    num_return_sequences: ${num_return_sequences_in_group}
  data_args:
    template: qwen3
  strategy_args:
    strategy_name: vllm
    strategy_config:
      tensor_parallel_size: 8
      gpu_memory_utilization: 0.8
      block_size: 16
      max_model_len: 8000
  device_mapping: list(range(32,48))
  infer_batch_size: 1

reference:
  model_args:
    disable_gradient_checkpointing: true
    dtype: bf16
    model_type: ~
  data_args:
    template: qwen3
  strategy_args:
    strategy_name: megatron_infer
    strategy_config:
      tensor_model_parallel_size: 4
      pipeline_model_parallel_size: 2
      expert_model_parallel_size: 2
  device_mapping: list(range(48,64))
  infer_batch_size: 8

rewards:
  code_sandbox:
    use_local: true
    worker_cls: roll.pipeline.rlvr.rewards.code_sandbox_reward_worker.CodeSandboxRewardWorker
    tag_included: [KodCode]
    model_args:
      model_name_or_path: ${reward_pretrain}
    data_args:
      template: qwen3
    world_size: 8
    infer_batch_size: 1
  math_rule:
    worker_cls: roll.pipeline.rlvr.rewards.math_rule_reward_worker.MathRuleRewardWorker
    model_args:
      model_name_or_path: ${reward_pretrain}
    data_args:
      template: qwen3
    tag_included: [deepmath_103k, aime]
    world_size: 8
    infer_batch_size: 1

mst272 avatar Sep 02 '25 01:09 mst272

any progress? Looking forward for your reply.

bingnoi77 avatar Mar 13 '26 15:03 bingnoi77

We haven't encountered this problem. That's a bit strange. Could you provide more information?

PanAndy avatar Mar 13 '26 15:03 PanAndy

我们是在训练Qwen3.5-35B的时候遇到了这个问题,保存模型权重的时候出现了RAY的oom的问题: ` (ActorWorker(actor_train-8-G0) pid=27394, ip=178.28.35.69) [2026-03-13 23:16:19,652] [INFO] [mcore_adapter.checkpointing]: Saving model checkpoint to ./output/actor_train-8-G0/checkpoint-1/iter_0000001/mp_rank_00_001_000/model_optim_rng.pt Traceback (most recent call last): File "/mnt/tenant-home_speed/lixinhao/ROLL/examples/start_rlvr_pipeline.py", line 36, in main() File "/mnt/tenant-home_speed/lixinhao/ROLL/examples/start_rlvr_pipeline.py", line 32, in main pipeline.run() File "/usr/local/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 124, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/mnt/tenant-home_speed/lixinhao/ROLL/roll/pipeline/rlvr/rlvr_pipeline.py", line 712, in run self.do_checkpoint(global_step=global_step) File "/mnt/tenant-home_speed/lixinhao/ROLL/roll/pipeline/base_pipeline.py", line 94, in do_checkpoint ckpt_metrics = DataProto.materialize_concat(data_refs=ckpt_metrics_refs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/mnt/tenant-home_speed/lixinhao/ROLL/roll/distributed/scheduler/protocol.py", line 854, in materialize_concat data: List["DataProto"] = ray.get(data_refs, timeout=timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/ray/_private/auto_init_hook.py", line 22, in auto_init_wrapper return fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/ray/_private/client_mode_hook.py", line 104, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/ray/_private/worker.py", line 2858, in get values, debugger_breakpoint = worker.get_objects(object_refs, timeout=timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/ray/_private/worker.py", line 960, in get_objects raise value ray.exceptions.ActorDiedError: The actor died unexpectedly before finishing this task. class_name: ActorWorker actor_id: 0bf5f7faad70199b186fe9701c000000 pid: 27397 name: actor_train-11-G3 namespace: roll ip: 178.28.35.69 The actor is dead because its worker process has died. Worker exit type: SYSTEM_ERROR Worker exit detail: Worker unexpectedly exits with a connection error code 2. End of file. There are some potential root causes. (1) The process is killed by SIGKILL by OOM killer due to high memory usage. (2) ray stop --force is called. (3) The worker is crashed unexpectedly due to SIGSEGV or other unexpected errors. (ActorWorker(actor_train-8-G0) pid=27394, ip=178.28.35.69) INFO:mcore_adapter.checkpointing:Saving model checkpoint to ./output/actor_train-8-G0/checkpoint-1/iter_0000001/mp_rank_00_001_000/model_optim_rng.pt (raylet) A worker died or was killed while executing a task by an unexpected system error. To troubleshoot the problem, check the logs for the dead worker. RayTask ID: ffffffffffffffffd79c3443157d1994b78887441c000000 Worker ID: 5499bae5782db38534db2ddc3863c08acfec44838170d2442fb7a2bc Node ID: 0557983668aea9b7da78518694dfbf1308a433b7f7bd8266d3947fc3 Worker IP address: 178.28.35.69 Worker port: 10126 Worker PID: 27396 Worker exit type: SYSTEM_ERROR Worker exit detail: Worker unexpectedly exits with a connection error code 2. End of file. There are some potential root causes. (1) The process is killed by SIGKILL by OOM killer due to high memory usage. (2) ray stop --force is called. (3) The worker is crashed unexpectedly due to SIGSEGV or other unexpected errors.

`

训练参数为

` defaults:

  • ../config/deepspeed_zero@here
  • ../config/deepspeed_zero2@here
  • ../config/deepspeed_zero3@here
  • ../config/deepspeed_zero3_cpuoffload@here

hydra: run: dir: . output_subdir: null

exp_name: "qwen3_5_35BA3_rlvr" seed: 42 rpc_timeout: 72000 # Ray RPC 超时(秒),rollout 生成 1024 条 8k 较慢时可适当调大,默认 3600 logging_dir: ./output/logs output_dir: ./output

checkpoint_config: type: file_system output_dir:

track_with: tensorboard tracker_kwargs: log_dir: ./output/tensorboard

max_steps: 500 save_steps: 1 eval_steps: 20 logging_steps: 1 resume_from_checkpoint: false

async_generation_ratio: 1

rollout_batch_size: 256 num_return_sequences_in_group: 8 is_num_return_sequences_expand: true prompt_length: 2048 response_length: 8192

ppo_epochs: 1 value_clip: 0.5 reward_clip: 10 advantage_clip: 10.0 whiten_advantages: false init_kl_coef: 0.0 adv_estimator: "grpo" use_kl_loss: false kl_loss_coef: 0.0

pretrain:

tag_2_domain: 3GPP_Network_Analysis: qa_accuracy 3GPP: qa_accuracy

validation: data_args: file_name: - dataset_dir: ./ preprocessing_num_workers: 32 generating_args: max_new_tokens: ${response_length} top_p: 0.99 top_k: 100 num_beams: 1 temperature: 0.99 num_return_sequences: 1 eval_steps: ${eval_steps}

actor_train: model_args: flash_attn: sdpa attn_implementation: sdpa disable_gradient_checkpointing: false dtype: bf16 model_type: ~ freeze_module_prefix: vision_model training_args: learning_rate: 3.0e-6 weight_decay: 1.0e-2 per_device_train_batch_size: 1 gradient_accumulation_steps: 128 warmup_steps: 0 num_train_epochs: 50 data_args: file_name: - dataset_dir: ./ messages: prompt preprocessing_num_workers: 32 domain_interleave_probs: qa_accuracy: 1.0 strategy_args: strategy_name: megatron_train strategy_config: # optimizer_cpu_offload: true # optimizer_offload_fraction: 0.1 sequence_parallel: true tensor_model_parallel_size: 1 context_parallel_size: 1 expert_model_parallel_size: 4 pipeline_model_parallel_size: 2 use_distributed_optimizer: true moe_token_dispatcher_type: alltoall recompute_granularity: full recompute_modules: "moe,layernorm" bias_activation_fusion: true apply_rope_fusion: true moe_grouped_gemm: true moe_shared_expert_overlap: true bf16: true device_mapping: list(range(0,16)) infer_batch_size: 1

actor_infer: model_args: flash_attn: fa2 attn_implementation: fa2 disable_gradient_checkpointing: true dtype: bf16 generating_args: max_new_tokens: ${response_length} top_p: 0.99 top_k: 100 num_beams: 1 temperature: 0.99 num_return_sequences: ${num_return_sequences_in_group} strategy_args: strategy_name: vllm strategy_config: gpu_memory_utilization: 0.8 max_model_len: 10240 load_format: dummy enforce_eager: true tensor_parallel_size: 2 num_gpus_per_worker: 8 device_mapping: list(range(16,32)) infer_batch_size: 1

reference: model_args: flash_attn: sdpa attn_implementation: sdpa disable_gradient_checkpointing: true dtype: bf16 model_type: ~ strategy_args: strategy_name: megatron_infer strategy_config: sequence_parallel: true tensor_model_parallel_size: 1 context_parallel_size: 1 pipeline_model_parallel_size: 1 expert_model_parallel_size: 2 bf16: true device_mapping: list(range(0,32)) infer_batch_size: 1

rewards: qa_accuracy: worker_cls: roll.pipeline.rlvr.rewards.multiple_choice_boxed_rule_reward_worker.MultipleChoiceBoxedRuleRewardWorker model_args: model_name_or_path: ${pretrain} tag_included: [3GPP_Network_Analysis, 3GPP] world_size: 8 infer_batch_size: 1

`

bingnoi77 avatar Mar 13 '26 16:03 bingnoi77

增加vllm sleep_level: 2,减小内存开销。

strategy_name: vllm
strategy_config:
    gpu_memory_utilization: 0.8
    max_model_len: 10240
    load_format: dummy
    enforce_eager: true
    tensor_parallel_size: 2
    sleep_level: 2

PanAndy avatar Mar 13 '26 16:03 PanAndy

已经增加了对应的配置,依然出现了内存oom的问题,我看核心的资源全都消耗在ray::ActorWorker.do_checkpoint这个函数上,请问您还有什么别的建议嘛。 Memory on the node (IP: 178.28.52.36, ID: 2d56b246d49abb6cef03b6ddb5b6183ad5bed5f258c4b15ceffb01a2) where the task (actor ID: f34d5fdbc52eb078cca88fef2e000000, name=actor_train-8-G0:ActorWorker.__init__, pid=33564, memory used=90.39GB) was running was 788.25GB / 800.00GB (0.985315), which exceeds the memory usage threshold of 0.95. Ray killed this worker (ID: 7e3fc26a3ee36549929dad67a49c940517bcbe2e0b0db80a78a3c8f5) because it was the most recently scheduled task; to see more information about memory usage on this node, useray logs raylet.out -ip 178.28.52.36. To see the logs of the worker, use ray logs worker-7e3fc26a3ee36549929dad67a49c940517bcbe2e0b0db80a78a3c8f5*out -ip 178.28.52.36. Top 10 memory users: PID MEM(GB) COMMAND 33570 106.18 ray::ActorWorker.do_checkpoint 33571 106.17 ray::ActorWorker.do_checkpoint 33569 105.95 ray::ActorWorker.do_checkpoint 33567 104.45 ray::ActorWorker.do_checkpoint 33564 90.39 ray::ActorWorker.do_checkpoint 33566 90.35 ray::ActorWorker.do_checkpoint 33568 89.91 ray::ActorWorker.do_checkpoint 33565 88.93 ray::ActorWorker.do_checkpoint `

bingnoi77 avatar Mar 14 '26 01:03 bingnoi77