# Ray Megatron GKD multi-turn — colocate mode, colocated teacher.
# Tests multi-turn GKD on Ray-Megatron backend with MathTipsScheduler.
rlhf_type: gkd

model: Qwen/Qwen3.5-0.8B
teacher_model: Qwen/Qwen3.5-2B
gkd_logits_topk: 64
enable_thinking: false

dataset:
  - 'AI-MO/NuminaMath-TIR#2000'
dataset_num_proc: 4
split_dataset_ratio: 0

micro_batch_size: 1
global_batch_size: 16
num_train_epochs: 1
logging_steps: 5
seed: 42
max_length: 2048
max_completion_length: 1024
truncation_strategy: delete
padding_free: true
sequence_parallel: true
attention_backend: flash

lr: 1e-5
min_lr: 1e-7
lr_warmup_fraction: 0.05

temperature: 1.0
lmbda: 1
beta: 0.5
sft_alpha: 0.0

# Multi-turn configuration
multi_turn_scheduler: math_tip_trick
max_turns: 2

finetune: true
no_save_optim: true
no_save_rng: true
recompute_granularity: selective

use_vllm: true

colocate_groups: [[train, rollout]]
offload_model: true
offload_optimizer: true
offload_teacher_model: true
sleep_level: 1

train:
  gpus: 4
  tuner_type: lora
  lora_rank: 8
  lora_alpha: 32
  tensor_model_parallel_size: 2
  pipeline_model_parallel_size: 1
  expert_model_parallel_size: 1
  context_parallel_size: 1
  output_dir: megatron_output/gkd_multi_turn_ray

rollout:
  gpus: 4
  vllm_tensor_parallel_size: 2
  vllm_gpu_memory_utilization: 0.4
  vllm_max_model_len: 4096
