0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

生成モデルの基礎知識9 Operator Fusion & Dynamic Batching

Posted at

こんにちは。
最近、NVIDIA-Certified Associate: Generative AI and LLMs (NCA-GENL)を習得しました。
その際に知っておいた方が良い基礎知識とコードの書き方を共有したいと思います。
生成AIのチュートリアル:

1.Operator Fusionとは?(モデルの運用・Inference)
オペレーター・フュージョンとは、小さな操作を実行する複数の連続するループを、より効率的な単一のループに結合する最適化手法で、ループ制御のオーバーヘッドが削減され、さらなるベクトル化最適化が可能になり、キャッシュ局所性が向上する。

LLMの運用ではオーバーヘッドが問題
各ループのイテレーションでは、ループ制御メカニズムのためにオーバーヘッドが発生する。
複数のループを融合することで、中間ループのこのオーバーヘッドが排除され、処理パイプラインが効率化。
例えばReLUを単一のループに結合することで、ループ制御のオーバーヘッドを削減できる。

サンプルコード

import numpy as np

def fused_operation(x):
   return np.exp(x) * np.log(x) 

x = np.array([1, 2, 3, 4])
result = fused_operation(x)

2.Dynamic Batchingとは?(モデルの運用・Inference)
ダイナミックバッチ処理は、バッチが満杯になった時、または最大時間が経過したときにバッチを実行する。
これにより、高トラフィック期間においてもスループットを維持しつつ、従来のバッチ処理と比較してレイテンシー(遅延)が改善する。

batching.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?