The inaccurate flop results after several rounds
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- python
調査の方向性
profiler.get_model_profile の呼び出しから始め、提供されている test_model ループと固定の入力形状を使って、繰り返し測定を再現します。後続ラウンドの FLOPs、MACs、パラメータ数、レイテンシを最初のラウンドと比較します。完了の条件は、同じモデルと入力に対してプロファイリングを繰り返しても FLOPs が増加しないことです。
索引モデルが issue の本文から書いたものです。
説明
Hi I tried to use the method "get_model_profile" to get the latency and flop for my model. To get avoid of the influence from randomness, I used this method in a for loop for several times, and then an average operation would be done.
However, I found the results for the following rounds of the first one are not correct, which is far away from the theoritical result. As shown in the fig below, you could see the flops is increasing with the round, which is not correct, since I gave the same size of input into the model.
And this is the code:
def test_model(model, input_shape, warmup=20, num_tests=1000):
results = []
for _ in range(num_tests):
#from profiler import get_model_profile
flops, macs, params, latency = profiler.get_model_profile(
model=model,
input_shape=input_shape,
print_profile=False,
detailed=True,
module_depth=-1,
top_modules=1,
warm_up=warmup,
as_string=False
)
del sys.modules['profiler']
results.append((flops/10**9, macs/10**9, params/10**3, latency*10**3))
df = pd.DataFrame(results, columns=['FLOPs', 'MACs', 'Params', 'Latency'])
return df
df_swin = test_model(Swin, (batch_size, math.prod(input_resolution), dim), warmup=warmup, num_tests=num_tests)
I tried to modify this code, and found if I could assign the model again in a different iteration with the profiler imported again, then the result is correct, shown in the fig below.
And the following is the modified code.
def test_model(input_shape, warmup=20, num_tests=1000):
results = []
for _ in range(num_tests):
#from profiler import get_model_profile
import profiler
model = MySwinTransformerModel(dim, input_resolution, num_heads, window_size, mlp_ratio, depth).to(device)
# model = MyTensorizedTransformerModel(dim, input_resolution, num_heads, n_proj, mlp_ratio, depth).to(device)
flops, macs, params, latency = profiler.get_model_profile(
model=model,
input_shape=input_shape,
print_profile=False,
detailed=True,
module_depth=-1,
top_modules=1,
warm_up=warmup,
as_string=False
)
del sys.modules['profiler']
results.append((flops/10**9, macs/10**9, params/10**3, latency*10**3))
df = pd.DataFrame(results, columns=['FLOPs', 'MACs', 'Params', 'Latency'])
return df
- 主要言語
- Python
- スター
- 6.8k
- フォーク
- 1.1k
- 平均マージ
- 2日 16時間
- マージ済み PR(30日)
- 1
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
deepspeedai/DeepSpeedExamples のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 52/100
deepspeedai/DeepSpeedExamples#996 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
deepspeedai/DeepSpeedExamples#995 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 52/100
deepspeedai/DeepSpeedExamples#989 ·
-
moe example 404 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
deepspeedai/DeepSpeedExamples#984 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
deepspeedai/DeepSpeedExamples#979 · コメント 6 件 ·
deepspeedai/DeepSpeedExamples の issue をすべて見る
似ている issue
-
area: harness bug status: needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Human-Agent-Society/reef#625 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
learningequality/kolibri#15351 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Name consistency オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
eellak/triplestore#65 · コメント 1 件 ·