OOM situation of 80 GB GPU enviroment.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.5k
- Forks
- 1.3k
- Avg merge
- 5h 36m
- Merged PRs (30d)
- 22
Description
Firstly I am grateful for your perfect job!
I'd like to ask if this project lacks a mechanism to release GPU memory beyond the static pool. Currently, I'm using an environment with 8 A100 80GB GPUs. While running the training script run-qwen3-4B.sh, I've noticed that as the training steps increase, the memory usage during the rollout inference phase keeps rising until it results in an OOM error and crashes.
One phenomenon I've observed is that after an OOM error occurs and I cold-restart the script, then load the latest saved checkpoint, the previously accumulated high memory usage disappears. The data batch that originally caused the OOM error can then proceed with inference successfully.
I've been adjusting various parameters and testing for almost a week, and I've found that no matter how low I set the rollout-batch-size and sglang-mem-fraction-static parameters, the memory usage eventually accumulates and leads to OOM errors—sometimes during the rollout phase, and other times during the training phase.
The current workaround is to set the model parameter saving interval to 10 and use a script that automatically restarts the training script after an OOM error. This cold-start approach clears the accumulated memory usage, allowing that problematic data batch to be processed successfully.
My running enviroment is offical docker environment and my training script as following:
#!/bin/bash
# for rerun the task
pkill -9 sglang
sleep 3
ray stop --force
pkill -9 ray
pkill -9 python
sleep 3
pkill -9 ray
pkill -9 python
set -ex
# will prevent ray from buffering stdout/stderr
export PYTHONBUFFERED=16
NVLINK_COUNT=$(nvidia-smi topo -m 2>/dev/null | grep -o 'NV[0-9][0-9]*' | wc -l)
if [ "$NVLINK_COUNT" -gt 0 ]; then
HAS_NVLINK=1
else
HAS_NVLINK=0
fi
echo "HAS_NVLINK: $HAS_NVLINK (detected $NVLINK_COUNT NVLink references)"
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
source "${SCRIPT_DIR}/models/qwen3-4B.sh"
CKPT_ARGS=(
--hf-checkpoint /root/Slime_project/models/Qwen3-4B
#--hf-checkpoint /root/Qwen3-4B-FP8
--ref-load /root/Slime_project/models/Qwen3-4B_torch_dist
--load /root/Slime_project/models/Qwen3-4B_slime/
--save /root/Slime_project/models/Qwen3-4B_slime/
--save-interval 10
--max-save-checkpoints 5
)
ROLLOUT_ARGS=(
--prompt-data /root/Slime_project/models/dapo-math-17k/dapo-math-17k.jsonl
--input-key prompt
--label-key label
--apply-chat-template
--rollout-shuffle
--rm-type deepscaler
--num-rollout 3000
--rollout-batch-size 32
--n-samples-per-prompt 8
--rollout-max-response-len 8192
--rollout-temperature 0.8
--update-weight-buffer-size $((256 * 1024 * 1024))
--num-steps-per-rollout 1
--global-batch-size 256
--balance-data
)
EVAL_ARGS=(
--eval-interval 20
--eval-prompt-data aime /root/Slime_project/models/aime-2024/aime-2024.jsonl
--n-samples-per-eval-prompt 16
--eval-max-response-len 8192
--eval-top-p 0.7
)
PERF_ARGS=(
--tensor-model-parallel-size 2
--sequence-parallel
--pipeline-model-parallel-size 1
--context-parallel-size 1
--expert-model-parallel-size 1
--expert-tensor-parallel-size 1
--recompute-granularity full
--recompute-method uniform
--recompute-num-layers 1
--micro-batch-size 1
# --use-dynamic-batch-size
# --max-tokens-per-gpu 9216
# --max-tokens-per-gpu 8192
)
GRPO_ARGS=(
--advantage-estimator grpo
--use-kl-loss
--kl-loss-coef 0.00
--kl-loss-type low_var_kl
--entropy-coef 0.00
--eps-clip 0.2
--eps-clip-high 0.28
)
OPTIMIZER_ARGS=(
--optimizer adam
--lr 1e-6
--lr-decay-style constant
--weight-decay 0.1
--adam-beta1 0.9
--adam-beta2 0.98
--optimizer-cpu-offload
--overlap-cpu-optimizer-d2h-h2d
--use-precision-aware-optimizer
)
WANDB_ARGS=(
# --use-wandb
# --wandb-project slime-dev
# --wandb-group qwen3-4B-test
# --wandb-key ${WANDB_KEY}
)
SGLANG_ARGS=(
--rollout-num-gpus-per-engine 2
--sglang-mem-fraction-static 0.4
# --sglang-server-concurrency 128
)
MISC_ARGS=(
# default dropout in megatron is 0.1
--attention-dropout 0.0
--hidden-dropout 0.0
# should be good for model performance
--accumulate-allreduce-grads-in-fp32
--attention-softmax-in-fp32
# need to comment this when using model with MLA
--attention-backend flash
)
# launch the master node of ray in container
export MASTER_ADDR=${MASTER_ADDR:-"127.0.0.1"}
ray start --head --node-ip-address ${MASTER_ADDR} --num-gpus 8 --disable-usage-stats --dashboard-host=0.0.0.0 --dashboard-port=8265
# Build the runtime environment JSON with proper variable substitution
RUNTIME_ENV_JSON="{
\"env_vars\": {
\"PYTHONPATH\": \"/root/Megatron-LM/\",
\"CUDA_DEVICE_MAX_CONNECTIONS\": \"1\",
\"NCCL_NVLS_ENABLE\": \"${HAS_NVLINK}\"
}
}"
ray job submit --address="http://127.0.0.1:8265" \
--runtime-env-json="${RUNTIME_ENV_JSON}" \
-- python3 train.py \
--actor-num-nodes 1 \
--actor-num-gpus-per-node 8 \
--colocate \
${MODEL_ARGS[@]} \
${CKPT_ARGS[@]} \
${ROLLOUT_ARGS[@]} \
${OPTIMIZER_ARGS[@]} \
${GRPO_ARGS[@]} \
${WANDB_ARGS[@]} \
${PERF_ARGS[@]} \
${EVAL_ARGS[@]} \
${SGLANG_ARGS[@]} \
${MISC_ARGS[@]}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with train.py and the run-qwen3-4B.sh configuration, then reproduce the rollout and training memory growth with the reported A100 setup and parameters. Done means the accumulation is characterized and the issue has a verified fix or documented reproduction boundary without relying on cold restarts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, docker, python
- Domain
- distributed-systems, machine-learning, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100