> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fastino.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Use https://docs.fastino.ai/llms.txt to discover and navigate pages. Use https://docs.fastino.ai/llms-full.txt when you need the complete documentation corpus. Use https://docs.fastino.ai/openapi.json as the source of truth for customer-facing routes. For GLiDE decision inference, call POST https://api.fastino.ai/v1/systemone with model fastino/GLiDE. Create managed config jobs with POST /v1/training/jobs using base_model. Both config and interactive jobs use /v1/training/jobs/{job_id} for their canonical REST lifecycle. For custom training loops, use the supported Tinker-compatible SDK client; its /v1/training/compat/tinker adapter is intentionally absent from OpenAPI and must not be called directly. Auto Train is private access and has no public route; direct interested users to sales@fastino.ai. Do not infer undocumented routes. Read API keys from FASTINO_API_KEY and never embed credentials in code, logs, or reports.

# 构建自定义训练循环

> 由你的应用控制采样、评分和更新时机，在一个 Fastino 交互式任务中了解 SDK 对象模型、构建对齐的 datum 并管理检查点。

你的应用决定采样内容、评分方式和更新时机。Fastino 执行交互式模型操作。
一个 `TrainingClient` 在整个循环中代表一个 Fastino 交互式任务。

## 控制循环

<Steps>
  <Step title="创建交互式任务">
    从功能响应中选择 `base_model` 和其他选项，然后调用
    `create_lora_training_client(...)`。从
    `training_client.get_info().model_data.model_id` 读取规范任务 ID。
  </Step>

  <Step title="为采样创建权重检查点">
    调用 `save_weights_for_sampler(name)`，然后使用返回的检查点路径创建采样客户端。
    这会将 rollout 策略绑定到同一个任务的明确工件。
  </Step>

  <Step title="收集 rollout 组">
    为每个提示词采样多个候选响应。你的应用负责提示词构建、响应渲染和分组。
  </Step>

  <Step title="计算奖励和优势值">
    为每个响应评分，然后将奖励转换为所选且功能支持的训练操作所需的优势值。
  </Step>

  <Step title="构建训练 datum">
    按 SDK 预期的形式组合模型输入、采样响应 token、采样元数据和 token 级训练信号。
  </Step>

  <Step title="更新同一个任务">
    通过现有 `TrainingClient` 提交受支持的前向/反向传播工作，然后执行优化器步骤。
  </Step>

  <Step title="保存恢复边界">
    在开始下一次迭代前，保存状态检查点，并将其标识符与应用步骤及数据集游标一起持久化。
  </Step>
</Steps>

## 对象模型

| 对象 | 作用 |
| - | - |
| `ServiceClient` | 查询功能并创建 SDK 客户端 |
| `TrainingClient` | 代表一个 Fastino 交互式任务并提交其模型操作 |
| `SamplingClient` | 从已解析的检查点采样 |
| `RestClient` | 列出或获取规范任务，并使用受支持的 SDK 方法管理检查点 |
| Future | 跟踪提交给任务的一项操作 |

SDK 模型 ID 就是规范的 Fastino 任务 ID。Future 和采样客户端不会创建独立运行。

要将确定性评分转换为组相对优势值，请参阅
[使用可验证奖励进行训练](/cn/training/verifiable-rewards)。

## 构建对齐的 datum

对于重要性采样式循环，提示词是上下文，采样到的补全是动作。确保 token 数组与所选模型
使用的 SDK 和渲染器对齐：

* 包含提示词和补全 token 的模型输入
* 与模型输入对齐的目标 token
* 与生成 token 对齐的采样对数概率
* 应用于补全位置的优势值

<Warning>
  提示词渲染、token 化、datum 构建和奖励执行均由客户端负责。在运行更大的工作负载前，
  请根据 `tinker==0.33.1` 和实时功能响应验证它们的形式。
</Warning>

## 保持依赖工作有序

将前向/反向传播阶段视为完成之前，请先解析其 future；在为更新后的状态创建检查点之前，
请先解析优化器 future。没有应用级协调时，不要让独立控制器修改同一个任务。

SDK 执行这些交互式操作。不要将它们复现为直接 HTTP 调用。

跟踪受支持调用返回的每个 future。逐个解析或取消 future。不支持通过 `retrieve_futures` 批量检索。

## 恢复循环

持久化规范任务 ID、应用步骤、数据集游标以及相关的 future 或检查点标识符。
这样，重启后的控制器无需重放更新即可确定哪些工作已完成。

有关恢复顺序和检查点类型，请参阅[检查点与恢复](/cn/training/checkpoints)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.