Skip to content
Open
Show file tree
Hide file tree
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
30 changes: 24 additions & 6 deletions tests/utils/test_flops_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,30 @@ def __init__(self, config_dict):
"num_experts_per_tok": 4,
"sliding_window": 128,
"layer_types": [
"sliding_attention", "full_attention", "sliding_attention", "full_attention",
"sliding_attention", "full_attention", "sliding_attention", "full_attention",
"sliding_attention", "full_attention", "sliding_attention", "full_attention",
"sliding_attention", "full_attention", "sliding_attention", "full_attention",
"sliding_attention", "full_attention", "sliding_attention", "full_attention",
"sliding_attention", "full_attention", "sliding_attention", "full_attention"
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
Comment on lines +223 to +246
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This long list of repeating strings can be made much more concise and maintainable by using list multiplication. This approach makes the code easier to read and simplifies future modifications if the number of layers changes.

Suggested change
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"full_attention",
*["sliding_attention", "full_attention"] * 12,

],
},
"batch_seqlens_tuple": ([512, 1024, 2048], [4096, 4096, 4096]),
Expand Down
2 changes: 2 additions & 0 deletions verl/utils/flops_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ def _estimate_apertus_flops(config, tokens_sum, batch_seqlens, delta_time):
flops_achieved = flops_all_token * (1.0 / delta_time) / 1e12
return flops_achieved


def _estimate_gpt_oss_flops(config, tokens_sum, batch_seqlens, delta_time):
hidden_size = config.hidden_size
vocab_size = config.vocab_size
Expand Down Expand Up @@ -383,6 +384,7 @@ def _estimate_gpt_oss_flops(config, tokens_sum, batch_seqlens, delta_time):
flops_achieved = flops_all_token * (1.0 / delta_time) / 1e12
return flops_achieved


def _estimate_unknown_flops(config, tokens_sum, batch_seqlens, delta_time):
return 0

Expand Down
Loading