@@ -68,48 +68,6 @@ class InklingModelProvider(GPTModelProvider):
6868 inkling_unpadded_vocab_size : int = 0
6969 inkling_hf_config : dict = field (default_factory = dict )
7070
71- def _get_num_floating_point_operations_with_runtime_stats (
72- self ,
73- * ,
74- batch_size : int ,
75- seqlen_sum : int | None ,
76- seqlen_squared_sum : int | None ,
77- cross_seqlen_sum : int | None = None ,
78- cross_seqlen_product_sum : int | None = None ,
79- ) -> float :
80- """Estimate full-training text FLOPs, including relative bias and shared experts.
81-
82- Follow Bridge's three-pass GEMM convention. Sliding attention uses the
83- smaller of dense attention and the local window's upper bound.
84- """
85- del cross_seqlen_sum , cross_seqlen_product_sum
86- tokens = batch_size * self .seq_length if seqlen_sum is None else seqlen_sum
87- squared = tokens * (tokens / batch_size ) if seqlen_squared_sum is None else seqlen_squared_sum
88- flops = 6.0 * tokens * self .hidden_size * self .vocab_size
89- for i , layer_type in enumerate (self .inkling_layer_types ):
90- sliding = layer_type == "hybrid_sliding"
91- heads = self .inkling_swa_num_attention_heads if sliding else self .num_attention_heads
92- groups = self .inkling_swa_num_query_groups if sliding else self .num_query_groups
93- dim = self .inkling_swa_kv_channels if sliding else self .kv_channels
94- extent = self .inkling_sliding_window if sliding else self .inkling_rel_extent
95- projections = self .hidden_size * ((2 * heads + 2 * groups ) * dim + heads * self .inkling_d_rel )
96- relative = heads * self .inkling_d_rel * extent
97- convolutions = 2 * self .inkling_conv_kernel_size * (self .hidden_size + groups * dim )
98- if self .moe_layer_freq [i ]:
99- mlp = (
100- 3
101- * self .hidden_size
102- * self .moe_ffn_hidden_size
103- * (self .moe_router_topk + self .inkling_n_shared_experts )
104- )
105- mlp += self .hidden_size * (self .num_moe_experts + self .inkling_n_shared_experts )
106- else :
107- mlp = 3 * self .hidden_size * self .ffn_hidden_size
108- flops += 6.0 * tokens * (projections + relative + convolutions + mlp )
109- attention_pairs = min (squared , tokens * extent ) if sliding else squared
110- flops += 12.0 * heads * dim * attention_pairs
111- return flops
112-
11371 def provide (self , pre_process = None , post_process = None , vp_stage = None ) -> GPTModel :
11472 """Construct the native GPT subclass without changing shared provider code."""
11573 from megatron .bridge .models .inkling .modeling_inkling import InklingGPTModel , inkling_layer_spec
0 commit comments