TRL documentation

AMD GPUでのトレーニング

You are viewing v1.18.0 version. A newer version v1.18.1 is available.
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

AMD GPUでのトレーニング

TRLのトレーナーは、コードの変更なしでAMD Instinct GPU上で動作します。PyTorchのROCmビルドでは、これらをcudaデバイスとして公開するため、ドキュメントの残りの部分に記載されているコマンドはそのまま使用できます。

インストール

PyTorchのROCmビルドをインストールし、同じ環境でTRLをインストールします:

pip install torch torchvision --index-url https://download.pytorch.org/whl/rocm7.2
pip install trl

アテンションカーネル

このドキュメントの例で使用されている FlashAttention カーネル(kernels-community/flash-attn2、flash-attn3 および flash-attn4)には、ROCm 向けのビルドがありません。AMD GPU では、kernels ライブラリ(pip install trl[kernels])によって Hub からダウンロードされる kernels-community/aiter-flash-attn を使用してください。

from trl import SFTConfig

training_args = SFTConfig(model_init_kwargs={"attn_implementation": "kernels-community/aiter-flash-attn@v2"})

カーネルにはアテンション・ロジットのソフトキャッピングがなく、Transformers は警告なしで attn_logit_softcapping をスキップするため、Gemma 2 のようにこれを使用するモデルは、キャップなしのアテンションで学習されます。

vLLMによる生成

use_vllm=True を使用した GRPO と RLOO には、vLLM の ROCm ビルドが必要です。vLLM インストールガイドを参照してください。

Update on GitHub