Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ policy:
async_engine: false
tensor_parallel_size: 64
enforce_eager: true
vllm_kwargs:
# vLLM 0.20's default FlashInfer TRTLLM MoE backend isn't refit-compatible,
# change to triton to keep same behavior as vLLM 0.17.
moe_backend: triton
data:
max_input_seq_length: 512 # max_prompt_length
prompt_file: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ policy:
vllm_cfg:
tensor_parallel_size: 32
async_engine: true
vllm_kwargs:
# vLLM 0.20's default FlashInfer TRTLLM MoE backend isn't refit-compatible,
# change to triton to keep same behavior as vLLM 0.17.
moe_backend: triton
Comment thread
terrykong marked this conversation as resolved.
logger:
log_dir: logs/grpo-deepseek-v3-32n8g
wandb_enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ policy:
vllm_cfg:
tensor_parallel_size: 16
async_engine: true
vllm_kwargs:
# vLLM 0.20's default FlashInfer TRTLLM MoE backend isn't refit-compatible,
# change to triton to keep same behavior as vLLM 0.17.
moe_backend: triton
Comment thread
terrykong marked this conversation as resolved.
logger:
log_dir: logs/grpo-qwen3-235b-16n8g
wandb_enabled: true
Expand Down
73 changes: 41 additions & 32 deletions nemo_rl/algorithms/grpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,6 @@ def grpo_train(
val_at_start = master_config.grpo["val_at_start"]
val_at_end = master_config.grpo["val_at_end"]
val_period = master_config.grpo["val_period"]
to_compute_kl = master_config.loss_fn.reference_policy_kl_penalty > 0
colocated_inference = master_config.policy["generation"]["colocated"]["enabled"]

# Initialize advantage estimator
Expand Down Expand Up @@ -2019,12 +2018,12 @@ def grpo_train(
"Computing prev_logprobs anyway for seq-level error masking."
)

if skip_prev_logprobs:
print(
"▶ Skipping prev_logprobs (force_on_policy_ratio=True)...",
flush=True,
)
else:
# Skip reference_policy_logprobs computation when skip_reference_policy_logprobs_calculation=True
skip_reference_logprobs = master_config.grpo.get(
"skip_reference_policy_logprobs_calculation"
)

if not (skip_prev_logprobs and skip_reference_logprobs):
print("▶ Preparing for logprob inference...", flush=True)
with timer.time("logprob_inference_prep"):
policy.prepare_for_lp_inference()
Expand All @@ -2041,25 +2040,32 @@ def grpo_train(
**extra_multimodal_data,
}
)

if not skip_prev_logprobs:
train_data["prev_logprobs"] = policy.get_logprobs(
logprob_data, timer=timer
)["logprobs"]
else:
print(
"▶ Skipping prev_logprobs (force_on_policy_ratio=True)...",
flush=True,
)
train_data["prev_logprobs"] = torch.zeros_like(
train_data["generation_logprobs"]
)

if to_compute_kl and not master_config.grpo.get(
"skip_reference_policy_logprobs_calculation"
):
if not skip_reference_logprobs:
train_data["reference_policy_logprobs"] = (
policy.get_reference_policy_logprobs(
logprob_data,
timer=timer,
)["reference_logprobs"]
)
else:
print(
"▶ Skipping reference_logprobs (skip_reference_policy_logprobs_calculation=True)...",
flush=True,
)
train_data["reference_policy_logprobs"] = torch.zeros_like(
train_data["prev_logprobs"]
)
Expand Down Expand Up @@ -2800,7 +2806,6 @@ def async_grpo_train(
val_period = master_config.grpo["val_period"]
val_at_start = master_config.grpo["val_at_start"]
val_at_end = master_config.grpo["val_at_end"]
to_compute_kl = master_config.loss_fn.reference_policy_kl_penalty > 0
colocated_inference = master_config.policy["generation"]["colocated"]["enabled"]

# Initialize advantage estimator
Expand Down Expand Up @@ -3172,37 +3177,41 @@ def async_grpo_train(
"Computing prev_logprobs anyway for seq-level error masking."
)

if skip_prev_logprobs:
print(
"▶ Skipping prev_logprobs (force_on_policy_ratio=True)...",
flush=True,
)
fprop_logprobs = torch.zeros_like(train_data["generation_logprobs"])
else:
print("▶ Preparing for logprob inference...")
# Skip reference_policy_logprobs computation when skip_reference_policy_logprobs_calculation=True
skip_reference_logprobs = master_config.grpo.get(
"skip_reference_policy_logprobs_calculation"
)

if not (skip_prev_logprobs and skip_reference_logprobs):
print("▶ Preparing for logprob inference...", flush=True)
with timer.time("logprob_inference_prep"):
policy.prepare_for_lp_inference()

print("▶ Computing logprobs...", flush=True)
with timer.time("policy_and_reference_logprobs"):
if not skip_prev_logprobs:
fprop_logprobs = policy.get_logprobs(
train_data,
timer=timer,
train_data["prev_logprobs"] = policy.get_logprobs(
train_data, timer=timer
)["logprobs"]
train_data["prev_logprobs"] = fprop_logprobs
else:
train_data["prev_logprobs"] = torch.zeros_like(
train_data["generation_logprobs"]
)

if to_compute_kl and not master_config.grpo.get(
"skip_reference_policy_logprobs_calculation"
):
reference_logprobs = policy.get_reference_policy_logprobs(
train_data,
timer=timer,
)["reference_logprobs"]
train_data["reference_policy_logprobs"] = reference_logprobs
if not skip_reference_logprobs:
train_data["reference_policy_logprobs"] = (
policy.get_reference_policy_logprobs(
train_data,
timer=timer,
)["reference_logprobs"]
)
else:
print(
"▶ Skipping reference_logprobs (skip_reference_policy_logprobs_calculation=True)...",
flush=True,
)
train_data["reference_policy_logprobs"] = torch.zeros_like(
fprop_logprobs
train_data["prev_logprobs"]
)

# Seq-level logprob error metrics/masking require real prev_logprobs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ uv run tests/json_dump_tb_logs.py $LOG_DIR --output_path $JSON_METRICS
# Only run metrics if the target step is reached
if [[ $(jq 'to_entries | .[] | select(.key == "train/loss") | .value | keys | map(tonumber) | max' $JSON_METRICS) -ge $MAX_STEPS ]]; then
uv run tests/check_metrics.py $JSON_METRICS \
'median(data["train/token_mult_prob_error"]) < 1.1' \
'data["train/token_mult_prob_error"]["10"] < 1.1'
'median(data["train/token_mult_prob_error"]) < 1.1'

# Clean up checkpoint directory after successful run to save space.
rm -rf "$CKPT_DIR"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ uv run tests/json_dump_tb_logs.py $LOG_DIR --output_path $JSON_METRICS
# Only run metrics if the target step is reached
if [[ $(jq 'to_entries | .[] | select(.key == "train/loss") | .value | keys | map(tonumber) | max' $JSON_METRICS) -ge $MAX_STEPS ]]; then
uv run tests/check_metrics.py $JSON_METRICS \
'median(data["train/token_mult_prob_error"]) < 1.1' \
'data["train/token_mult_prob_error"]["10"] < 1.1'
'median(data["train/token_mult_prob_error"]) < 1.1'

# Clean up checkpoint directory after successful run to save space.
rm -rf "$CKPT_DIR"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ uv run tests/json_dump_tb_logs.py $LOG_DIR --output_path $JSON_METRICS
# Only run metrics if the target step is reached
if [[ $(jq 'to_entries | .[] | select(.key == "train/loss") | .value | keys | map(tonumber) | max' $JSON_METRICS) -ge $MAX_STEPS ]]; then
uv run tests/check_metrics.py $JSON_METRICS \
'median(data["train/token_mult_prob_error"]) < 1.1' \
'data["train/token_mult_prob_error"]["10"] < 1.1'
'median(data["train/token_mult_prob_error"]) < 1.1'

# Clean up checkpoint directory after successful run to save space.
rm -rf "$CKPT_DIR"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ uv run tests/json_dump_tb_logs.py $LOG_DIR --output_path $JSON_METRICS
# Only run metrics if the target step is reached
if [[ $(jq 'to_entries | .[] | select(.key == "train/loss") | .value | keys | map(tonumber) | max' $JSON_METRICS) -ge $MAX_STEPS ]]; then
uv run tests/check_metrics.py $JSON_METRICS \
'median(data["train/token_mult_prob_error"]) < 1.1' \
'data["train/token_mult_prob_error"]["10"] < 1.1'
'median(data["train/token_mult_prob_error"]) < 1.1'
Comment thread
terrykong marked this conversation as resolved.

# Clean up checkpoint directory after successful run to save space.
rm -rf "$CKPT_DIR"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ uv run tests/json_dump_tb_logs.py $LOG_DIR --output_path $JSON_METRICS
# Only run metrics if the target step is reached
if [[ $(jq 'to_entries | .[] | select(.key == "train/loss") | .value | keys | map(tonumber) | max' $JSON_METRICS) -ge $MAX_STEPS ]]; then
uv run tests/check_metrics.py $JSON_METRICS \
'median(data["train/token_mult_prob_error"]) < 1.1' \
'data["train/token_mult_prob_error"]["10"] < 1.1'
'median(data["train/token_mult_prob_error"]) < 1.1'

# Clean up checkpoint directory after successful run to save space.
rm -rf "$CKPT_DIR"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ uv run tests/json_dump_tb_logs.py $LOG_DIR --output_path $JSON_METRICS
# Only run metrics if the target step is reached
if [[ $(jq 'to_entries | .[] | select(.key == "train/loss") | .value | keys | map(tonumber) | max' $JSON_METRICS) -ge $MAX_STEPS ]]; then
uv run tests/check_metrics.py $JSON_METRICS \
'median(data["train/token_mult_prob_error"]) < 1.1' \
'data["train/token_mult_prob_error"]["10"] < 1.1'
'median(data["train/token_mult_prob_error"]) < 1.1'

# Clean up checkpoint directory after successful run to save space.
rm -rf "$CKPT_DIR"
Expand Down
Loading
Loading