Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Alibaba ROLL SFTWorker Val Step

From Leeroopedia


Knowledge Sources
Domains Supervised_Learning, Evaluation
Last Updated 2026-02-07 20:00 GMT

Overview

Concrete SFT validation step provided by the Alibaba ROLL library.

Description

The SFTWorker.val_step method computes cross-entropy loss on validation data without gradient computation.

Usage

Called by the SFT pipeline at evaluation intervals.

Code Reference

Source Location

  • Repository: Alibaba ROLL
  • File: roll/pipeline/sft/sft_worker.py
  • Lines: L41-51

Signature

class SFTWorker(Worker):
    @register(Dispatch.DP_MP_DISPATCH_FIRST, clear_cache=False)
    def val_step(self, data: DataProto) -> DataProto:
        """
        Validation step for SFT.

        Args:
            data: DataProto with input_ids, attention_mask, labels

        Returns:
            DataProto with validation loss metric
        """

Import

from roll.pipeline.sft.sft_worker import SFTWorker

I/O Contract

Inputs

Name Type Required Description
data DataProto Yes Validation batch

Outputs

Name Type Description
val_loss float sft_train/val_loss metric

Usage Examples

if step % eval_steps == 0:
    val_results = sft_train.execute_all_sync("val_step", val_batch)

Related Pages

Implements Principle

Requires Environment

Environment Dependencies

This implementation requires the following environment constraints:

Heuristics Applied

No specific heuristics apply to this implementation.

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment