NVIDIA-NeMo / NVIDIA-NeMo/RL

Use Nsight System to profile Qwen3-32B will generate errors with Megatron backend

Open
#1,064 4 comments 0 reactions 1 assignee Claimed by @guyueh1 View on GitHub
bug i-sa
Dominant language
Python
Stars
2k
Forks
561
Avg merge
4d 5h
Merged PRs (30d)
145

Description

**Describe the bug**

Profile the RL of Qwen3-32B with Megatron backend could not successfully executed.

**Steps/Code to reproduce bug**
Generate the docker image with our [official method](https://docs.nvidia.com/nemo/rl/latest/docker.html#release-image)

The slurm-based script is as follows:
```bash
#!/bin/bash
NUM_ACTOR_NODES=8
#MODEL_PATH="/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/Qwen3-32B"
MODEL_PATH="/lustre/fs1/portfolios/coreai/users/jzhai/Qwen3_32B/Qwen3_32B_finetuning_ckpt/2025-08-20_02-32-31/checkpoints/converted_hf_ckpt"

VLLM_TP=4

TRAIN_TP=8

## Nsight parameters settings
NRL_NSYS_PROFILE_STEP_RANGE=1:6
NRL_NSYS_WORKER_PATTERNS="*policy*,*vllm*"
LD_LIBRARY_PATH="/usr/local/cuda/targets/x86_64-linux/lib:/usr/local/cuda/lib64:/usr/local/cuda/lib:/usr/local/nvidia/lib64:/usr/local/nvidia/lib:/usr/lib/x86_64-linux-gnu"
NUM_SEC=600
export RAY_LOG_SYNC_FREQUENCY=$NUM_SEC

##############################

read -r -d '' COMMAND <
main()
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/./examples/run_grpo_math.py", line 253, in main
) = setup(config, tokenizer, dataset, val_dataset)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/nemo_rl/algorithms/grpo.py", line 345, in setup
policy = Policy(
^^^^^^^
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/nemo_rl/models/policy/lm_policy.py", line 137, in __init__
self.worker_group = RayWorkerGroup(
^^^^^^^^^^^^^^^
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/nemo_rl/distributed/worker_groups.py", line 394, in __init__
self._create_workers_from_bundle_indices(
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/nemo_rl/distributed/worker_groups.py", line 549, in _create_workers_from_bundle_indices
workers = ray.get(worker_refs)
^^^^^^^^^^^^^^^^^^^^
File "/opt/nemo_rl_venv/lib/python3.12/site-packages/ray/_private/auto_init_hook.py", line 21, in auto_init_wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/nemo_rl_venv/lib/python3.12/site-packages/ray/_private/client_mode_hook.py", line 103, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/nemo_rl_venv/lib/python3.12/site-packages/ray/_private/worker.py", line 2822, in get
values, debugger_breakpoint = worker.get_objects(object_refs, timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/nemo_rl_venv/lib/python3.12/site-packages/ray/_private/worker.py", line 930, in get_objects
raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(OSError): ray::IsolatedWorkerInitializer.create_worker() (pid=709952, ip=10.65.16.73, actor_id=f10ab4c46a1416a189b63a3401000000, repr=)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/nemo_rl/distributed/worker_groups.py", line 165, in create_worker
module = importlib.import_module(module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 999, in exec_module
File "", line 488, in _call_with_frames_removed
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/nemo_rl/models/policy/megatron_policy_worker.py", line 25, in
from megatron.bridge import AutoBridge
File "/opt/nemo-rl/3rdparty/Megatron-Bridge-workspace/Megatron-Bridge/src/megatron/bridge/__init__.py", line 16, in
from megatron.bridge.models.conversion.auto_bridge import AutoBridge
File "/opt/nemo-rl/3rdparty/Megatron-Bridge-workspace/Megatron-Bridge/src/megatron/bridge/models/__init__.py", line 16, in
from megatron.bridge.models.conversion.auto_bridge import AutoBridge
File "/opt/nemo-rl/3rdparty/Megatron-Bridge-workspace/Megatron-Bridge/src/megatron/bridge/models/conversion/__init__.py", line 16, in
from megatron.bridge.models.conversion.auto_bridge import AutoBridge
File "/opt/nemo-rl/3rdparty/Megatron-Bridge-workspace/Megatron-Bridge/src/megatron/bridge/models/conversion/auto_bridge.py", line 22, in
from megatron.core.transformer.module import MegatronModule
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/3rdparty/Megatron-LM-workspace/Megatron-LM/megatron/core/__init__.py", line 3, in
import megatron.core.tensor_parallel
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/3rdparty/Megatron-LM-workspace/Megatron-LM/megatron/core/tensor_parallel/__init__.py", line 4, in
from .layers import (
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/3rdparty/Megatron-LM-workspace/Megatron-LM/megatron/core/tensor_parallel/layers.py", line 30, in
from ..transformer.utils import make_sharded_tensors_for_checkpoint
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/3rdparty/Megatron-LM-workspace/Megatron-LM/megatron/core/transformer/__init__.py", line 6, in
from .transformer_layer import TransformerLayer, TransformerLayerSubmodules
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/3rdparty/Megatron-LM-workspace/Megatron-LM/megatron/core/transformer/transformer_layer.py", line 18, in
from megatron.core.transformer.cuda_graphs import CudaGraphManager
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/3rdparty/Megatron-LM-workspace/Megatron-LM/megatron/core/transformer/cuda_graphs.py", line 15, in
from megatron.core.tensor_parallel.random import (
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/3rdparty/Megatron-LM-workspace/Megatron-LM/megatron/core/tensor_parallel/random.py", line 26, in
import transformer_engine # pylint: disable=unused-import
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ray_venvs/nemo_rl.models.policy.megatron_policy_worker.MegatronPolicyWorker/lib/python3.12/site-packages/transformer_engine/__init__.py", line 11, in
import transformer_engine.common
File "/opt/ray_venvs/nemo_rl.models.policy.megatron_policy_worker.MegatronPolicyWorker/lib/python3.12/site-packages/transformer_engine/common/__init__.py", line 292, in
_CUDNN_LIB_CTYPES = _load_cudnn()
^^^^^^^^^^^^^
File "/opt/ray_venvs/nemo_rl.models.policy.megatron_policy_worker.MegatronPolicyWorker/lib/python3.12/site-packages/transformer_engine/common/__init__.py", line 245, in _load_cudnn
found, handle = _load_nvidia_cuda_library("cudnn")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ray_venvs/nemo_rl.models.policy.megatron_policy_worker.MegatronPolicyWorker/lib/python3.12/site-packages/transformer_engine/common/__init__.py", line 207, in _load_nvidia_cuda_library
ctypes_handles.append(ctypes.CDLL(so_path, mode=ctypes.RTLD_GLOBAL))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/lib/python3.12/ctypes/__init__.py", line 379, in __init__
self._handle = _dlopen(self._name, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: /opt/ray_venvs/nemo_rl.models.policy.megatron_policy_worker.MegatronPolicyWorker/lib/python3.12/site-packages/nvidia/cudnn/lib/libcudnn_engines_runtime_compiled.so.9: undefined symbol: _ZTIN5cudnn6fusion23LayerNormPatternMatcherE, version libcudnn_graph.so.9
Capturing CUDA graph shapes: 99%|█████████▊| 66/67 [00:09<00:00, 6.68it/s] [repeated 32x across cluster]
Capturing CUDA graph shapes: 100%|██████████| 67/67 [00:09<00:00, 7.07it/s] [repeated 6x across cluster]
Capturing CUDA graph shapes: 91%|█████████ | 61/67 [00:08<00:01, 5.46it/s] [repeated 32x across cluster]
(RayWorkerWrapper pid=787530, ip=10.65.17.143) INFO 09-04 00:53:14 [gpu_worker.py:104] Sleep mode freed 45.94 GiB memory, 7.27 GiB memory is still in use. [repeated 63x across cluster]
(VllmGenerationWorker pid=785921, ip=10.65.17.143) INFO 09-04 00:53:14 [executor_base.py:187] It took 7.884769 seconds to fall asleep. [repeated 15x across cluster]
Exception ignored in:
Traceback (most recent call last):
File "/lustre/fs1/portfolios/coreai/users/jzhai/RL_NeMo_RL/nemo-rl/nemo_rl/models/policy/lm_policy.py", line 618, in __del__
self.worker_group.shutdown()
^^^^^^^^^^^^^^^^^
AttributeError: 'Policy' object has no attribute 'worker_group'
2025-09-04 00:53:27,941 INFO worker.py:1694 -- Connecting to existing Ray cluster at address: 10.65.3.207:54514...
2025-09-04 00:53:27,945 INFO worker.py:1879 -- Connected to Ray cluster. View the dashboard at http://127.0.0.1:8265
2025-09-04 00:53:28,016 INFO worker.py:1694 -- Connecting to existing Ray cluster at address: 10.65.3.207:54514...
2025-09-04 00:53:28,019 INFO worker.py:1879 -- Connected to Ray cluster. View the dashboard at http://127.0.0.1:8265
[2025-09-04 00:53:28,047 C 3442965 3442965] core_worker_process.cc:69: Check failed: !core_worker_process The process is already initialized for core worker.
*** StackTrace Information ***
/opt/nemo_rl_venv/lib/python3.12/site-packages/ray/_raylet.so(+0x14392da) [0x1553cd2652da] ray::operator<<()
/opt/nemo_rl_venv/lib/python3.12/site-packages/ray/_raylet.so(_ZN3ray6RayLogD1Ev+0x479) [0x1553cd267d59] ray::RayLog::~RayLog()
/opt/nemo_rl_venv/lib/python3.12/site-packages/ray/_raylet.so(_ZN3ray4core17CoreWorkerProcess10InitializeERKNS0_17CoreWorkerOptionsE+0xe8) [0x1553cc7d7e48] ray::core::CoreWorkerProcess::Initialize()
/opt/nemo_rl_venv/lib/python3.12/site-packages/ray/_raylet.so(+0x81af6e) [0x1553cc646f6e] __pyx_pf_3ray_7_raylet_10CoreWorker___cinit__()
/opt/nemo_rl_venv/lib/python3.12/site-packages/ray/_raylet.so(+0x81c828) [0x1553cc648828] __pyx_pw_3ray_7_raylet_10CoreWorker_1__cinit__()
/opt/nemo_rl_venv/lib/python3.12/site-packages/ray/_raylet.so(+0x81d26c) [0x1553cc64926c] __pyx_tp_new_3ray_7_raylet_CoreWorker()
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x3b3d79) [0x1555540d7d79] type_call
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(_PyEval_EvalFrameDefault+0x31f0f) [0x1555541377df] _PyEval_EvalFrameDefault
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(PyObject_CallOneArg+0x61) [0x155554098dd1] PyObject_CallOneArg
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x4c05b8) [0x1555541e45b8] slot_tp_finalize
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x3baf75) [0x1555540def75] subtype_dealloc
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x3bad09) [0x1555540ded09] subtype_dealloc
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x3bad09) [0x1555540ded09] subtype_dealloc
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x37ca29) [0x1555540a0a29] frame_dealloc
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x43a16d) [0x15555415e16d] tb_dealloc
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x43a161) [0x15555415e161] tb_dealloc
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x43a161) [0x15555415e161] tb_dealloc
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(PyDict_SetItem+0x64f) [0x1555540ba6ef] PyDict_SetItem
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x558252) [0x15555427c252] _PySys_ClearAttrString
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x54645f) [0x15555426a45f] finalize_modules.llvm.6956522194820775225
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(Py_FinalizeEx+0xf1) [0x155554269a21] Py_FinalizeEx
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(Py_RunMain+0x183) [0x15555428c2e3] Py_RunMain
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x56898f) [0x15555428c98f] pymain_main
/root/.local/share/uv/python/cpython-3.12.10-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(Py_BytesMain+0x2d) [0x15555428ca4d] Py_BytesMain
/usr/lib/x86_64-linux-gnu/libc.so.6(+0x2a1ca) [0x155553a3d1ca]
/usr/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x8b) [0x155553a3d28b] __libc_start_main
/opt/nemo_rl_venv/bin/python3(_start+0x29) [0x6000a9] _start
````

**Expected behavior**

Normally generate the Nsys files

**Environment overview (please complete the following information)**

- Environment location: Slurm cluster with enroot environment
- Method of install: Build main branch docker image with [official method](https://docs.nvidia.com/nemo/rl/latest/docker.html#release-image)

**Environment details**

**Additional context**

Add any other context about the problem here.
Example: GPU model

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.