

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# FlashAttention のサポート
<a name="model-parallel-attention-head-size-for-flash-attention"></a>

FlashAttention のサポートはライブラリの機能で、モデル並列トレーニングの [https://sagemaker.readthedocs.io/en/v2.199.0/api/training/smp_versions/latest/smd_model_parallel_pytorch.html#smdistributed-modelparallel-torch-distributedmodel](https://sagemaker.readthedocs.io/en/v2.199.0/api/training/smp_versions/latest/smd_model_parallel_pytorch.html#smdistributed-modelparallel-torch-distributedmodel) によってラップされた Transformer モデルである*分散トランスフォーマー*モデルにのみ適用されます。この機能は [テンソル並列処理](model-parallel-extended-features-pytorch-tensor-parallelism.md) とも互換性があります。

[FlashAttention](https://github.com/HazyResearch/flash-attention) ライブラリは、`attention_head_size` が 8 の倍数で 128 未満の値に設定されているモデルのみをサポートしています。したがって、分散トランスフォーマーをトレーニングして FlashAttention が正しく動作することを確認するときは、アテンションヘッドサイズが要件を満たすようにパラメータを調整する必要があります。詳細については、「*FlashAttention GitHub リポジトリ*」の「[インストールと機能](https://github.com/HazyResearch/flash-attention#installation-and-features)」も参照してください。

例えば、`hidden_width=864` と `num_heads=48` を使用して Transformer モデルを設定すると仮定します。FlashAttention のヘッドサイズは `attention_head_size = hidden_width / num_heads = 864 / 48 = 18` と計算されます。FlashAttention を有効にするには、`num_heads` パラメータを `54` に調整して `attention_head_size = hidden_width / num_heads = 864 / 54 = 16` (つまり 8 の倍数) となるように調整する必要があります。