# 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/v0.43.0/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/v0.43.0/src/diffusers/schedulers/scheduling_helios.py#L371)

**パラメータ:**

model_output (`torch.Tensor`) : 学習済み拡散モデルからの直接の出力です。

timestep (`int`) : 拡散チェーンにおける現在の離散タイムステップ。

sample (`torch.Tensor`) : 拡散プロセスによって生成されたサンプルの現在のインスタンス。

sigma (`torch.Tensor`, *任意*) : ノイズスケジュールにおける現在のステップのシグマです。

**戻り値:** `torch.Tensor`

変換後のモデルの出力。

モデルの出力を、UniPCアルゴリズムが要求する対応する型に変換します。

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

```python
init_sigmas()
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/schedulers/scheduling_helios.py#L90)

グローバルのtimestepsとsigmasを初期化します

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

```python
init_sigmas_for_each_stage()
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/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/v0.43.0/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 (`torch.Tensor`, *任意*) : ノイズスケジュールにおける現在のステップのシグマです。

**戻り値:** `torch.Tensor`

現在のタイムステップにおける修正済みサンプルテンソル。

UniC（B(h)版）の1ステップ。

#### 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/v0.43.0/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_next (`torch.Tensor`, *任意*) : ノイズスケジュールにおける次のステップのシグマです。

**戻り値:** `torch.Tensor`

前のタイムステップのサンプルテンソル。

UniP（B(h)版）の1ステップ。または、指定されている場合は`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/v0.43.0/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/v0.43.0/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/v0.43.0/src/diffusers/schedulers/scheduling_helios.py#L259)

**パラメータ:**

mu (`float`) : 時間シフト用の mu パラメータ。

sigma (`float`) : 時間シフト用の sigma パラメータ。

t (`torch.Tensor`) : 入力タイムステップ。

**戻り値:** `torch.Tensor`

時間シフトされたタイムステップ。

シグマに時間シフトを適用します。

scheduling_helios

