OOM when save checkpoint
Hi
我在训练32B模型的时候遇到了保存checkpoint导致超出内存的问题,下面是具体的报错日志。目前来看,应该是checkpoint过大,多个worker同时保存,导致的。我的机器只有400GB的内存,没办法增加了。这个问题可以解决吗?感谢
trainer.fit()
File "/search/odin/wunxie/code/verl/verl/trainer/ppo/ray_trainer.py", line 1181, in fit
self._save_checkpoint()
File "/search/odin/wunxie/code/verl/verl/trainer/ppo/ray_trainer.py", line 856, in _save_checkpoint
self.actor_rollout_wg.save_checkpoint(actor_local_path, actor_remote_path, self.global_steps, max_ckpt_to_keep=max_actor_ckpt_to_keep)
File "/search/odin/wunxie/code/verl/verl/single_controller/ray/base.py", line 51, in call
output = ray.get(output)
^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ray.exceptions.OutOfMemoryError: Task was killed due to the node running low on memory.
Memory on the node (IP: 10.212.120.117, ID: 02f82f803ebbe53896582a02e58afee99633c7736f7e04e19cfe466e) where the task (actor ID: 35401eb04028d69250016be001000000, name=IEBYnGWorkerDict_0:7:WorkerDict.init, pid=827684, memory used=43.35GB) was running was 382.59GB / 400.00GB (0.956471), which exceeds the memory usage threshold of 0.95. Ray killed this worker (ID: c72fad2871501a736b60aeed3a7b0d4e99ca7b34916e3ef2802a090a) because it was the most recently scheduled task; to see more information about memory usage on this node, use ray logs raylet.out -ip 10.212.120.117. To see the logs of the worker, use `ray logs worker-c72fad2871501a736b60aeed3a7b0d4e99ca7b34916e3ef2802a090a*out -ip 10.212.120.117. Top 10 memory users:
PID MEM(GB) COMMAND
827683 43.54 ray::WorkerDict.actor_rollout_save_checkpoint
827678 43.48 ray::WorkerDict.actor_rollout_save_checkpoint
827684 43.35 ray::WorkerDict.actor_rollout_save_checkpoint
827477 43.35 ray::WorkerDict.actor_rollout_save_checkpoint
827677 43.33 ray::WorkerDict.actor_rollout_save_checkpoint
827679 43.21 ray::WorkerDict.actor_rollout_save_checkpoint
827682 42.55 ray::WorkerDict.actor_rollout_save_checkpoint
827676 42.47 ray::WorkerDict.actor_rollout_save_checkpoint
825414 1.47 ray::TaskRunner.run
同问,我的机器1600GB的内存保存32B模型时也会遇到这个问题。
我大概找到原因了,应该是vllm内存泄漏的问题。我尝试解决save_checkpoint的内存报错之后,又在rollout爆了内存。我找到了这个 https://github.com/volcengine/verl/pull/650 使用更高版本的vllm解决了这个问题
我升级了vllm到0.8.2/0.8.5或者更换成SGLang还是在save checkpoint时CPU OOM。
具体情况如下:
报错信息
[36m(WorkerDict pid=29470, ip=22.7.38.205)[0m Saving sharded model checkpoint to /mnt/workspace/pengjiazhen.pjz/code/ToolScope/PRM/checkpoints/verl_grpo_appworld_32b/sft_1_v1_random_cases_kl0008_n4_detailed2_v3/global_step_1/actor
[36m(WorkerDict pid=29466, ip=22.7.38.205)[0m Saved checkpoint to /mnt/workspace/pengjiazhen.pjz/code/ToolScope/PRM/checkpoints/verl_grpo_appworld_32b/sft_1_v1_random_cases_kl0008_n4_detailed2_v3/global_step_1/actor/model
[36m(WorkerDict pid=29464, ip=22.7.38.205)[0m Saving sharded model checkpoint to /mnt/workspace/pengjiazhen.pjz/code/ToolScope/PRM/checkpoints/verl_grpo_appworld_32b/sft_1_v1_random_cases_kl0008_n4_detailed2_v3/global_step_1/actor[32m [repeated 7x across cluster][0m
Error executing job with overrides: ['algorithm.adv_estimator=grpo', 'data.train_files=Data/qwen_32b/SFT/1/train.parquet', 'data.val_files=Data/qwen_32b/SFT/1/test.parquet', 'data.train_batch_size=16', 'data.max_prompt_length=6144', 'data.max_response_length=384', 'data.filter_overlong_prompts=True', 'data.truncation=error', 'actor_rollout_ref.model.path=/mnt/model-new/xkliao/full-model-path/Qwen2.5-32B-Instruct/full-mix-claude4', 'actor_rollout_ref.actor.optim.lr=1e-6', 'actor_rollout_ref.actor.ppo_mini_batch_size=4', 'actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1', 'actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=1', 'actor_rollout_ref.actor.megatron.tensor_model_parallel_size=8', 'actor_rollout_ref.actor.megatron.param_offload=True', 'actor_rollout_ref.actor.megatron.optimizer_offload=True', 'actor_rollout_ref.actor.megatron.grad_offload=True', 'actor_rollout_ref.actor.use_kl_loss=True', 'actor_rollout_ref.actor.kl_loss_coef=0.008', 'actor_rollout_ref.actor.kl_loss_type=low_var_kl', 'actor_rollout_ref.actor.entropy_coeff=0', 'actor_rollout_ref.model.enable_gradient_checkpointing=True', 'actor_rollout_ref.rollout.max_num_batched_tokens=6656', 'actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1', 'actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=1', 'actor_rollout_ref.ref.megatron.tensor_model_parallel_size=8', 'actor_rollout_ref.ref.megatron.param_offload=True', 'actor_rollout_ref.rollout.name=vllm', 'actor_rollout_ref.rollout.gpu_memory_utilization=0.5', 'actor_rollout_ref.rollout.tensor_model_parallel_size=8', 'actor_rollout_ref.rollout.n=4', 'actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=1', 'algorithm.use_kl_in_reward=False', 'algorithm.kl_ctrl.kl_coef=0.008', 'trainer.critic_warmup=0', 'trainer.logger=[console,swanlab]', 'trainer.project_name=verl_grpo_appworld_32b', 'trainer.experiment_name=sft_1_v1_random_cases_kl0008_n4_detailed2_v3', 'trainer.n_gpus_per_node=8', 'trainer.nnodes=2', 'trainer.save_freq=1', 'trainer.test_freq=1', 'trainer.total_epochs=5', 'reward_model.reward_manager=prime', 'custom_reward_function.path=/mnt/workspace/pengjiazhen.pjz/code/ToolScope/Common/Reward/OneShotThinkReasonDetailedReward2_32b_new.py']
Traceback (most recent call last):
File "/mnt/workspace/shian.lq/RL_project/verl/verl/trainer/main_ppo.py", line 27, in main
run_ppo(config)
File "/mnt/workspace/shian.lq/RL_project/verl/verl/trainer/main_ppo.py", line 39, in run_ppo
ray.get(runner.run.remote(config))
File "/mnt/workspace/lianggui.wlg/miniforge3/envs/verl_new/lib/python3.11/site-packages/ray/_private/auto_init_hook.py", line 21, in auto_init_wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/mnt/workspace/lianggui.wlg/miniforge3/envs/verl_new/lib/python3.11/site-packages/ray/_private/client_mode_hook.py", line 103, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/mnt/workspace/lianggui.wlg/miniforge3/envs/verl_new/lib/python3.11/site-packages/ray/_private/worker.py", line 2822, in get
values, debugger_breakpoint = worker.get_objects(object_refs, timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/workspace/lianggui.wlg/miniforge3/envs/verl_new/lib/python3.11/site-packages/ray/_private/worker.py", line 930, in get_objects
raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(OutOfMemoryError): [36mray::TaskRunner.run()[39m (pid=82082, ip=dlc18eolqgfne2kf-master-0, actor_id=aa426c86e8027b272289fe7202000000, repr=<main_ppo.TaskRunner object at 0x7f024971b390>)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/workspace/shian.lq/RL_project/verl/verl/trainer/main_ppo.py", line 159, in run
trainer.fit()
File "/mnt/workspace/shian.lq/RL_project/verl/verl/trainer/ppo/ray_trainer.py", line 1189, in fit
self._save_checkpoint()
File "/mnt/workspace/shian.lq/RL_project/verl/verl/trainer/ppo/ray_trainer.py", line 863, in _save_checkpoint
self.actor_rollout_wg.save_checkpoint(actor_local_path, actor_remote_path, self.global_steps, max_ckpt_to_keep=max_actor_ckpt_to_keep)
File "/mnt/workspace/shian.lq/RL_project/verl/verl/single_controller/ray/base.py", line 51, in __call__
output = ray.get(output)
^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ray.exceptions.OutOfMemoryError: Task was killed due to the node running low on memory.
Memory on the node (IP: 22.7.38.205, ID: 06e4456820122559d93238c3a363f54ff57dc2f34a05bd770391138e) where the task (actor ID: fac1acddc42129fb2dff6a8402000000, name=aTUGbxWorkerDict_0:6:WorkerDict.__init__, pid=29469, memory used=188.22GB) was running was 1525.23GB / 1600.00GB (0.953271), which exceeds the memory usage threshold of 0.95. Ray killed this worker (ID: 9edf704fbc65792c0c8ddf6a4944ee26bd3d44d30f3e4183fe5de996) because it was the most recently scheduled task; to see more information about memory usage on this node, use `ray logs raylet.out -ip 22.7.38.205`. To see the logs of the worker, use `ray logs worker-9edf704fbc65792c0c8ddf6a4944ee26bd3d44d30f3e4183fe5de996*out -ip 22.7.38.205. Top 10 memory users:
PID MEM(GB) COMMAND
29464 188.44 ray::WorkerDict.actor_rollout_save_checkpoint
29466 188.33 ray::WorkerDict.actor_rollout_save_checkpoint
29469 188.22 ray::WorkerDict.actor_rollout_save_checkpoint
29463 188.20 ray::WorkerDict.actor_rollout_save_checkpoint
29467 182.80 ray::WorkerDict.actor_rollout_save_checkpoint
29270 180.59 ray::WorkerDict.actor_rollout_save_checkpoint
29468 175.47 ray::WorkerDict.actor_rollout_save_checkpoint
29470 174.37 ray::WorkerDict.actor_rollout_save_checkpoint
28868 0.49 /mnt/workspace/lianggui.wlg/miniforge3/envs/verl_new/lib/python3.11/site-packages/ray/core/src/ray/r...
28869 0.16 /mnt/workspace/lianggui.wlg/miniforge3/envs/verl_new/bin/python3.11 -u /mnt/workspace/lianggui.wlg/m...
Refer to the documentation on how to address the out of memory issue: https://docs.ray.io/en/latest/ray-core/scheduling/ray-oom-prevention.html. Consider provisioning more memory on this node or reducing task parallelism by requesting more CPUs per task. Set max_restarts and max_task_retries to enable retry when the task crashes due to OOM. To adjust the kill threshold, set the environment variable `RAY_memory_usage_threshold` when starting Ray. To disable worker killing, set the environment variable `RAY_memory_monitor_refresh_ms` to zero.
Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
脚本
set -x
export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping
MASTER_ADDR=$MASTER_ADDR
MASTER_PORT=$MASTER_PORT
GPUS_PER_NODE=$NPROC_PER_NODE
NODE_RANK=$RANK
WORLD_SIZE=2
echo $NNODES
echo $MASTER_ADDR
echo $MASTER_PORT
echo $GPUS_PER_NODE
echo $NODE_RANK
echo $WORLD_SIZE
model="/mnt/model-new/xkliao/full-model-path/Qwen2.5-32B-Instruct/full-mix-claude4"
offload=True
gen_tp=8
train_tp=8
train_pp=1
if [ "$NODE_RANK" -eq 0 ]; then
ray start --head --node-ip-address=$MASTER_ADDR --port=6378 --num-gpus=$GPUS_PER_NODE
sleep 60
ray job submit --address="http://127.0.0.1:8265" \
-- python3 -m verl.trainer.main_ppo --config-path=config \
--config-name='ppo_megatron_trainer.yaml'\
algorithm.adv_estimator=grpo \
data.train_files="Data/qwen_32b/SFT/1/train.parquet" \
data.val_files="Data/qwen_32b/SFT/1/test.parquet" \
data.train_batch_size=16 \
data.max_prompt_length=6144 \
data.max_response_length=384 \
data.filter_overlong_prompts=True \
data.truncation='error' \
actor_rollout_ref.model.path=${model} \
actor_rollout_ref.actor.optim.lr=1e-6 \
actor_rollout_ref.actor.ppo_mini_batch_size=4 \
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1 \
actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=${train_pp} \
actor_rollout_ref.actor.megatron.tensor_model_parallel_size=${train_tp} \
actor_rollout_ref.actor.megatron.param_offload=${offload} \
actor_rollout_ref.actor.megatron.optimizer_offload=${offload} \
actor_rollout_ref.actor.megatron.grad_offload=${offload} \
actor_rollout_ref.actor.use_kl_loss=True \
actor_rollout_ref.actor.kl_loss_coef=0.008 \
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
actor_rollout_ref.actor.entropy_coeff=0 \
actor_rollout_ref.model.enable_gradient_checkpointing=True \
actor_rollout_ref.rollout.max_num_batched_tokens=6656 \
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1 \
actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=${train_pp} \
actor_rollout_ref.ref.megatron.tensor_model_parallel_size=${train_tp} \
actor_rollout_ref.ref.megatron.param_offload=${offload} \
actor_rollout_ref.rollout.name=vllm \
actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \
actor_rollout_ref.rollout.tensor_model_parallel_size=${gen_tp} \
actor_rollout_ref.rollout.n=4 \
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=1 \
algorithm.use_kl_in_reward=False \
algorithm.kl_ctrl.kl_coef=0.008 \
trainer.critic_warmup=0 \
trainer.logger=['console','swanlab'] \
trainer.project_name='verl_grpo_appworld_32b' \
trainer.experiment_name="sft_1_v1_random_cases_kl0008_n4_detailed2_v3" \
trainer.n_gpus_per_node=$GPUS_PER_NODE \
trainer.nnodes=$WORLD_SIZE \
trainer.save_freq=1 \
trainer.test_freq=1 \
trainer.total_epochs=5 \
reward_model.reward_manager=prime \
custom_reward_function.path="/mnt/workspace/pengjiazhen.pjz/code/ToolScope/Common/Reward/OneShotThinkReasonDetailedReward2_32b_new.py"
else
ray start --address $MASTER_ADDR:6378 --num-gpus $GPUS_PER_NODE
python /mnt/workspace/shian.lq/RL_project/verl/scripts/null_node.py
fi
环境
accelerate 1.7.0
aiohappyeyeballs 2.6.1
aiohttp 3.12.2
aiohttp-cors 0.8.1
aiosignal 1.3.2
airportsdata 20250523
aniso8601 10.0.1
annotated-types 0.7.0
anthropic 0.52.0
antlr4-python3-runtime 4.9.3
anyio 3.7.1
apex 0.1
appworld 0.1.3 /mnt/workspace/pengjiazhen.pjz/code/swift/ToolScope/AppWorld/appworld
astor 0.8.1
asttokens 3.0.0
async-generator 1.10
attrs 25.3.0
av 14.4.0
blake3 1.0.5
blinker 1.9.0
blobfile 3.0.0
boto3 1.38.34
botocore 1.38.34
cachetools 5.5.2
certifi 2025.4.26
cffi 1.17.1
charset-normalizer 3.4.2
click 8.2.1
cloudpickle 3.1.1
codetiming 1.4.0
colorful 0.5.6
compressed-tensors 0.9.2
coverage 7.8.2
crc32c 2.7.1
cryptography 43.0.3
cuda-bindings 12.9.0
cuda-python 12.9.0
cupy-cuda12x 13.4.1
datasets 3.6.0
decorator 5.2.1
decord 0.6.0
Deprecated 1.2.18
depyf 0.18.0
dill 0.3.8
diskcache 5.6.3
distlib 0.3.9
distro 1.9.0
dnspython 2.7.0
docker-pycreds 0.4.0
donfig 0.8.1.post1
einops 0.8.1
email_validator 2.2.0
execnet 2.1.1
executing 2.2.0
Faker 24.14.1
fastapi 0.115.12
fastapi-cli 0.0.7
fastapi-login 1.9.3
fastrlock 0.8.3
filelock 3.18.0
flash_attn 2.7.4.post1
flashinfer-python 0.2.5
Flask 3.1.1
Flask-RESTful 0.3.10
freezegun 1.2.2
frozenlist 1.6.0
fsspec 2024.6.1
gguf 0.10.0
gitdb 4.0.12
GitPython 3.1.44
google-api-core 2.24.2
google-auth 2.40.2
googleapis-common-protos 1.70.0
greenlet 3.2.3
grpcio 1.71.0
h11 0.16.0
hf_transfer 0.1.9
hf-xet 1.1.2
httpcore 1.0.9
httptools 0.6.4
httpx 0.27.2
httpx-aiohttp 0.1.4
huggingface-hub 0.32.1
hydra-core 1.3.2
idna 3.10
importlib_metadata 8.0.0
inflection 0.5.1
iniconfig 2.1.0
interegular 0.3.3
ipython 9.2.0
ipython_pygments_lexers 1.1.1
itsdangerous 2.2.0
jedi 0.19.2
Jinja2 3.1.6
jiter 0.10.0
jmespath 1.0.1
joblib 1.5.1
jsonref 1.1.0
jsonschema 4.24.0
jsonschema-specifications 2025.4.1
lark 1.2.2
libcst 1.8.0
liger_kernel 0.5.10
litellm 1.71.1
llguidance 0.7.24
llvmlite 0.43.0
lm-format-enforcer 0.10.11
lxml 5.4.0
markdown-it-py 3.0.0
MarkupSafe 2.1.5
mathruler 0.1.0
matplotlib-inline 0.1.7
mdurl 0.1.2
megatron-core 0.12.0rc3
mistral_common 1.5.6
ml_dtypes 0.5.1
modelscope 1.26.0
mpmath 1.3.0
msgpack 1.1.0
msgspec 0.19.0
multidict 6.4.4
multiprocess 0.70.16
munch 4.0.0
nanobind 2.7.0
nest-asyncio 1.6.0
networkx 3.3
ninja 1.11.1.4
nltk 3.9.1
numba 0.60.0
numcodecs 0.16.1
numpy 1.26.4
nvidia-cublas-cu12 12.4.5.8
nvidia-cuda-cupti-cu12 12.4.127
nvidia-cuda-nvrtc-cu12 12.4.127
nvidia-cuda-runtime-cu12 12.4.127
nvidia-cudnn-cu12 9.1.0.70
nvidia-cufft-cu12 11.2.1.3
nvidia-curand-cu12 10.3.5.147
nvidia-cusolver-cu12 11.6.1.9
nvidia-cusparse-cu12 12.3.1.170
nvidia-cusparselt-cu12 0.6.2
nvidia-ml-py 12.575.51
nvidia-modelopt 0.29.0
nvidia-modelopt-core 0.29.0
nvidia-nccl-cu12 2.21.5
nvidia-nvjitlink-cu12 12.4.127
nvidia-nvtx-cu12 12.4.127
omegaconf 2.3.0
openai 1.82.0
opencensus 0.11.4
opencensus-context 0.1.3
opencv-fixer 0.2.5
opencv-python 4.11.0.86
opencv-python-headless 4.11.0.86
opentelemetry-api 1.26.0
opentelemetry-exporter-otlp 1.26.0
opentelemetry-exporter-otlp-proto-common 1.26.0
opentelemetry-exporter-otlp-proto-grpc 1.26.0
opentelemetry-exporter-otlp-proto-http 1.26.0
opentelemetry-proto 1.26.0
opentelemetry-sdk 1.26.0
opentelemetry-semantic-conventions 0.47b0
opentelemetry-semantic-conventions-ai 0.4.9
optree 0.15.0
orjson 3.10.18
outcome 1.3.0.post0
outlines 0.1.11
outlines_core 0.1.26
packaging 25.0
pandas 2.2.3
parso 0.8.4
partial-json-parser 0.2.1.1.post5
peft 0.15.2
pendulum 3.1.0
pexpect 4.9.0
pillow 11.2.1
pip 25.1.1
platformdirs 4.3.8
pluggy 1.6.0
polyfactory 2.21.0
prettytable 3.16.0
prometheus_client 0.22.0
prometheus-fastapi-instrumentator 7.1.0
prompt_toolkit 3.0.51
propcache 0.3.1
proto-plus 1.26.1
protobuf 4.25.7
psutil 5.9.8
ptyprocess 0.7.0
PuLP 3.1.1
pure_eval 0.2.3
py-cpuinfo 9.0.0
py-spy 0.4.0
pyarrow 20.0.0
pyasn1 0.6.1
pyasn1_modules 0.4.2
pybind11 2.13.6
pycountry 24.6.1
pycparser 2.22
pycryptodomex 3.23.0
pydantic 2.11.5
pydantic_core 2.33.2
pyecharts 2.0.8
Pygments 2.19.1
PyJWT 2.10.1
pylatexenc 2.10
pynvml 12.0.0
pytest 8.3.5
pytest-cov 6.1.1
pytest-mock 3.14.1
pytest-random-order 1.1.1
pytest-xdist 3.7.0
python-dateutil 2.9.0.post0
python-dotenv 1.1.0
python-json-logger 3.3.0
python-multipart 0.0.20
pytz 2025.2
PyYAML 6.0.2
pyzmq 26.4.0
qwen-vl-utils 0.0.11
ray 2.46.0
referencing 0.36.2
regex 2024.11.6
requests 2.32.3
rich 13.9.4
rich-toolkit 0.14.6
rpds-py 0.25.1
rsa 4.9.1
s3transfer 0.13.0
safetensors 0.5.3
scipy 1.15.3
sentencepiece 0.2.0
sentry-sdk 2.29.1
setproctitle 1.3.6
setuptools 80.8.0
sgl-kernel 0.1.4
sglang 0.4.6.post5
shellingham 1.5.4
simplejson 3.20.1
six 1.17.0
smart-open 7.1.0
smmap 5.0.2
sniffio 1.3.1
sortedcontainers 2.4.0
soundfile 0.13.1
SQLAlchemy 2.0.41
SQLAlchemy-Utils 0.41.2
sqlalchemy2-stubs 0.0.2a38
sqlmodel 0.0.24
stack-data 0.6.3
starlette 0.46.2
swankit 0.2.2
swanlab 0.6.2
sympy 1.13.1
tensordict 0.6.2
tensorstore 0.1.75
tiktoken 0.9.0
tokenizers 0.21.1
torch 2.6.0
torch_memory_saver 0.0.6
torchao 0.9.0
torchaudio 2.6.0
torchdata 0.11.0
torchprofile 0.0.4
torchvision 0.21.0
tqdm 4.67.1
traitlets 5.14.3
transformer_engine 2.2.0+c55e425
transformers 4.51.1
trio 0.21.0
triton 3.2.0
typer 0.12.5
typing_extensions 4.12.2
typing-inspection 0.4.1
tzdata 2025.2
urllib3 2.4.0
uvicorn 0.27.1
uvloop 0.21.0
verl 0.3.1.dev0 /mnt/workspace/shian.lq/RL_project/verl
virtualenv 20.31.2
vllm 0.8.2
wandb 0.19.11
watchfiles 1.0.5
wcwidth 0.2.13
websockets 15.0.1
Werkzeug 3.1.3
wheel 0.45.1
wrapt 1.17.2
xformers 0.0.29.post2
xgrammar 0.1.19
xxhash 3.5.0
yarl 1.20.0
zarr 3.0.8
zipp 3.22.0
@PengJiazhen408 Thanks a lot for sharing your specific configuration~
@xiewen354 Thanks for leaving a possible solution, hoping to help anyone in need.
@PengJiazhen408 Did the swanlab record the CPU Memory logs in system metrics? Could you also use the memory trace to navigate the memory occupation?
And can you try whether the latest verl has this problem?
@PengJiazhen408 Did the swanlab record the CPU Memory logs in system metrics? Could you also use the memory trace to navigate the memory occupation?
And can you try whether the latest verl has this problem?
用swanlab跟踪了,但似乎有些滞后,没有记录到内存爆炸的情况:
我verl用的6月6更新的版本, #1872
猜测是offload太占CPU memory了? 但没法验证这种情况,如果offload设置为False,又会GPU OOM。
From your case, theoretical CPU memory occupation:
- 3 models states (3 weights + 1 optimizer states + 1 gradients): $32 * 2 * 3 + 32 * 4 * 2 + 32 * 2 = 32 * 16 = 512 GB$
- KVCache: $(2 * 4 * 6528 * 8 * 5120/40 * 64 * 2)/(2^{30}) = 6.375 GB$
Should be far from your limits.
Currently some implementations are bad, so real CPU memory costs are:
- 3 models states (3 weights + 2 optimizer states + 1 gradients): $32 * 2 * 3 + 32 * 4 * 4 + 32 * 2 = 32 * 24 = 768 GB$
- KVCache: $(2 * 4 * 6528 * 8 * 5120/40 * 64 * 2)/(2^{30}) = 6.375 GB$
@ETOgaosion Could you explain in detail which part of the implementation caused the optimizer to have an extra copy of the state? And KVCAche why not (2 * 4 * 6528 * (5120/40) *8 * 64 * 2)=6.375G, qwen-32B model is GQA. If I'm wrong, please point it out.
@wukong1992 Forgot about it, you are right, anyway, the dist_checkpointing implemented by #2125 can decrease peak memory by $\frac{1}{dp\times cp}$ , could you please review and check?
Same issue with vllm==0.11.0. I have 2T memory but still goes OOM
saving all previous ckpt works fine, only the last ckpt leads to OOM
error msg:
ray.exceptions.OutOfMemoryError: Task was killed due to the node running low on memory.
Memory on the node (IP: 10.2.201.11, ID: 243935e97befd64e53c960091466db80951f4403b301e0d7cc449f20) where the lease (lease ID: 08000000b50e2bcab645a9266385e3f6fa078d59ecca9db03ae743e6a373f4fa, name=RHkXdVWorkerDict_0:7:WorkerDict.init, pid=2116289, memory used=74.89GB) was running was 1929.03GB / 2015.52GB (0.957086), which exceeds the memory usage threshold of 0.95. Ray killed this worker (ID: cb8b97efd8457bfa200e181314e1fd7d7ba8794c0136f23c27ac8ac3) because it was the most recently scheduled task; to see more information about memory usage on this node, use ray logs raylet.out -ip 10.2.201.11. To see the logs of the worker, use `ray logs worker-cb8b97efd8457bfa200e181314e1fd7d7ba8794c0136f23c27ac8ac3*out -ip 10.2.201.11. Top 10 memory users:
same issue