Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix moe tflops #445

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion megatron/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ def throughput_calculator(model, args, iteration_time, total_iterations):
num_layers = args.num_layers
vocab_size = args.padded_vocab_size
gqa = args.num_attention_heads // args.num_key_value_heads
num_experts_routed_to = args.topk
ffn_multiplier = 3 if args.swiglu else 2
macs_per_flops = 2

Expand All @@ -294,7 +295,7 @@ def throughput_calculator(model, args, iteration_time, total_iterations):

pre_and_post_mha_gemm_macs = batch_size * num_layers * (1 + (2 // gqa) + 1) * (hidden_size**2) * seq_len
mha_bgemm_macs = batch_size * num_layers * 2 * head_dim * num_attention_heads * (seq_len**2)
ffn_gemm_macs = batch_size * num_layers * ffn_multiplier * ffn_hidden_size * hidden_size * seq_len
ffn_gemm_macs = batch_size * num_layers * ffn_multiplier * ffn_hidden_size * hidden_size * seq_len * num_experts_routed_to
logit_lmhead_gemm_macs = batch_size * vocab_size * hidden_size * seq_len

fwd_macs = pre_and_post_mha_gemm_macs + mha_bgemm_macs + ffn_gemm_macs + logit_lmhead_gemm_macs
Expand Down