MCPcopy Create free account
hub / github.com/OpenSparseLLMs/Linear-MoE / forward

Method forward

linear_moe/sequence_modeling/lasp2/lasp2.py:62–79  ·  view source on GitHub ↗
(
        self,
        q: torch.Tensor,
        k: torch.Tensor,
        v: torch.Tensor,
    )

Source from the content-addressed store, hash-verified

60 module._is_hf_initialized = True
61
62 def forward(
63 self,
64 q: torch.Tensor,
65 k: torch.Tensor,
66 v: torch.Tensor,
67 ) -> torch.Tensor:
68 q, k, v = (rearrange(x, 'n b h d -> b h n d') for x in (q, k, v))
69
70 if self.la_feature_map_fn is not None:
71 q, k = map(self.la_feature_map_fn, (q, k))
72
73 # expects q: b, h, n, d
74 output = self._la_impl(q, k, v, get_context_parallel_group())
75
76 output = self.la_output_norm(output)
77 output = rearrange(output, 'b h n d -> n b (h d)')
78
79 return output

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected