Model Studio online policy distillation training configuration: submission methods, teacher model configuration, hyperparameters, tuning pitfalls, task management, and FAQ
Submit a Training Job
Three submission methods, with increasing flexibility. Configuration priority:__init__()(SDK init function) Default Value < YAML < run() runtime parameters (the latter overrides the former). Pass in teacher_model to trigger distillation.
Recommend: one step done (run)
Pass AgenticRL().run(...) to complete function registration, data upload, and job submission in one step; pass an additional teacher_model to trigger distillation.
resources Configure training billing resources:charge_type: mtu_postpaid Indicates pay-as-you-go billing by MTU (Model Studio compute Type unit),mtu_spec_code specify the Type (e.g. MTU4), mtu_capacity specify the Capacity.functions The Parameter determines the run mode (pure distillation / Model OPD / Agentic OPD), and teacher_model is unrelated ——teacher_model only triggers distillation. For mode selection, see Overview of applicable scenarios. Here only the SDK-layer value mapping is listed; the distinguishing criterion is whether a Rollout Component is passed (determines using native Rollout or Custom Rollout):
- Model OPD: do not pass a Rollout Component → use native Rollout, including pure distillation (
functions=None) and add Reward (only pass Reward Component to overlay task reward) two tiers - Agentic OPD (None Reward): only pass Rollout Component → Custom Rollout (supports multi-turn dialogue, custom interaction, structured tool call) + teacher distillation
- Agentic OPD (with Reward): simultaneously pass Rollout + Reward → Custom Rollout + teacher distillation + Reward
- Pass
None(rather than empty list[]) → pure distillation, reward derived metrics not reported, distillation loss-type metrics and teacher health-type metrics still reported normally
YAML Configure
Suitable for multiple experiments or managing multiple groups of parameters, via teacher_model Field specifies the teacher model.
CLI Command
Pass dashscope rl run Submit,--teacher-model overrides in YAML teacher_model.
--teacher-modelhelp text (original): Enable OPD with this teacher model (overrides YAML); Rollout and Reward are optional. Meaning: Enable OPD and specify the teacher model (overrides YAML); Rollout and Reward are Optional.
Common CLI Commands:
Actions | Command | Description |
|---|---|---|
Submit Training |
| Read YAML configuration to submit; --verbose human-readable, -o json machine-readable |
Upload Data |
| Only upload data, return File ID |
Example submission script submit_job.py (reference implementation, classpath is example class name)
Example submission script submit_job.py (reference implementation, classpath is example class name)
submit_job.py Attach hyperparameters as command-line arguments, adjustable as needed.--no-reward is a convenience switch on the example side (not an SDK parameter), equivalent to the SDK layer functions=None. zipdir Recommend explicitly specifying to avoid entry-class localization failure. Key snippets are as follows:Configure Teacher Model
teacher_model is the submission parameter that triggers distillation. Passing it triggers distillation; not passing it does not. After it is passed, the SDK internal field training_type is automatically set to pg_opd (strategy distillation training type identifier, corresponding to that in YAML training.type), no need to and cannot manually specify the training type.
Behavior Conclusion:
- Pass
teacher_modelforcestraining_type=pg_opd, no need to and cannot manually specify the training type - Write in YAML
training.type: pg_opdbut not passedteacher_modelwhen, the control plane reports an errorerror 3006(teacher model missing) hyper_parametersUndeclared keys will not be recognized, and will neither report errors nor take effect
Three hard constraints
Teacher model configuration must simultaneously satisfy the following three constraints; failure to meet any one will cause distillation to fail or the submission to be rejected.
Constraint | Description | Behavior when violated |
|---|---|---|
Must be a Model Studio model ID | Only accepts Model Studio-registered model IDs, not HuggingFace repository names or weight paths |
|
Teacher-student same model family | The teacher and student model tokenizers must be alignable (tokenizer alignment: consistent vocabulary, token ids correspond one-to-one, e.g., both belong to the Qwen3.5 series) | When vocabularies are not aligned, token-level distributions cannot correspond position by position, and the distillation signal fails |
Teacher model stronger than student model | Distillation transfers LLM capabilities to a smaller model | No distillation gain when teacher is not stronger than student |
Training Hyperparameters
hyper_parameters field names and value ranges are consistent, grouped into 4 categories: Algorithm (algorithm; kl_loss_coef not enabled in OPD) / Optimize (learning_rate, lr_scheduler_type, lr_warmup_steps, n_epochs) / Data throughput (batch_size, n_rollouts, ppo_mini_batch_size, max_length, max_prompt_length) / Evaluation & save (eval_steps, save_steps, save_strategy, save_total_limit).
Required parameters comprehensive table
The comprehensive table below merges field definitions, value ranges, and recommended starting points by model scale × data phase; you can launch training directly by adopting the starting point column, then iterate per §tuning decision table.
Parameter | Introduction | Value Range | Small Model Quick Validation | Formal Training | Large Model |
|---|---|---|---|---|---|
algorithm | Training Algorithm | gspo | gspo | gspo | gspo |
kl_loss_coef | KL Loss Coefficient (OPD Not Enabled) | [0, 10] | — | — | — |
learning_rate | Learning Rate | [0, 1] | 1e-6 | 3e-6 ~ 5e-6 | 2e-6 ~ 3e-6 |
lr_scheduler_type | Scheduler | cosine / constant | cosine | cosine | cosine |
lr_warmup_steps | Warmup Steps (-1 = Auto; set 0 for small-data smoke test to avoid exceeding total steps) | >= -1 | 0 | -1 | -1 |
n_epochs | Training Epochs | [1, 200] | 1 | 2 ~ 3 | 1 ~ 2 |
batch_size | Samples per step | [1, 100000] | 128 | 128 ~ 256 | 256 ~ 512 |
n_rollouts | Samples per prompt | [1, 1024] | 8 | 8 | 8 ~ 16 |
ppo_mini_batch_size | PPO mini-batch | [1, 100000] | 8 | 16 ~ 32 | 32 ~ 64 |
max_length | Max tokens for prompt + resp | [1, 131072] | 8192 | 8192 ~ 16384 | 8192 ~ 16384 |
max_prompt_length | Max tokens for prompt | [1, 131072] | 2048 | 2048 ~ 4096 | 2048 ~ 4096 |
eval_steps | Eval interval (Recommendation: total steps / 10~20) | [1, 999999] | 1 | Total steps / 10~20 | Total steps / 10~20 |
save_steps | Save interval (Recommendation: eval_steps × 2~3) | [1, 999999] | 1 | eval_steps × 2~3 | eval_steps × 2~3 |
save_strategy | Save strategy | steps / epoch | steps | steps | steps |
save_total_limit | Max ckpt retained | [1, 200] | 2 | 3 | 2 ~ 3 |
- Sample Count:
batch_size × n_rollouts = actual samples generated per step - mini-batch upper limit:
ppo_mini_batch_size ≤ batch_size × n_rollouts learning_ratedetermines distillation convergence speed—OPD has nokl_loss_coefconstrains model deviation from initial policy (prevents output style drift), learning rate is the only parameter controlling convergence speed
Optional Parameters
The following parameters are used to control distributed training resource configuration, generally using default values is sufficient. The default values in the table are the values when not passed; actual values are subject to what is passed at submission.
Parameter | Description | Default Value | Value Range |
|---|---|---|---|
n_gpus_rollout | Number of GPUs in the Rollout Phase | 8 | [1, 1024] |
n_gpus_training | Number of GPUs in the Training Phase | 8 | [1, 1024] |
nnodes_rollout | Number of Nodes in the Rollout Phase | 1 | [1, 256] |
nnodes_training | Number of Nodes in the Training Phase | 2 | [1, 256] |
Teacher Model Deployment Parameters and Disabled Items
Pay special attention to the following parameters; understanding them helps you avoid mistakenly tuning parameters that will not take effect.
- algorithm: Default
gspo(GSPO, group relative policy optimization). When reward is enabled, determines the implementation method of policy optimization; pure distillation (without registering reward) does not participate in loss calculation, generally no modification needed - Teacher model deployment resources: can explicitly configure
opd_teacher_*parameter, if not passed, takes the Default Value. Example default values are as follows:
- Long sequence: increase
opd_teacher_max_model_len(along withopd_teacher_max_num_batched_tokens↑) - Tight GPU memory: Lower
opd_teacher_gpu_memory_utilization
Parameter | demo Default Value |
|---|---|
opd_teacher_nnodes | 1 |
opd_teacher_n_gpus_per_node | 8 |
opd_teacher_infer_tp | 8 |
opd_teacher_gpu_memory_utilization | 0.75 |
opd_teacher_max_model_len | 34816 |
opd_teacher_max_num_batched_tokens | 4096 |
opd_teacher_max_num_seqs | 2 |
opd_teacher_num_replicas | 1 |
- kl_loss_coef: OPD does not consume this parameter—distillation does not constrain policy divergence via KL divergence (a metric measuring the difference between two probability distributions), and convergence speed is controlled by
learning_ratealone. The "—" marked in the required parameter table indicates OPD does not consume it. You can keep the Default or leave it empty; no need to zero it out or Delete it.
Parameter Tuning and Pitfall Avoidance
Tuning Decision Table
When metrics are abnormal, refer to this table to select the preferred adjustment item and magnitude; for complete metric meanings and troubleshooting decision tree, seeOnline Policy Distillation Observable Configuration.
Symptom | Primary Adjustment | Adjustment Range | Fallback |
|---|---|---|---|
distillation/loss not decreasing | learning_rate ↑ | × 1.5~2 | Check valid_token_rate + Reward function |
distillation/loss exploding | learning_rate ↓ | × 0.5 | Check teacher model health metrics |
valid_token_rate < 1 | Submit a ticket (teacher model side) | — | Confirm teacher-student same model family |
Overfitting (Validation Set no longer improving) | n_epochs ↓ | -1~2 | save_strategy=steps early stop |
Reward signal not taking effect (success_rate=0) | Check FC calls and Reward function | — | Reproduce scoring with local test_functions |
Rollout slow | n_rollouts ↓ / max_length tighten | — | Add concurrency (FunctionComponentRuntime.concurrency/capacity, see Development) |
OOM | ppo_mini_batch_size ↓ | × 0.5 | max_length ↓ / tune parallel parameters |
High truncation rate | max_length ↑ | + 2048 | Check max_prompt_length |
Tuning Operation Recommendations
- Check first
valid_token_rate: When this metric is below 1, the teacher model scoring has gaps, and the explanatory power of other metrics decreases. Investigate this first before tuning hyperparameters. - Change only one variable at a time: Tuning both
learning_rateandbatch_sizesimultaneously makes attribution impossible. - Train for
eval_steps × 3steps before judging the trend: Distillation curves have less noise, but trends are hard to judge over short periods. Wait at least 3 evaluation intervals before judging the direction.
Anti-patterns
The following configurations have been proven in practice to cause training failure or resource waste and should be avoided.
Anti-pattern | Consequence |
|---|---|
Execute OPD with SFT's lr starting point (5e-5) | Training diverges — distillation is sensitive to lr, one order of magnitude lower than SFT |
Set n_epochs to 10+ expecting "thorough training" | Deepens overfitting to the teacher model's style, validation set collapses |
Use HuggingFace repository name as teacher_model | 400 InvalidParameter: teacher_model must be a valid model ID |
Teacher model capability weaker than student model | No distillation gain, wasted compute |
max_length=32K for safety | teacher vLLM reserves KV cache according to opd_teacher_max_model_len, and max_num_seqs is compressed (demo only 2), reducing scoring throughput; short sequences will not cause OOM. Set based on actual longest sequence ×1.2~1.5; 32K is only needed when sequences actually reach 32K |
pass an empty list [] as pure distillation | the control plane may not handle [] and None the same way, possibly unable to execute native rollout; pure distillation must pass None |
Task Management
This section provides commands for querying, canceling, deleting, and viewing logs of training tasks, as well as experiment management and continual training methods.
SDK / CLI Command Comparison
Task management commands (query, cancel, delete, logs) are as follows; pass an extra parameter when submitting teacher_model:
Actions | SDK | CLI |
|---|---|---|
Query Status |
|
|
List Tasks |
|
|
Cancel Task |
|
|
Delete Task |
| CLI not supported, use SDK |
View Logs |
|
|
Experiment Management
- YAML Multiple-experiment mode:
job_nameidentifies experiments,finetuned_outputidentifies output models; change these two each time to isolate experiments; YAML centralizes configuration management for Git versioning - Configuration priority:
__init__()< YAML <run()Runtime parameters — for controlled experiments only change the outermost layer - Parameter sweep / CI scenarios (advanced usage, general users can skip): when the function is stable and only hyperparameters change, you can
functionspass at the Component levelentity_id(such asRewardFunctionComponent(..., entity_id="rw-xxx")) reuse registered components, saving repeated registration and upload. Entity ID (ro-represents Rollout,rw-represents Reward) is taken from the return value of the first registration, Field Nameentity_id, can be put into CI configuration for long-term reuse:
Continued Training and Checkpoint
Checkpoint retention and selection:
save_strategy=steps+save_steps=100+save_total_limit=3: Keep up to 3 piece, automatically clean the oldest when exceeded- Which Checkpoint to select: When reward is enabled, look at
validation/data/reward/mean@1select the best point (in pure distillation without reward enabled, this metric is not reported; based onactor/distillation/losstrend stabilized point selection), not necessarily the last one - Keep 3~5 piece to balance space and rollback needs
- Continue training = use the model produced last time as
modelinput parameter and submit again; hyperparameters can be fine-tuned (lr is usually reduced) - Applicable: Data increment / Reward adjustment / long-chain gradual convergence
- Note: The base model version must be consistent; cross-base-model cannot directly continue training
- In a multi-phase training pipeline, each phase's output can serve as the next phase's
modelinput, progressing level by level
Next Steps
- Review principles and scenario selection → Online Policy Distillation Training Overview
- Model OPD Development (Pure Distillation/Reward) → Model OPD Development
- Agentic OPD Development (Custom Rollout) → Agentic OPD Development
- Training Metrics Quick Reference, Effect Evaluation and Troubleshooting → Online Policy Distillation Observable Configuration