# HeliosScheduler

`HeliosScheduler` 基于 [Helios](https://huggingface.co/papers) 中提出的金字塔流匹配采样方法。

## HeliosScheduler[[diffusers.HeliosScheduler]]

#### diffusers.HeliosScheduler[[diffusers.HeliosScheduler]]

```python
diffusers.HeliosScheduler(num_train_timesteps: int = 1000, shift: float = 1.0, stages: int = 3, stage_range: list = [0, 0.3333333333333333, 0.6666666666666666, 1], gamma: float = 0.3333333333333333, thresholding: bool = False, prediction_type: str = 'flow_prediction', solver_order: int = 2, predict_x0: bool = True, solver_type: str = 'bh2', lower_order_final: bool = True, disable_corrector: list[int] = [], solver_p: SchedulerMixin = None, use_flow_sigmas: bool = True, scheduler_type: str = 'unipc', use_dynamic_shifting: bool = False, time_shift_type: typing.Literal['exponential', 'linear'] = 'exponential')
```

[源代码](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_helios.py#L35)

#### convert_model_output[[diffusers.HeliosScheduler.convert_model_output]]

```python
convert_model_output(model_output: Tensor, *args, sample: Tensor = None, sigma: Tensor = None, **kwargs)
```

[源代码](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_helios.py#L371)

**参数：**

model_output (`torch.Tensor`)：学习到的扩散模型的直接输出。

timestep (`int`)：扩散链中当前的离散时间步。

sample (`torch.Tensor`)：扩散过程生成的当前样本实例。

sigma (`torch.Tensor`, *可选*) : 噪声调度中当前步的 sigma。

**返回：** `torch.Tensor`

转换后的模型输出。

将模型输出转换为 UniPC 算法所需的对应类型。

#### init_sigmas[[diffusers.HeliosScheduler.init_sigmas]]

```python
init_sigmas()
```

[源代码](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_helios.py#L90)

初始化全局时间步和 sigma

#### init_sigmas_for_each_stage[[diffusers.HeliosScheduler.init_sigmas_for_each_stage]]

```python
init_sigmas_for_each_stage()
```

[源代码](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_helios.py#L108)

初始化每个阶段的 timesteps

#### multistep_uni_c_bh_update[[diffusers.HeliosScheduler.multistep_uni_c_bh_update]]

```python
multistep_uni_c_bh_update(this_model_output: Tensor, *args, last_sample: Tensor = None, this_sample: Tensor = None, order: int = None, sigma_before: Tensor = None, sigma: Tensor = None, **kwargs)
```

[源代码](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_helios.py#L591)

**参数：**

this_model_output (`torch.Tensor`) : 模型在 `x_t` 处的输出。

this_timestep (`int`) : 当前时间步 `t`。

last_sample (`torch.Tensor`) : 最后一个预测器之前的生成样本 `x_{t-1}`。

this_sample (`torch.Tensor`) : 最后一个预测器 `x_{t}` 之后生成的样本。

order (`int`) : 此步骤中 UniC-p 的 `p`。有效精度阶数应为 `order + 1`。

sigma_before (`torch.Tensor`, *可选*) : 噪声调度中上一步的 sigma。

sigma (`torch.Tensor`, *可选*) : 噪声调度中当前步的 sigma。

**返回：** `torch.Tensor`

当前时间步的修正后样本张量。

UniC (B(h) 版本) 的一步。

#### multistep_uni_p_bh_update[[diffusers.HeliosScheduler.multistep_uni_p_bh_update]]

```python
multistep_uni_p_bh_update(model_output: Tensor, *args, sample: Tensor = None, order: int = None, sigma: Tensor = None, sigma_next: Tensor = None, **kwargs)
```

[源代码](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_helios.py#L453)

**参数：**

model_output (`torch.Tensor`) : 学习到的扩散模型在当前时间步的直接输出。

prev_timestep (`int`) : 扩散链中的上一个离散时间步。

sample (`torch.Tensor`)：扩散过程生成的当前样本实例。

order (`int`) : 当前时间步的 UniP 阶数（对应于 UniPC-p 中的 *p*）。

sigma (`torch.Tensor`, *可选*) : 噪声调度中当前步的 sigma。

sigma_next (`torch.Tensor`, *可选*) : 噪声调度中下一步的 sigma。

**返回：** `torch.Tensor`

上一步时间步的样本张量。

UniP（B(h) 版本）的单步。或者，如果指定了，则使用 `self.solver_p`。

#### set_begin_index[[diffusers.HeliosScheduler.set_begin_index]]

```python
set_begin_index(begin_index: int = 0)
```

[源代码](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_helios.py#L182)

**参数：**

begin_index (`int`) : 调度器的起始索引。

设置调度器的起始索引。此函数应在推理之前从流水线中运行。

#### set_timesteps[[diffusers.HeliosScheduler.set_timesteps]]

```python
set_timesteps(num_inference_steps: int, stage_index: int | None = None, device: typing.Union[str, torch.device] = None, sigmas: bool | None = None, mu: bool | None = None, is_amplify_first_chunk: bool = False)
```

[源代码](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_helios.py#L195)

为每个阶段设置 timesteps 和 sigmas

#### time_shift[[diffusers.HeliosScheduler.time_shift]]

```python
time_shift(mu: float, sigma: float, t: Tensor)
```

[源代码](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_helios.py#L259)

**参数：**

mu (`float`) : 时间偏移的 mu 参数。

sigma (`float`) : 时间偏移的 sigma 参数。

t (`torch.Tensor`) : 输入的时间步。

**返回：** `torch.Tensor`

时间偏移的时间步。

对 sigmas 应用时间偏移。

scheduling_helios

