The inaccurate flop results after several rounds
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- machine-learning, performance
Hướng nghiên cứu
Bắt đầu từ lệnh gọi profiler.get_model_profile và tái hiện các phép đo lặp lại bằng vòng lặp test_model được cung cấp cùng với kích thước đầu vào cố định. So sánh FLOPs, MACs, số tham số và độ trễ của các vòng sau với vòng đầu tiên; hoàn thành khi việc profiling lặp lại cùng một model và input không khiến FLOPs tăng lên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 6.8k
- Fork
- 1.1k
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 1
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của deepspeedai/DeepSpeedExamples
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 52/100
deepspeedai/DeepSpeedExamples#996 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
deepspeedai/DeepSpeedExamples#995 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 52/100
deepspeedai/DeepSpeedExamples#989 ·
-
moe example 404 Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
deepspeedai/DeepSpeedExamples#984 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
deepspeedai/DeepSpeedExamples#979 · 6 bình luận ·
Tất cả issue của deepspeedai/DeepSpeedExamples
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stephrobert/dsoxlab#238 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
sublimehq/package_control#1780 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
nwg-piotr/nwg-displays#145 ·