Run this model with HF Jobs
Run replicate/megablocks on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/replicate/megablocks. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/replicate/megablocks on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use replicate/megablocks with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use replicate/megablocks with Kernels:
# !pip install kernels from kernels import get_kernel # a version (or an explicit revision) is required; see the "Files and versions" tab for the available ones kernel = get_kernel("replicate/megablocks", version=1) - Notebooks
- Google Colab
- Kaggle
drbh commited on
Commit ·
484fde0
1
Parent(s): 6756875
fix: prefer relative imports
Browse filesFiles changed (31)
- build.toml-1
- torch-ext/megablocks/grouped_gemm/backend.py+2-1
- torch-ext/megablocks/layers/arguments.py+2-1
- torch-ext/megablocks/layers/common.py+1-1
- torch-ext/megablocks/layers/dmlp_registry.py+2-2
- torch-ext/megablocks/layers/dmoe.py+8-5
- torch-ext/megablocks/layers/glu.py+16-5
- torch-ext/megablocks/layers/memory_test.py+2-1
- torch-ext/megablocks/layers/mlp.py+9-5
- torch-ext/megablocks/layers/moe.py+50-18
- torch-ext/megablocks/layers/mpu.py+2-1
- torch-ext/megablocks/layers/router.py+4-2
- torch-ext/megablocks/layers/sharedexpert_registry.py+4-2
- torch-ext/megablocks/ops/__init__.py+14-14
- torch-ext/megablocks/ops/all_to_all_benchmark.py+5-2
- torch-ext/megablocks/ops/binned_gather.py+1-1
- torch-ext/megablocks/ops/binned_scatter.py+1-1
- torch-ext/megablocks/ops/cumsum.py+1-1
- torch-ext/megablocks/ops/gather.py+1-1
- torch-ext/megablocks/ops/histogram.py+1-1
- torch-ext/megablocks/ops/histogram_benchmark.py+1-1
- torch-ext/megablocks/ops/matmul_benchmark.py+1-1
- torch-ext/megablocks/ops/padded_gather.py+1-1
- torch-ext/megablocks/ops/padded_scatter.py+1-1
- torch-ext/megablocks/ops/padded_scatter_benchmark.py+1-1
- torch-ext/megablocks/ops/permute_benchmark.py+1-1
- torch-ext/megablocks/ops/replicate.py+1-1
- torch-ext/megablocks/ops/scatter.py+1-1
- torch-ext/megablocks/ops/sort.py+1-1
- torch-ext/megablocks/ops/sort_benchmark.py+1-1
- torch-ext/megablocks/ops/topology.py+1-1
22 unmodified lines2324252627282922 unmodified lines"10.1","11.8","12.0"# "12.4"]depends = ["torch", "cutlass_3_8"]src = [22 unmodified lines23242526272822 unmodified lines"10.1","11.8","12.0"]depends = ["torch", "cutlass_3_8"]src = [
9 unmodified lines101112131415169 unmodified lines# We import the backend operations from the megablocks package as# grouped_gemm is vendored in megablocks in this repository.# from ... import _ops as backendfrom megablocks._ops import ops as backend # type: ignoredef _allocate_output(a, b, batch_sizes, trans_a, trans_b):assert not (trans_a and trans_b)9 unmodified lines10111213141516179 unmodified lines# We import the backend operations from the megablocks package as# grouped_gemm is vendored in megablocks in this repository.# from ... import _ops as backend# from megablocks._ops import ops as backend # type: ignorefrom .._ops import ops as backend # type: ignoredef _allocate_output(a, b, batch_sizes, trans_a, trans_b):assert not (trans_a and trans_b)
8 unmodified lines91011121314158 unmodified linesimport torch.distributed as distimport torch.nn.functional as Fimport megablocks.grouped_gemm_util as grouped_gemm# Type annotation for in-place Tensor initialization function.InitFn = Union[Callable[[torch.Tensor], None], partial[torch.Tensor]]8 unmodified lines9101112131415168 unmodified linesimport torch.distributed as distimport torch.nn.functional as F# import megablocks.grouped_gemm_util as grouped_gemmfrom .. import grouped_gemm_util as grouped_gemm# Type annotation for in-place Tensor initialization function.InitFn = Union[Callable[[torch.Tensor], None], partial[torch.Tensor]]
2 unmodified lines34567892 unmodified linesimport torchfrom megablocks.layers.arguments import Argumentsdef dtype(args: Arguments):2 unmodified lines34567892 unmodified linesimport torchfrom .arguments import Argumentsdef dtype(args: Arguments):
2 unmodified lines3456789102 unmodified linesfrom typing import Unionfrom megablocks.layers import glu, mlpfrom megablocks.layers.arguments import ArgumentsMlpType = Union[mlp.SparseMLP, glu.SparseGLU]2 unmodified lines3456789102 unmodified linesfrom typing import Unionfrom . import glu, mlpfrom .arguments import ArgumentsMlpType = Union[mlp.SparseMLP, glu.SparseGLU]
5 unmodified lines6789101112131415165 unmodified linesimport torchfrom stk import Matriximport megablocks.ops as ops# from megablocks.ops import opsfrom megablocks.layers import common, dmlp_registry, moe, mpufrom megablocks.layers.arguments import Argumentsdef promote_scalar(x):return x.view(1) if not len(x.size()) else x5 unmodified lines6789101112131415161718195 unmodified linesimport torchfrom stk import Matrix# import megablocks.ops as ops# # from megablocks.ops import ops# from megablocks.layers import common, dmlp_registry, moe, mpu# from megablocks.layers.arguments import Argumentsfrom .. import opsfrom . import common, dmlp_registry, moe, mpufrom .arguments import Argumentsdef promote_scalar(x):return x.view(1) if not len(x.size()) else x
3 unmodified lines45678910111213143 unmodified linesimport stk.opsimport torchfrom megablocks import grouped_gemm_util as ggfrom megablocks.layers import common, mpufrom megablocks.layers.activation_fn import act_fnfrom megablocks.layers.arguments import Argumentsfrom megablocks.layers.mlp import (SharedMLP,SparseMLP,create_dmoe_expert_weights,3 unmodified lines456789101112131415161718192021222324253 unmodified linesimport stk.opsimport torch# from megablocks import grouped_gemm_util as gg# from megablocks.layers import common, mpu# from megablocks.layers.activation_fn import act_fn# from megablocks.layers.arguments import Arguments# from megablocks.layers.mlp import (# SharedMLP,# SparseMLP,# create_dmoe_expert_weights,# resolve_dtensor,# )from .. import grouped_gemm_util as ggfrom . import common, mpufrom .activation_fn import act_fnfrom .arguments import Argumentsfrom .mlp import (SharedMLP,SparseMLP,create_dmoe_expert_weights,
5 unmodified lines67891011125 unmodified linesimport torchimport torch.distributed as distfrom megablocks.layers import arguments, dmoe_TESTS = ((8, 2048, 4096, 4096, 32, 4),)5 unmodified lines6789101112135 unmodified linesimport torchimport torch.distributed as dist# from megablocks.layers import arguments, dmoefrom . import arguments, dmoe_TESTS = ((8, 2048, 4096, 4096, 32, 4),)
8 unmodified lines9101112131415161718198 unmodified linesimport torchfrom packaging import versionfrom megablocks import grouped_gemm_util as ggfrom megablocks.layers import common, gelu, mpufrom megablocks.layers.activation_fn import act_fnfrom megablocks.layers.arguments import DEFAULT_ACTIVATION_FN, Arguments, InitFnclass ScaleGradient(torch.autograd.Function):8 unmodified lines910111213141516171819202122238 unmodified linesimport torchfrom packaging import version# from megablocks import grouped_gemm_util as gg# from megablocks.layers import common, gelu, mpu# from megablocks.layers.activation_fn import act_fn# from megablocks.layers.arguments import DEFAULT_ACTIVATION_FN, Arguments, InitFnfrom .. import grouped_gemm_util as ggfrom . import common, gelu, mpufrom .activation_fn import act_fnfrom .arguments import DEFAULT_ACTIVATION_FN, Arguments, InitFnclass ScaleGradient(torch.autograd.Function):
5 unmodified lines6789101112131415142 unmodified lines1581591601611621631643 unmodified lines16816917017117217317417517617717 unmodified lines1951961971981992002012 unmodified lines20420520620720820921053 unmodified lines26426526626726826927014 unmodified lines28528628728828929029125 unmodified lines31731831932032132232312 unmodified lines3363373383393403413428 unmodified lines3513523533543553563573583593603613623633643 unmodified lines36836937037137237337441 unmodified lines4164174184194204214224234244255 unmodified linesimport torchimport torch.distributed as distimport megablocks.ops as opsfrom megablocks.layers import common, mlp, mpu, router, sharedexpert_registryfrom megablocks.layers.all_to_all import all_to_allfrom megablocks.layers.arguments import Arguments_LOAD_BALANCING_LOSS = []142 unmodified lines# prior? Could we place the `torch.max` operation to return# 32-bit expert indices?top_expert = top_expert.int()output = ops.sort(top_expert, self.sort_end_bit)assert output is not Nonebin_ids, indices = output3 unmodified lines# TODO(tgale): Does the sorted data produce a more favorable# data distribution for histogram? Or is the op parallelism# worth more?tokens_per_expert = ops.histogram(top_expert, self.num_experts)# Calculate the bin bounds for the sorted tokens.bins = ops.inclusive_cumsum(tokens_per_expert, 0)assert bins is not Nonebins = bins.view(1) if not len(bins.size()) else bins17 unmodified lines):# Route the tokens for MoE computation.x = x.view(-1, x.shape[-1])output = ops.binned_gather(x, indices, bins, expert_capacity, top_k)assert output is not Nonex = output2 unmodified linesx = self.mlp(x)# Un-route the data for the MoE output.return ops.binned_scatter(x, indices, expert_weights, bins, top_k)def forward_once(self, x: torch.Tensor, expert_weights: torch.Tensor, top_experts: torch.Tensor):# x: [sl, bs, hs]53 unmodified lines# If we're sharding the experts along the hidden dimension# multiple devices own parts of the same sets of experts.# Replicate the token counts so every device gets the counts.repeated_tokens_per_expert = ops.repeat(tokens_per_expert,(mpu.hidden_sharding_degree(self.args),),)14 unmodified lines# This view updates the shape of the tensor from [sl, bs, hs] to# [sl * bs, hs] prior to the permutation.x = x.view(-1, x.shape[-1])output = ops.gather(x, indices, bin_ids, bins, self.top_k)assert output is not Nonex = output25 unmodified lines# get all of the tokens assigned to them.## TODO(tgale): Fuse this into the prior, local permutation.x = ops.repeat(x, (mpu.hidden_sharding_degree(self.args), 1))# Start the cross-device permutation asynchronously so we can# overlap communication with computation.12 unmodified lines# for expert computation we'll do one more local permutation. The# rest of this torch.no_grad() scope sets up the indices and bins# for this permutation.replicate_bins = ops.inclusive_cumsum(parallel_tokens_per_expert.flatten(),0,)8 unmodified lines),mpu.experts_per_rank(self.args),)parallel_top_expert = ops.replicate(parallel_top_expert.unsqueeze(dim=0),replicate_bins,tokens_received,).flatten()# TODO(tgale): The sort_end_bit here can be reduced.parallel_bin_ids, parallel_indices = ops.sort(parallel_top_expert,self.sort_end_bit,)3 unmodified linesdim=0,dtype=torch.int,)parallel_bins = ops.inclusive_cumsum(parallel_tokens_per_expert, 0)parallel_bins = (parallel_bins.view(1) if not len(parallel_bins.size()) else parallel_bins)# If expert_capacity is set to zero, set the number of tokens41 unmodified lines-1,self.args.hidden_size,)x = ops.sum(x.view(shape), dim=0)# Un-permute locally to setup for the next series of operations.x = ops.scatter(x, indices, bin_ids, expert_weights, bins, self.top_k)return x, tokens_per_expert.flatten()def forward(self, x: torch.Tensor, scores: torch.Tensor, expert_weights: torch.Tensor, top_experts: torch.Tensor):5 unmodified lines67891011121314151617181920212223242526272829303132142 unmodified lines1751761771781791801811823 unmodified lines18618718818919019119219319419519619717 unmodified lines2152162172182192202212222 unmodified lines22522622722822923023123223353 unmodified lines28728828929029129229329414 unmodified lines30931031131231331431531625 unmodified lines34234334434534634734834912 unmodified lines3623633643653663673683698 unmodified lines3783793803813823833843853863873883893903913923933 unmodified lines39739839940040140240340441 unmodified lines4464474484494504514524534544554564575 unmodified linesimport torchimport torch.distributed as dist# import megablocks.ops as ops# from megablocks.layers import common, mlp, mpu, router, sharedexpert_registry# from megablocks.layers.all_to_all import all_to_all# from megablocks.layers.arguments import Argumentsfrom ..ops import (sort,histogram,inclusive_cumsum,exclusive_cumsum,binned_gather,binned_scatter,gather,scatter,repeat,replicate,)from . import common, mlp, mpu, router, sharedexpert_registryfrom .arguments import Argumentsfrom .all_to_all import all_to_all_LOAD_BALANCING_LOSS = []142 unmodified lines# prior? Could we place the `torch.max` operation to return# 32-bit expert indices?top_expert = top_expert.int()# output = ops.sort(top_expert, self.sort_end_bit)output = sort(top_expert, self.sort_end_bit)assert output is not Nonebin_ids, indices = output3 unmodified lines# TODO(tgale): Does the sorted data produce a more favorable# data distribution for histogram? Or is the op parallelism# worth more?# tokens_per_expert = ops.histogram(top_expert, self.num_experts)tokens_per_expert = histogram(top_expert, self.num_experts)# Calculate the bin bounds for the sorted tokens.# bins = ops.inclusive_cumsum(tokens_per_expert, 0)bins = inclusive_cumsum(tokens_per_expert, 0)assert bins is not Nonebins = bins.view(1) if not len(bins.size()) else bins17 unmodified lines):# Route the tokens for MoE computation.x = x.view(-1, x.shape[-1])# output = ops.binned_gather(x, indices, bins, expert_capacity, top_k)output = binned_gather(x, indices, bins, expert_capacity, top_k)assert output is not Nonex = output2 unmodified linesx = self.mlp(x)# Un-route the data for the MoE output.# return ops.binned_scatter(x, indices, expert_weights, bins, top_k)return binned_scatter(x, indices, expert_weights, bins, top_k)def forward_once(self, x: torch.Tensor, expert_weights: torch.Tensor, top_experts: torch.Tensor):# x: [sl, bs, hs]53 unmodified lines# If we're sharding the experts along the hidden dimension# multiple devices own parts of the same sets of experts.# Replicate the token counts so every device gets the counts.# repeated_tokens_per_expert = ops.repeat(repeated_tokens_per_expert = repeat(tokens_per_expert,(mpu.hidden_sharding_degree(self.args),),)14 unmodified lines# This view updates the shape of the tensor from [sl, bs, hs] to# [sl * bs, hs] prior to the permutation.x = x.view(-1, x.shape[-1])# output = ops.gather(x, indices, bin_ids, bins, self.top_k)output = gather(x, indices, bin_ids, bins, self.top_k)assert output is not Nonex = output25 unmodified lines# get all of the tokens assigned to them.## TODO(tgale): Fuse this into the prior, local permutation.# x = ops.repeat(x, (mpu.hidden_sharding_degree(self.args), 1))x = repeat(x, (mpu.hidden_sharding_degree(self.args), 1))# Start the cross-device permutation asynchronously so we can# overlap communication with computation.12 unmodified lines# for expert computation we'll do one more local permutation. The# rest of this torch.no_grad() scope sets up the indices and bins# for this permutation.# replicate_bins = ops.inclusive_cumsum(replicate_bins = inclusive_cumsum(parallel_tokens_per_expert.flatten(),0,)8 unmodified lines),mpu.experts_per_rank(self.args),)# parallel_top_expert = ops.replicate(parallel_top_expert = replicate(parallel_top_expert.unsqueeze(dim=0),replicate_bins,tokens_received,).flatten()# TODO(tgale): The sort_end_bit here can be reduced.# parallel_bin_ids, parallel_indices = ops.sort(parallel_bin_ids, parallel_indices = sort(parallel_top_expert,self.sort_end_bit,)3 unmodified linesdim=0,dtype=torch.int,)# parallel_bins = ops.inclusive_cumsum(parallel_tokens_per_expert, 0)parallel_bins = inclusive_cumsum(parallel_tokens_per_expert, 0)parallel_bins = (parallel_bins.view(1) if not len(parallel_bins.size()) else parallel_bins)# If expert_capacity is set to zero, set the number of tokens41 unmodified lines-1,self.args.hidden_size,)# x = ops.sum(x.view(shape), dim=0)x = x.view(shape).sum(dim=0)# Un-permute locally to setup for the next series of operations.# x = ops.scatter(x, indices, bin_ids, expert_weights, bins, self.top_k)x = scatter(x, indices, bin_ids, expert_weights, bins, self.top_k)return x, tokens_per_expert.flatten()def forward(self, x: torch.Tensor, scores: torch.Tensor, expert_weights: torch.Tensor, top_experts: torch.Tensor):
5 unmodified lines67891011125 unmodified linesimport torchimport torch.distributed as distfrom megablocks.layers.arguments import Argumentsclass MoeParam(torch.Tensor):5 unmodified lines6789101112135 unmodified linesimport torchimport torch.distributed as dist# from megablocks.layers.arguments import Argumentsfrom .arguments import Argumentsclass MoeParam(torch.Tensor):
3 unmodified lines45678910113 unmodified linesimport torchfrom megablocks.layers import commonfrom megablocks.layers.arguments import Arguments_ROUTER_LOGITS = []3 unmodified lines456789101112133 unmodified linesimport torch# from megablocks.layers import common# from megablocks.layers.arguments import Argumentsfrom . import commonfrom .arguments import Arguments_ROUTER_LOGITS = []
2 unmodified lines3456789102 unmodified linesfrom typing import Unionfrom megablocks.layers import glu, mlpfrom megablocks.layers.arguments import Arguments_REGISTRY = {'mlp': mlp.SharedMLP,2 unmodified lines34567891011122 unmodified linesfrom typing import Union# from megablocks.layers import glu, mlp# from megablocks.layers.arguments import Argumentsfrom . import glu, mlpfrom .arguments import Arguments_REGISTRY = {'mlp': mlp.SharedMLP,
1234567891011121314151617181920# Copyright 2024 Databricks# SPDX-License-Identifier: Apache-2.0from megablocks.ops.binned_gather import binned_gatherfrom megablocks.ops.binned_scatter import binned_scatterfrom megablocks.ops.cumsum import exclusive_cumsum, inclusive_cumsumfrom megablocks.ops.gather import gatherfrom megablocks.ops.histogram import histogramfrom megablocks.ops.padded_gather import padded_gatherfrom megablocks.ops.padded_scatter import padded_scatterfrom megablocks.ops.repeat import repeatfrom megablocks.ops.replicate import replicatefrom megablocks.ops.round_up import round_upfrom megablocks.ops.scatter import scatterfrom megablocks.ops.sort import sortfrom megablocks.ops.sum import sumfrom megablocks.ops.topology import topology__all__ = ['binned_gather',1234567891011121314151617181920# Copyright 2024 Databricks# SPDX-License-Identifier: Apache-2.0from .binned_gather import binned_gatherfrom .binned_scatter import binned_scatterfrom .cumsum import exclusive_cumsum, inclusive_cumsumfrom .gather import gatherfrom .histogram import histogramfrom .padded_gather import padded_gatherfrom .padded_scatter import padded_scatterfrom .repeat import repeatfrom .replicate import replicatefrom .round_up import round_upfrom .scatter import scatterfrom .sort import sortfrom .sum import sumfrom .topology import topology__all__ = ['binned_gather',
3 unmodified lines45678910113 unmodified linesimport torchimport torch.distributed as distfrom megablocks import benchmark_utilfrom megablocks.layers.all_to_all import all_to_all_ALL_TO_ALL_BENCHMARK = ((8, 1024),3 unmodified lines45678910111213143 unmodified linesimport torchimport torch.distributed as dist# from megablocks import benchmark_util# from megablocks.layers.all_to_all import all_to_allfrom .. import benchmark_utilfrom ..layers.all_to_all import all_to_all_ALL_TO_ALL_BENCHMARK = ((8, 1024),
4 unmodified lines5678910114 unmodified linesimport torchfrom stk.backend.autocast import custom_bwd, custom_fwdfrom megablocks.backend import kernels# Autograd wrapper for binned_gather kernel.4 unmodified lines5678910114 unmodified linesimport torchfrom stk.backend.autocast import custom_bwd, custom_fwdfrom ..backend import kernels# Autograd wrapper for binned_gather kernel.
4 unmodified lines5678910114 unmodified linesimport torchfrom stk.backend.autocast import custom_bwd, custom_fwdfrom megablocks.backend import kernels# Autograd wrapper for binned_scatter kernel.4 unmodified lines5678910114 unmodified linesimport torchfrom stk.backend.autocast import custom_bwd, custom_fwdfrom ..backend import kernels# Autograd wrapper for binned_scatter kernel.
10 unmodified lines1112131415161710 unmodified lines# instructions for building the c++ operations.try:# import megablocks_ops as ops # type: ignorefrom megablocks._ops import ops # type: ignoreexcept ModuleNotFoundError as e:raise ModuleNotFoundError("No module named 'megablocks_ops'.") from e10 unmodified lines1112131415161710 unmodified lines# instructions for building the c++ operations.try:# import megablocks_ops as ops # type: ignorefrom .._ops import ops # type: ignoreexcept ModuleNotFoundError as e:raise ModuleNotFoundError("No module named 'megablocks_ops'.") from e
4 unmodified lines5678910114 unmodified linesimport torchfrom stk.backend.autocast import custom_bwd, custom_fwdfrom megablocks.backend import kernels# Autograd wrapper for gather kernel.4 unmodified lines5678910114 unmodified linesimport torchfrom stk.backend.autocast import custom_bwd, custom_fwdfrom ..backend import kernels# Autograd wrapper for gather kernel.
9 unmodified lines101112131415169 unmodified lines# Wrap this in a try-block with better error message and# instructions for building the c++ operations.try:from megablocks._ops import ops # type: ignoreexcept ModuleNotFoundError as e:raise ModuleNotFoundError("No module named 'megablocks_ops'.") from e9 unmodified lines101112131415169 unmodified lines# Wrap this in a try-block with better error message and# instructions for building the c++ operations.try:from .._ops import ops # type: ignoreexcept ModuleNotFoundError as e:raise ModuleNotFoundError("No module named 'megablocks_ops'.") from e
6 unmodified lines789101112136 unmodified linesimport torchfrom absl.testing import parameterizedfrom megablocks import ops_HISTOGRAM_TESTS = ((16384, torch.int32, 2),6 unmodified lines789101112136 unmodified linesimport torchfrom absl.testing import parameterizedfrom .. import ops_HISTOGRAM_TESTS = ((16384, torch.int32, 2),
6 unmodified lines789101112136 unmodified linesimport torchfrom absl.testing import parameterizedfrom megablocks import benchmark_util, ops# Calling tensor.t() calls tensor.transpose(0, 1) which calls6 unmodified lines789101112136 unmodified linesimport torchfrom absl.testing import parameterizedfrom .. import benchmark_util, ops# Calling tensor.t() calls tensor.transpose(0, 1) which calls
4 unmodified lines5678910114 unmodified linesimport torchfrom stk.backend.autocast import custom_bwd, custom_fwdfrom megablocks.backend import kernels# Autograd wrapper for padded_gather kernel.4 unmodified lines5678910114 unmodified linesimport torchfrom stk.backend.autocast import custom_bwd, custom_fwdfrom ..backend import kernels# Autograd wrapper for padded_gather kernel.
4 unmodified lines5678910114 unmodified linesimport torchfrom stk.backend.autocast import custom_bwd, custom_fwdfrom megablocks.backend import kernels# Autograd wrapper for padded_scatter kernel.4 unmodified lines5678910114 unmodified linesimport torchfrom stk.backend.autocast import custom_bwd, custom_fwdfrom ..backend import kernels# Autograd wrapper for padded_scatter kernel.
5 unmodified lines67891011125 unmodified linesimport torchfrom absl.testing import parameterizedfrom megablocks import benchmark_util, ops_PADDED_SCATTER_BENCHMARK = (# dMoE-Medium, 8-way EMP.5 unmodified lines67891011125 unmodified linesimport torchfrom absl.testing import parameterizedfrom .. import benchmark_util, ops_PADDED_SCATTER_BENCHMARK = (# dMoE-Medium, 8-way EMP.
5 unmodified lines67891011125 unmodified linesimport torchfrom absl.testing import parameterizedfrom megablocks import benchmark_util, ops_PERMUTE_TESTS = ((16384, 768, 2),5 unmodified lines67891011125 unmodified linesimport torchfrom absl.testing import parameterizedfrom .. import benchmark_util, ops_PERMUTE_TESTS = ((16384, 768, 2),
9 unmodified lines101112131415169 unmodified lines# Wrap this in a try-block with better error message and# instructions for building the c++ operations.try:from megablocks._ops import ops # type: ignoreexcept ModuleNotFoundError as e:raise ModuleNotFoundError("No module named 'megablocks_ops'.") from e9 unmodified lines101112131415169 unmodified lines# Wrap this in a try-block with better error message and# instructions for building the c++ operations.try:from .._ops import ops # type: ignoreexcept ModuleNotFoundError as e:raise ModuleNotFoundError("No module named 'megablocks_ops'.") from e
5 unmodified lines67891011125 unmodified linesimport torchfrom stk.backend.autocast import custom_bwd, custom_fwdfrom megablocks.backend import kernels# Autograd wrapper for scatter kernel.5 unmodified lines67891011125 unmodified linesimport torchfrom stk.backend.autocast import custom_bwd, custom_fwdfrom ..backend import kernels# Autograd wrapper for scatter kernel.
9 unmodified lines101112131415169 unmodified lines# Wrap this in a try-block with better error message and# instructions for building the c++ operations.try:from megablocks._ops import ops # type: ignoreexcept ModuleNotFoundError as e:raise ModuleNotFoundError("No module named 'megablocks_ops'.") from e9 unmodified lines101112131415169 unmodified lines# Wrap this in a try-block with better error message and# instructions for building the c++ operations.try:from .._ops import ops # type: ignoreexcept ModuleNotFoundError as e:raise ModuleNotFoundError("No module named 'megablocks_ops'.") from e
6 unmodified lines789101112136 unmodified linesimport torchfrom absl.testing import parameterizedfrom megablocks import ops_SORT_TESTS = ((16384, torch.int32, None),6 unmodified lines789101112136 unmodified linesimport torchfrom absl.testing import parameterizedfrom .. import ops_SORT_TESTS = ((16384, torch.int32, None),
9 unmodified lines101112131415169 unmodified lines# Wrap this in a try-block with better error message and# instructions for building the c++ operations.try:from megablocks._ops import ops # type: ignoreexcept ModuleNotFoundError as e:raise ModuleNotFoundError("No module named 'megablocks_ops'.") from e9 unmodified lines101112131415169 unmodified lines# Wrap this in a try-block with better error message and# instructions for building the c++ operations.try:from .._ops import ops # type: ignoreexcept ModuleNotFoundError as e:raise ModuleNotFoundError("No module named 'megablocks_ops'.") from e
build.toml-1
torch-ext/megablocks/grouped_gemm/backend.py+2-1
torch-ext/megablocks/layers/arguments.py+2-1
torch-ext/megablocks/layers/common.py+1-1
torch-ext/megablocks/layers/dmlp_registry.py+2-2
torch-ext/megablocks/layers/dmoe.py+8-5
torch-ext/megablocks/layers/glu.py+16-5
torch-ext/megablocks/layers/memory_test.py+2-1
torch-ext/megablocks/layers/mlp.py+9-5
torch-ext/megablocks/layers/moe.py+50-18
torch-ext/megablocks/layers/mpu.py+2-1
torch-ext/megablocks/layers/router.py+4-2
torch-ext/megablocks/layers/sharedexpert_registry.py+4-2
torch-ext/megablocks/ops/__init__.py+14-14
torch-ext/megablocks/ops/all_to_all_benchmark.py+5-2
torch-ext/megablocks/ops/binned_gather.py+1-1
torch-ext/megablocks/ops/binned_scatter.py+1-1
torch-ext/megablocks/ops/cumsum.py+1-1
torch-ext/megablocks/ops/gather.py+1-1
torch-ext/megablocks/ops/histogram.py+1-1
torch-ext/megablocks/ops/histogram_benchmark.py+1-1
torch-ext/megablocks/ops/matmul_benchmark.py+1-1
torch-ext/megablocks/ops/padded_gather.py+1-1
torch-ext/megablocks/ops/padded_scatter.py+1-1
torch-ext/megablocks/ops/padded_scatter_benchmark.py+1-1
torch-ext/megablocks/ops/permute_benchmark.py+1-1
torch-ext/megablocks/ops/replicate.py+1-1
torch-ext/megablocks/ops/scatter.py+1-1
torch-ext/megablocks/ops/sort.py+1-1
torch-ext/megablocks/ops/sort_benchmark.py+1-1
torch-ext/megablocks/ops/topology.py+1-1