Skip to content

[Bug] save_consolidated times out and truncates Gemma 4 31B safetensors with FSDP2/DTensor in v0.7.0 #3624

Open

Description

@vikalluru

Describe the bug

In NeMo-RL v0.7.0, exporting a consolidated Hugging Face checkpoint for google/gemma-4-31B-it with AutoModel, FSDP2, and DTensor v2 fails when consolidation takes longer than the Gloo process group's 30-minute default timeout.

With checkpointing.save_consolidated: true, ranks synchronize through dist.barrier() inside consolidate_safetensors_files_on_every_rank. In NFS-backed storage, gathering and writing the 31B checkpoint takes approximately 35–45 minutes. The Gloo process group times out after 30 minutes while rank 0 is still writing.

The failed job leaves truncated .safetensors files. These files cannot subsequently be loaded by Hugging Face Transformers, NeMo AutoModel, or SGLang.

This is a regression. The same model, hardware, topology, launch configuration, storage, and checkpoint complete successfully in approximately 43 minutes using the earlier NeMo-RL commit 37cb7de1a. The failure reproduces with NeMo-RL v0.7.0 and the intermediate nemo-rl-arm64.130 build.

Environment

  • NeMo-RL failing version: v0.7.0
  • Additional failing build: nemo-rl-arm64.130
  • Last known working NeMo-RL commit: 37cb7de1a
  • Model: google/gemma-4-31B-it
  • Model class: Gemma4ForConditionalGeneration
  • Backend: NeMo AutoModel
  • Distributed strategy: FSDP2 with DTensor v2
  • Hardware: GB200
  • Configurations tested:
    • 32 GPUs: 8 workers × 4 GPUs
    • 64 GPUs: 16 workers × 4 GPUs
  • Parallelism: TP=1, CP=4
  • CPU offload: enabled
  • Distributed backend: cuda:nccl,cpu:gloo
  • Model precision: BF16
  • Storage: NFS-backed shared storage
  • Python: 3.13
  • Exact container image: [ADD IMAGE AND TAG OR DIGEST]
  • PyTorch version: [ADD VERSION]
  • Ray version: [ADD VERSION]

Checkpoint configuration:

checkpointing:
  save_optimizer: false
  save_consolidated: true

Steps to reproduce

  1. Configure Gemma 4 31B training using the NeMo AutoModel FSDP2/DTensor v2 backend.

  2. Use a distributed configuration equivalent to:

tensor_parallel_size: 1
context_parallel_size: 4
cpu_offload: true

checkpointing:
  save_optimizer: false
  save_consolidated: true
  1. Run on 32 or 64 GB200 GPUs using shared storage where consolidation takes longer than 30 minutes.

  2. Allow training to save, or explicitly consolidate, a checkpoint.

  3. Observe non-writing ranks enter dist.barrier() while rank 0 continues writing the Hugging Face safetensors.

  4. After 30 minutes, observe the Gloo timeout:

File ".../consolidate_hf_safetensors.py", line 855, in consolidate_safetensors_files_on_every_rank
    dist.barrier()

File ".../torch/distributed/distributed_c10d.py", line 5037, in barrier
    work.wait()

RuntimeError: [/pytorch/third_party/gloo/gloo/transport/tcp/unbound_buffer.cc:78]
Timed out waiting 1800000ms for recv operation to complete
  1. Attempt to load the generated checkpoint using Transformers, AutoModel, or SGLang.

The load fails because one of the safetensors files is incomplete.

Expected behavior

Consolidation should be allowed to run for the time required to export a large model.

The distributed timeout should be configurable and propagated to the process groups used by the checkpoint-consolidation path.

A failed consolidation must not leave truncated files that appear to be completed checkpoint artifacts.

Actual behavior

The consolidation is terminated at the default 30-minute Gloo timeout.

The generated index declares a total model size of approximately 125 GB, but the first output shard is short by approximately 0.5–6.6 GB, depending on the run. The second shard completes successfully.

Loading the incomplete shard produces an error similar to:

SafetensorError: Error while deserializing header:
incomplete metadata, file not fully covered

Working workaround

Setting a longer timeout on every Ray worker before NeMo-RL initializes the distributed process group allows consolidation to complete:

from datetime import timedelta

import torch.distributed as dist

_original_init_process_group = dist.init_process_group


def patched_init_process_group(*args, **kwargs):
    if kwargs.get("timeout") is None:
        kwargs["timeout"] = timedelta(hours=4)
    return _original_init_process_group(*args, **kwargs)


dist.init_process_group = patched_init_process_group

With a four-hour timeout, the affected v0.7.0 consolidation completes successfully in approximately 43 minutes. This indicates that the checkpoint contents and storage path are otherwise functional.

Suspected cause

NeMo-RL initializes the AutoModel process group without an explicit timeout:

torch.distributed.init_process_group(backend=backend)

The CPU/Gloo group therefore uses PyTorch's 30-minute default. Large-model consolidation can legitimately exceed that timeout while other ranks wait at the post-write barrier.

The Python call appears unchanged between the working and failing builds. A bundled PyTorch, Gloo, Ray, or lower-level behavioral change may explain why the default timeout became observable in v0.7.0.

Activity

  1. added
    bug
    on Aug 13, 2026
  2. self-assigned this
    on Aug 14, 2026
  3. sharonyu-115 commented on Aug 15, 2026

    @sharonyu-115
    Contributor

    Hi @vikalluru, to trace down the reason of regression - "This is a regression. The same model, hardware, topology, launch configuration, storage, and checkpoint complete successfully in approximately 43 minutes using the earlier NeMo-RL commit 37cb7de. The failure reproduces with NeMo-RL v0.7.0 and the intermediate nemo-rl-arm64.130 build."

    Would you help check in the training driver and worker logs of 0.7.0 and 37cb7de1a, whether both of them contain the disabling async mode message?

    something like:

    [offload|B] ^[[36m(DTensorPolicyWorkerV2 pid=453847, ip=10.52.106.195)^[[0m ERROR:root:checkpointing.py:198: Async mode is only supported for torch >= 2.9.0, disabling async mode
    
  4. stevenmsm commented on Aug 18, 2026

    @stevenmsm

    @sharonyu-115 @vikalluru
    The 37cb7de commit's log contains the following message:
    "(DTensorPolicyWorkerV2 pid=3262, ip=10.241.35.126) ERROR:root:checkpointing.py:198: Async mode is only supported for torch >= 2.9.0, disabling async mode [repeated 31x across cluster]"

    The issue from the 0.7.0 image is that: (a) I cannot use save_consolidate=True during training as when saving checkpoint, it will nccl timeout (worker died); (b) after finished training with save_consolidate=False, I want to consolidate the weights so I have to submit a separate job to just do save_consolidate without training, i.e. load the weights and consolidate, and it will fail. Let's mainly focus on the problem (b) above. I mainly observe two different errors.

    1. The log didn't even reach to the disabling async mode message. Instead, it is just having the following error after initiating worker at 100%:
    """
    Initializing lm_policy workers: 100%|██████████| 32/32 [00:37<00:00,  1.17s/worker]
      ✓ 32 workers initialized in 37.48s
    [transformers] `torch_dtype` is deprecated! Use `dtype` instead!
    FLOPS tracker not supported for model /data/genAI/public_models/gemma-4-31B-it: Unsupported config type: <class 'transformers.models.gemma4.configuration_gemma4.Gemma4Config'>
    Traceback (most recent call last):
      File "/code/nemo_rl_training/train_dpo/oci/gemma_4_31b/consolidate_only.py", line 310, in <module>
        main()
        ~~~~^^
      File "/code/nemo_rl_training/train_dpo/oci/gemma_4_31b/consolidate_only.py", line 257, in main
        policy.print_node_ip_and_gpu_id()
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
      File "/opt/nemo-rl/nemo_rl/models/policy/lm_policy.py", line 1129, in print_node_ip_and_gpu_id
        results = ray.get(
            self.worker_group.run_all_workers_single_data(
                "report_node_ip_and_gpu_id",
            )
        )
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/auto_init_hook.py", line 22, in auto_init_wrapper
        return fn(*args, **kwargs)
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/client_mode_hook.py", line 107, in wrapper
        return func(*args, **kwargs)
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/worker.py", line 2980, in get
        values, debugger_breakpoint = worker.get_objects(
                                      ~~~~~~~~~~~~~~~~~~^
            object_refs, timeout, use_object_store=_use_object_store
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/worker.py", line 1025, in get_objects
        raise value
    ray.exceptions.ActorDiedError: The actor died unexpectedly before finishing this task.
    	class_name: DTensorPolicyWorkerV2
    	actor_id: d6596aea89e9024b5f13c8bb01000000
    	pid: 2246
    	name: lm_policy-0-0
    	namespace: 625b4168-3ff9-4c34-ac0f-2f0778151d12
    	ip: 10.241.43.22
    The actor is dead because its worker process has died. Worker exit type: SYSTEM_ERROR Worker exit detail: Failed to execute the setup hook method, ray_worker_pg_timeout_setup.setup_pg_timeout from ``ray.init(runtime_env={'worker_process_setup_hook': ray_worker_pg_timeout_setup.setup_pg_timeout})``. Please make sure the given module exists and is available from ray workers. For more details, see the error trace below.
    Traceback (most recent call last):
      File "/opt/ray_venvs/nemo_rl.models.policy.workers.dtensor_policy_worker_v2.DTensorPolicyWorkerV2/lib/python3.13/site-packages/ray/_private/runtime_env/setup_hook.py", line 208, in load_and_execute_setup_hook_module
        setup_func = load_class(worker_process_setup_hook_key)
      File "/opt/ray_venvs/nemo_rl.models.policy.workers.dtensor_policy_worker_v2.DTensorPolicyWorkerV2/lib/python3.13/site-packages/ray/_common/utils.py", line 367, in load_class
        module = importlib.import_module(module_path)
      File "/root/.local/share/uv/python/cpython-3.13.13-linux-aarch64-gnu/lib/python3.13/importlib/__init__.py", line 88, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
               ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap>", line 1395, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1324, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'ray_worker_pg_timeout_setup'
    
    The actor never ran - it was cancelled before it started running.
    (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. Lease ID: 2f0000009ad2cb6a30c255e885cc79ab66d7ebbf62676f0c12fb1b75e1033525 Worker ID: 7459cd7e052093372543a19ed604aa00f4130f3b1726f18790cb33e8 Node ID: e58638a01c822a91ebf34eaf37beafb01d1fcbefa40f1c2e169a2963 Worker IP address: 10.241.35.156 Worker port: 10020 Worker PID: 3109 Worker exit type: SYSTEM_ERROR Worker exit detail: Failed to execute the setup hook method, ray_worker_pg_timeout_setup.setup_pg_timeout from ``ray.init(runtime_env={'worker_process_setup_hook': ray_worker_pg_timeout_setup.setup_pg_timeout})``. Please make sure the given module exists and is available from ray workers. For more details, see the error trace below.
    Traceback (most recent call last):
      File "/opt/ray_venvs/nemo_rl.models.policy.workers.dtensor_policy_worker_v2.DTensorPolicyWorkerV2/lib/python3.13/site-packages/ray/_private/runtime_env/setup_hook.py", line 208, in load_and_execute_setup_hook_module
        setup_func = load_class(worker_process_setup_hook_key)
      File "/opt/ray_venvs/nemo_rl.models.policy.workers.dtensor_policy_worker_v2.DTensorPolicyWorkerV2/lib/python3.13/site-packages/ray/_common/utils.py", line 367, in load_class
        module = importlib.import_module(module_path)
      File "/root/.local/share/uv/python/cpython-3.13.13-linux-aarch64-gnu/lib/python3.13/importlib/__init__.py", line 88, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
               ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap>", line 1395, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1324, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'ray_worker_pg_timeout_setup'
     [repeated 27x across cluster]
    (IsolatedWorkerInitializer pid=2878, ip=10.241.35.156) W0807 20:01:49.731000 2878 /root/.cache/uv/archive-v0/jci1wrw8yxALN5I1/torch/utils/cpp_extension.py:140] No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda' [repeated 7x across cluster]
    Error removing placement group PlacementGroupID(b0d19836fc0b037674d55fb1b67101000000): sys.meta_path is None, Python is likely shutting down
    Error removing placement group PlacementGroupID(72ecc5255c77e32072389b01cedc01000000): sys.meta_path is None, Python is likely shutting down
    Error removing placement group PlacementGroupID(d60f4d26546199d821fb1e95a9b401000000): sys.meta_path is None, Python is likely shutting down
    Error removing placement group PlacementGroupID(0bef8f45bd79c71c47be9d211ed101000000): sys.meta_path is None, Python is likely shutting down
    Error removing placement group PlacementGroupID(2568583def9383a20b79316a272b01000000): sys.meta_path is None, Python is likely shutting down
    Error removing placement group PlacementGroupID(3aadace033430080d080f9e1683201000000): sys.meta_path is None, Python is likely shutting down
    Error removing placement group PlacementGroupID(01627d774b521bc54915052ea58901000000): sys.meta_path is None, Python is likely shutting down
    Error removing placement group PlacementGroupID(c12100d2bcbc054070333826928801000000): sys.meta_path is None, Python is likely shutting down
    [consolidate_only] injected worker_process_setup_hook + PYTHONPATH into ray.init runtime_env (PYTHONPATH prefix=/code/nemo_rl_training/train_dpo/oci/gemma_4_31b)
    Exception ignored in: <function Policy.__del__ at 0xf3cdd8736f20>
    Traceback (most recent call last):
      File "/opt/nemo-rl/nemo_rl/models/policy/lm_policy.py", line 1115, in __del__
      File "/opt/nemo-rl/nemo_rl/distributed/worker_groups.py", line 1071, in shutdown
      File "/opt/nemo-rl/nemo_rl/distributed/worker_groups.py", line 857, in run_all_workers_single_data
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/actor.py", line 917, in remote
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/auto_init_hook.py", line 21, in auto_init_wrapper
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/auto_init_hook.py", line 15, in auto_init_ray
      File "/code/nemo_rl_training/train_dpo/oci/gemma_4_31b/consolidate_only.py", line 125, in _patched_ray_init
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/client_mode_hook.py", line 107, in wrapper
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/worker.py", line 1760, in init
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/job_config.py", line 72, in __init__
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/job_config.py", line 155, in set_default_actor_lifetime
    ImportError: sys.meta_path is None, Python is likely shutting down
    """
    
    1. It is able to load the weights but failed to write consolidate (the weights are not fully written and tokenizer folder is empty):
    """
    +-----------------------------------------------------------------------------------+
    |                      Policy worker mapping to Nodes and GPUs                      |
    +---------------+----------------+----------------+----------------+----------------+
    |    Node_IP    |    GPU_ID=0    |    GPU_ID=1    |    GPU_ID=2    |    GPU_ID=3    |
    +---------------+----------------+----------------+----------------+----------------+
    | 10.241.34.243 | ('worker-24',) | ('worker-25',) | ('worker-26',) | ('worker-27',) |
    |  10.241.36.34 | ('worker-12',) | ('worker-13',) | ('worker-14',) | ('worker-15',) |
    |  10.241.37.56 | ('worker-16',) | ('worker-17',) | ('worker-18',) | ('worker-19',) |
    | 10.241.38.228 | ('worker-20',) | ('worker-21',) | ('worker-22',) | ('worker-23',) |
    | 10.241.42.149 | ('worker-8',)  | ('worker-9',)  | ('worker-10',) | ('worker-11',) |
    | 10.241.44.108 | ('worker-0',)  | ('worker-1',)  | ('worker-2',)  | ('worker-3',)  |
    | 10.241.44.169 | ('worker-28',) | ('worker-29',) | ('worker-30',) | ('worker-31',) |
    | 10.241.46.189 | ('worker-4',)  | ('worker-5',)  | ('worker-6',)  | ('worker-7',)  |
    +---------------+----------------+----------------+----------------+----------------+
      Weights loaded.
    
    Saving with save_consolidated=True to:
      /checkpoints/sft_mix-y2.5-1p_gemma-4-31B-it_light_LR8e-7_GBS64_W8_G4_L32768/step_1795_hf/policy/weights
      (this will take ~20-40 min for a 31B model — rank-0 gather + HF write)
    (DTensorPolicyWorkerV2[rank=14] pid=3046, ip=10.241.36.34) Saving checkpoint to /checkpoints/sft_mix-y2.5-1p_gemma-4-31B-it_light_LR8e-7_GBS64_W8_G4_L32768/step_1795_hf/policy/weights
    (DTensorPolicyWorkerV2 pid=3045, ip=10.241.36.34) Loading weights from /checkpoints/sft_mix-y2.5-1p_gemma-4-31B-it_light_LR8e-7_GBS64_W8_G4_L32768/step_1795/policy/weights [repeated 31x across cluster]
    Traceback (most recent call last):
      File "/code/nemo_rl_training/train_dpo/oci/gemma_4_31b/consolidate_only.py", line 323, in <module>
        main()
        ~~~~^^
      File "/code/nemo_rl_training/train_dpo/oci/gemma_4_31b/consolidate_only.py", line 299, in main
        policy.save_checkpoint(
        ~~~~~~~~~~~~~~~~~~~~~~^
            weights_path=save_weights_path,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        ...<2 lines>...
            checkpointing_cfg=checkpointing_cfg,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/opt/nemo-rl/nemo_rl/models/policy/lm_policy.py", line 1096, in save_checkpoint
        ray.get(futures)
        ~~~~~~~^^^^^^^^^
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/auto_init_hook.py", line 22, in auto_init_wrapper
        return fn(*args, **kwargs)
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/client_mode_hook.py", line 107, in wrapper
        return func(*args, **kwargs)
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/worker.py", line 2980, in get
        values, debugger_breakpoint = worker.get_objects(
                                      ~~~~~~~~~~~~~~~~~~^
            object_refs, timeout, use_object_store=_use_object_store
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/worker.py", line 1023, in get_objects
        raise value.as_instanceof_cause()
    ray.exceptions.RayTaskError(ValueError): ray::DTensorPolicyWorkerV2.save_checkpoint() (pid=2352, ip=10.241.44.108, actor_id=cb4ab7325428a36eb9c4314b01000000, repr=DTensorPolicyWorkerV2[rank=1])
      File "/opt/nemo-rl/nemo_rl/models/policy/workers/dtensor_policy_worker_v2.py", line 1314, in save_checkpoint
        self.checkpoint_manager.save_checkpoint(
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
            model=self.model,
            ^^^^^^^^^^^^^^^^^
        ...<8 lines>...
            peft_config=self.peft_config,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/opt/nemo-rl/nemo_rl/models/automodel/checkpoint.py", line 312, in save_checkpoint
        self.checkpointer.save_model(
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
            model=model,
            ^^^^^^^^^^^^
        ...<2 lines>...
            tokenizer=tokenizer if tokenizer_path is None else None,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/opt/ray_venvs/nemo_rl.models.policy.workers.dtensor_policy_worker_v2.DTensorPolicyWorkerV2/lib/python3.13/site-packages/torch/utils/_contextlib.py", line 124, in decorate_context
        return func(*args, **kwargs)
      File "/opt/nemo-rl/3rdparty/Automodel-workspace/Automodel/nemo_automodel/components/checkpoint/checkpointing.py", line 333, in save_model
        consolidate_safetensors_files_on_every_rank(
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
            input_dir=model_dir,
            ^^^^^^^^^^^^^^^^^^^^
        ...<4 lines>...
            staging_dir=self.config.staging_dir,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/opt/nemo-rl/3rdparty/Automodel-workspace/Automodel/nemo_automodel/components/checkpoint/_backports/consolidate_hf_safetensors.py", line 832, in consolidate_safetensors_files_on_every_rank
        _consolidate_safetensors_files(
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
            input_dir=input_dir,
            ^^^^^^^^^^^^^^^^^^^^
        ...<4 lines>...
            staging_dir=staging_dir,
            ^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/opt/nemo-rl/3rdparty/Automodel-workspace/Automodel/nemo_automodel/components/checkpoint/_backports/consolidate_hf_safetensors.py", line 694, in _consolidate_safetensors_files
        _write_data(input_files_data, output_files_data, num_threads)
        ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/nemo-rl/3rdparty/Automodel-workspace/Automodel/nemo_automodel/components/checkpoint/_backports/consolidate_hf_safetensors.py", line 334, in _write_data
        _process_output_file(output_file, output_data, input_files_data)
        ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/nemo-rl/3rdparty/Automodel-workspace/Automodel/nemo_automodel/components/checkpoint/_backports/consolidate_hf_safetensors.py", line 290, in _process_output_file
        data_to_write = _read_tensor_data_mmap(
            safetensors_file,
        ...<2 lines>...
            input_metadata_size,
        )
      File "/opt/nemo-rl/3rdparty/Automodel-workspace/Automodel/nemo_automodel/components/checkpoint/_backports/consolidate_hf_safetensors.py", line 239, in _read_tensor_data_mmap
        with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as mm:
             ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ValueError: cannot mmap an empty file
    (DTensorPolicyWorkerV2[rank=3] pid=2354, ip=10.241.44.108) Saving checkpoint to /checkpoints/sft_mix-y2.5-1p_gemma-4-31B-it_light_LR8e-7_GBS64_W8_G4_L32768/step_1795_hf/policy/weights [repeated 31x across cluster]
    (DTensorPolicyWorkerV2 pid=2669, ip=10.241.44.169) `torch_dtype` is deprecated! Use `dtype` instead! [repeated 7x across cluster]
    (DTensorPolicyWorkerV2 pid=3044, ip=10.241.36.34) /opt/ray_venvs/nemo_rl.models.policy.workers.dtensor_policy_worker_v2.DTensorPolicyWorkerV2/lib/python3.13/site-packages/torch/distributed/device_mesh.py:722: UserWarning: Slicing a flattened dim from root mesh will be deprecated in PT 2.11. Users need to bookkeep the flattened mesh directly.  [repeated 31x across cluster]
    (DTensorPolicyWorkerV2 pid=3044, ip=10.241.36.34)   sliced_mesh_layout = self._get_slice_mesh_layout(mesh_dim_names) [repeated 31x across cluster]
    (DTensorPolicyWorkerV2 pid=3044, ip=10.241.36.34) ERROR:root:checkpointing.py:198: Async mode is only supported for torch >= 2.9.0, disabling async mode [repeated 31x across cluster]
    (DTensorPolicyWorkerV2 pid=3046, ip=10.241.36.34) WARNING:root:checkpointing.py:188: save_consolidated=True but v4_compatible=False; checkpoint assets may be not compatible with transformers v4; [experimental] set --checkpoint.v4_compatible=True to enable [repeated 31x across cluster]
    [consolidate_only] injected worker_process_setup_hook, py_modules, and PYTHONPATH into ray.init runtime_env (module=/code/nemo_rl_training/train_dpo/oci/gemma_4_31b/ray_worker_pg_timeout_setup.py)
    2026-08-17 21:30:51,476	INFO worker.py:1814 -- Connecting to existing Ray cluster at address: 10.241.46.189:6379...
    2026-08-17 21:30:51,492	INFO worker.py:2003 -- Connected to Ray cluster. View the dashboard at http://10.241.46.189:8265 
    Exception ignored in: <function Policy.__del__ at 0xe241b2ef6fc0>
    Traceback (most recent call last):
      File "/opt/nemo-rl/nemo_rl/models/policy/lm_policy.py", line 1115, in __del__
        self.worker_group.shutdown(cleanup_method="shutdown")
      File "/opt/nemo-rl/nemo_rl/distributed/worker_groups.py", line 1071, in shutdown
        futures = self.run_all_workers_single_data(cleanup_method)
      File "/opt/nemo-rl/nemo_rl/distributed/worker_groups.py", line 857, in run_all_workers_single_data
        futures.append(method.remote(*args, **kwargs))
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/actor.py", line 917, in remote
        return self._remote(args, kwargs)
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/auto_init_hook.py", line 21, in auto_init_wrapper
        auto_init_ray()
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/auto_init_hook.py", line 15, in auto_init_ray
        ray.init()
      File "/code/nemo_rl_training/train_dpo/oci/gemma_4_31b/consolidate_only.py", line 138, in _patched_ray_init
        return _orig_ray_init(*args, **kwargs)
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/client_mode_hook.py", line 107, in wrapper
        return func(*args, **kwargs)
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/worker.py", line 2014, in init
        connect(
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/worker.py", line 1143, in wrapper
        return func(*args, **kwargs)
      File "/opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_private/worker.py", line 2697, in connect
        worker.core_worker = ray._raylet.CoreWorker(
      File "python/ray/_raylet.pyx", line 2855, in ray._raylet.CoreWorker.__cinit__
      File "/root/.local/share/uv/python/cpython-3.13.13-linux-aarch64-gnu/lib/python3.13/threading.py", line 976, in start
        _start_joinable_thread(self._bootstrap, handle=self._handle,
    PythonFinalizationError: can't create new thread at interpreter shutdown
    [consolidate_only] injected worker_process_setup_hook, py_modules, and PYTHONPATH into ray.init runtime_env (module=/code/nemo_rl_training/train_dpo/oci/gemma_4_31b/ray_worker_pg_timeout_setup.py)
    2026-08-17 21:30:51,573	INFO worker.py:1814 -- Connecting to existing Ray cluster at address: 10.241.46.189:6379...
    2026-08-17 21:30:51,585	INFO worker.py:2003 -- Connected to Ray cluster. View the dashboard at http://10.241.46.189:8265 
    [2026-08-17 21:30:51,657 C 1719 1719] core_worker_process.cc:88:  An unexpected system state has occurred. You have likely discovered a bug in Ray. Please report this issue at https://github.com/ray-project/ray/issues and we'll work with you to fix it. Check failed: !core_worker_process The process is already initialized for core worker.
    *** StackTrace Information ***
    /opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_raylet.so(+0x167a578) [0xe246261ea578] ray::operator<<()
    /opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_raylet.so(_ZN3ray6RayLogD1Ev+0x5d8) [0xe246261ed018] ray::RayLog::~RayLog()
    /opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_raylet.so(_ZN3ray4core17CoreWorkerProcess10InitializeERKNS0_17CoreWorkerOptionsE+0xe0) [0xe246255b7930] ray::core::CoreWorkerProcess::Initialize()
    /opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_raylet.so(+0x91ffb0) [0xe2462548ffb0] __pyx_pw_3ray_7_raylet_10CoreWorker_1__cinit__()
    /opt/nemo_rl_venv/lib/python3.13/site-packages/ray/_raylet.so(+0x9219b8) [0xe246254919b8] __pyx_tp_new_3ray_7_raylet_CoreWorker()
    /opt/nemo_rl_venv/bin/python3(+0x356f64) [0xb91fa9236f64] type_call
    /opt/nemo_rl_venv/bin/python3(_PyEval_EvalFrameDefault+0x9c58) [0xb91fa9280d0c] _PyEval_EvalFrameDefault
    /opt/nemo_rl_venv/bin/python3(PyObject_CallOneArg+0x70) [0xb91fa91d8a5c] PyObject_CallOneArg
    /opt/nemo_rl_venv/bin/python3(+0x4c14a8) [0xb91fa93a14a8] slot_tp_finalize
    /opt/nemo_rl_venv/bin/python3(+0x35f8b0) [0xb91fa923f8b0] subtype_dealloc
    /opt/nemo_rl_venv/bin/python3(+0x3602b4) [0xb91fa92402b4] subtype_dealloc
    /opt/nemo_rl_venv/bin/python3(+0x3602b4) [0xb91fa92402b4] subtype_dealloc
    /opt/nemo_rl_venv/bin/python3(+0x3064d8) [0xb91fa91e64d8] frame_dealloc
    /opt/nemo_rl_venv/bin/python3(+0x4162a8) [0xb91fa92f62a8] tb_dealloc
    /opt/nemo_rl_venv/bin/python3(+0x416284) [0xb91fa92f6284] tb_dealloc
    /opt/nemo_rl_venv/bin/python3(PyDict_SetItem+0xaa0) [0xb91fa920f214] PyDict_SetItem
    /opt/nemo_rl_venv/bin/python3(+0x584e54) [0xb91fa9464e54] _PySys_ClearAttrString
    /opt/nemo_rl_venv/bin/python3(+0x575e60) [0xb91fa9455e60] finalize_modules
    /opt/nemo_rl_venv/bin/python3(+0x575590) [0xb91fa9455590] _Py_Finalize.llvm.16330752704997765902
    /opt/nemo_rl_venv/bin/python3(Py_RunMain+0x21c) [0xb91fa9472e80] Py_RunMain
    /opt/nemo_rl_venv/bin/python3(+0x593624) [0xb91fa9473624] pymain_main.llvm.15101424977736502305
    /opt/nemo_rl_venv/bin/python3(+0x441cb0) [0xb91fa9321cb0] main
    /lib/aarch64-linux-gnu/libc.so.6(+0x284c4) [0xe24626f484c4]
    /lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98) [0xe24626f48598] __libc_start_main
    /opt/nemo_rl_venv/bin/python3(+0x441ba0) [0xb91fa9321ba0]
    """
    
  5. sharonyu-115 commented on Aug 20, 2026

    @sharonyu-115
    Contributor

    Hi @stevenmsm, Thank you for the information. Here is the update after some further analysis:

    • We are upgrading the Automodel submodule to r0.6.0 in build(automodel): bump Automodel to r0.6.0 #3498. We verified that Automodel v0.6.0 gives consolidation its own Gloo group with a consolidation_timeout_minutes setting on both the inline and async paths, a group-aware barrier, the index moved after the barrier. With that update, you will be enabled to specify a consolidation_timeout_minutes value to avoid timeout, plus staging_dir so even a failed consolidation can no longer publish a truncated shard. Here are the related Automodel side of PRs carrying the enhancements: fix(checkpoint): isolate consolidation timeout from NCCL Automodel#3108, feat(checkpoint): defer distributed async consolidation Automodel#3125. Will keep you posted on the status of build(automodel): bump Automodel to r0.6.0 #3498.

    • For problem (b) you mentioned above, I see you are using your own customized script consolidate_only.py, Automodel ships an
      offline tool that does the disk-to-disk merge: 3rdparty/Automodel-workspace/Automodel/tools/offline_hf_consolidation.py. Have you tried if this script works for you?

    • Besides, I'd like to confirm whether the patched_init_process_group workaround mentioned above unblock you with using save_consolidate=True?

  6. stevenmsm commented on Sep 1, 2026

    @stevenmsm

    Hi @sharonyu-115, your suggested "3rdparty/Automodel-workspace/Automodel/tools/offline_hf_consolidation.py" works for me. Thanks for the help!

  7. vikalluru commented on Sep 4, 2026

    @vikalluru
    Author

    @sharonyu-115 - can you close the issue if it works for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions