Skip to content

Commit 924574d

Browse files
committed
refactor(inkling): remove optional enablement telemetry
Signed-off-by: Neil Kale <263453039+kalectory@users.noreply.github.com>
1 parent 7cd9a88 commit 924574d

3 files changed

Lines changed: 0 additions & 53 deletions

File tree

‎src/megatron/bridge/models/inkling/inkling_bridge.py‎

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -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

‎src/megatron/bridge/models/inkling/inkling_mapping.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class InklingSharedExpertMapping(MegatronParamMapping[torch.Tensor]):
7373
"""Map a TP-sharded shared MLP to one slice of a replicated expert stack."""
7474

7575
is_grouped_export = True
76-
allow_hf_name_mismatch = True
7776

7877
def __init__(self, megatron_param: str, hf_param: str):
7978
super().__init__(megatron_param, hf_param)

‎tests/unit_tests/models/inkling/test_inkling_bridge.py‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,6 @@ def test_quantized_checkpoint_is_rejected(raw_config):
8585
InklingBridge().provider_bridge(source(raw_config))
8686

8787

88-
def test_flops_include_each_shared_expert_and_its_gate_row(raw_config):
89-
provider = InklingBridge().provider_bridge(source(raw_config))
90-
kwargs = dict(batch_size=2, seqlen_sum=128, seqlen_squared_sum=8192)
91-
before = provider._get_num_floating_point_operations_with_runtime_stats(**kwargs)
92-
provider.inkling_n_shared_experts += 1
93-
after = provider._get_num_floating_point_operations_with_runtime_stats(**kwargs)
94-
expected = 6 * 128 * sum(provider.moe_layer_freq) * provider.hidden_size * (3 * provider.moe_ffn_hidden_size + 1)
95-
assert after - before == expected
96-
97-
9888
@pytest.mark.parametrize(
9989
"field,value", [("q_bias", True), ("shared_expert_sink", False), ("gate_activation", "softmax")]
10090
)

0 commit comments

Comments
 (0)