Instructions to use kernels-community/megablocks with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use kernels-community/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("kernels-community/megablocks", version=1) - Notebooks
- Google Colab
- Kaggle
Build uploaded using `kernels`.
Browse filesThis view is limited to 50 files because it contains too many changes. Β See raw diff
- build/torch210-cxx11-cu126-x86_64-linux/__init__.py +202 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/__init__.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/activation_fn.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/all_to_all.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/arguments.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/common.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/dmlp_registry.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/dmoe.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/gelu.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/glu.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/memory_test.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/mlp.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/moe.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/mpu.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/router.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/sharedexpert_registry.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks/_megablocks_885c7a2.abi3.so β torch210-cxx11-cu126-x86_64-linux/_megablocks_7314066.abi3.so} +2 -2
- build/{torch28-cxx11-cu129-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_ops.py +3 -3
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_version.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/backend/__init__.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/backend/kernels.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/benchmark_util.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/grouped_gemm/__init__.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/grouped_gemm/backend.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/grouped_gemm/ops.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/grouped_gemm_util.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/layers.py +0 -0
- build/torch210-cxx11-cu126-x86_64-linux/megablocks/__init__.py +26 -0
- build/torch210-cxx11-cu126-x86_64-linux/metadata.json +1 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/__init__.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/all_to_all_benchmark.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/binned_gather.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/binned_scatter.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/cumsum.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/gather.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/histogram.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/histogram_benchmark.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/matmul_benchmark.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/padded_gather.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/padded_scatter.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/padded_scatter_benchmark.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/permute_benchmark.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/repeat.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/replicate.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/round_up.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/scatter.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/sort.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/sort_benchmark.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/stk_autocast.py +0 -0
- build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/sum.py +0 -0
build/torch210-cxx11-cu126-x86_64-linux/__init__.py
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2024 Databricks
|
| 2 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
|
| 4 |
+
import torch
|
| 5 |
+
|
| 6 |
+
from ._ops import ops
|
| 7 |
+
|
| 8 |
+
from .grouped_gemm import backend as gg_backend
|
| 9 |
+
from .grouped_gemm import ops as gg_ops
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
from ._layers.arguments import Arguments
|
| 13 |
+
from ._layers.dmoe import ParallelDroplessMLP, dMoE
|
| 14 |
+
from ._layers.glu import SparseGLU
|
| 15 |
+
from ._layers.mlp import MLP, SparseMLP
|
| 16 |
+
from ._layers.moe import MoE, ParallelMLP, get_load_balancing_loss
|
| 17 |
+
|
| 18 |
+
from . import layers
|
| 19 |
+
|
| 20 |
+
# This section contains the direct kernel exports (not inlcuded in the original code)
|
| 21 |
+
def exclusive_cumsum(x: torch.Tensor, dim: int, out: torch.Tensor) -> torch.Tensor:
|
| 22 |
+
"""
|
| 23 |
+
Compute exclusive cumulative sum along the specified dimension.
|
| 24 |
+
|
| 25 |
+
Args:
|
| 26 |
+
x: Input tensor
|
| 27 |
+
dim: Dimension along which to compute cumsum
|
| 28 |
+
out: Output tensor (modified in-place)
|
| 29 |
+
|
| 30 |
+
Returns:
|
| 31 |
+
The output tensor
|
| 32 |
+
"""
|
| 33 |
+
result = ops.exclusive_cumsum(x, dim)
|
| 34 |
+
out.copy_(result)
|
| 35 |
+
return out
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def inclusive_cumsum(x: torch.Tensor, dim: int, out: torch.Tensor) -> torch.Tensor:
|
| 39 |
+
"""
|
| 40 |
+
Compute inclusive cumulative sum along the specified dimension.
|
| 41 |
+
|
| 42 |
+
Args:
|
| 43 |
+
x: Input tensor
|
| 44 |
+
dim: Dimension along which to compute cumsum
|
| 45 |
+
out: Output tensor (modified in-place)
|
| 46 |
+
|
| 47 |
+
Returns:
|
| 48 |
+
The output tensor
|
| 49 |
+
"""
|
| 50 |
+
result = ops.inclusive_cumsum(x, dim)
|
| 51 |
+
out.copy_(result)
|
| 52 |
+
return out
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def histogram(x: torch.Tensor, num_bins: int) -> torch.Tensor:
|
| 56 |
+
"""
|
| 57 |
+
Compute histogram of input tensor values.
|
| 58 |
+
|
| 59 |
+
Args:
|
| 60 |
+
x: Input tensor
|
| 61 |
+
num_bins: Number of histogram bins
|
| 62 |
+
|
| 63 |
+
Returns:
|
| 64 |
+
Histogram tensor with counts for each bin
|
| 65 |
+
"""
|
| 66 |
+
return ops.histogram(x, num_bins)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def indices(
|
| 70 |
+
padded_bins: torch.Tensor,
|
| 71 |
+
block_size: int,
|
| 72 |
+
output_block_rows: int,
|
| 73 |
+
output_block_columns: int,
|
| 74 |
+
) -> torch.Tensor:
|
| 75 |
+
"""
|
| 76 |
+
Construct indices from padded bins for sparse operations.
|
| 77 |
+
|
| 78 |
+
Args:
|
| 79 |
+
padded_bins: Tensor containing bin boundaries
|
| 80 |
+
block_size: Size of each block
|
| 81 |
+
output_block_rows: Number of rows in output blocks
|
| 82 |
+
output_block_columns: Number of columns in output blocks
|
| 83 |
+
|
| 84 |
+
Returns:
|
| 85 |
+
Tensor containing constructed indices
|
| 86 |
+
"""
|
| 87 |
+
return ops.indices(padded_bins, block_size, output_block_rows, output_block_columns)
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def replicate_forward(
|
| 91 |
+
x: torch.Tensor, bins: torch.Tensor, out: torch.Tensor
|
| 92 |
+
) -> torch.Tensor:
|
| 93 |
+
"""
|
| 94 |
+
Forward pass of replicate operation - replicate values according to bin sizes.
|
| 95 |
+
|
| 96 |
+
Args:
|
| 97 |
+
x: Input tensor with values to replicate
|
| 98 |
+
bins: Tensor containing bin sizes
|
| 99 |
+
out: Output tensor (modified in-place)
|
| 100 |
+
|
| 101 |
+
Returns:
|
| 102 |
+
The output tensor
|
| 103 |
+
"""
|
| 104 |
+
return ops.replicate_forward(x, bins, out)
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def replicate_backward(
|
| 108 |
+
grad: torch.Tensor, bins: torch.Tensor, out: torch.Tensor
|
| 109 |
+
) -> torch.Tensor:
|
| 110 |
+
"""
|
| 111 |
+
Backward pass of replicate operation - reduce gradients back to bins.
|
| 112 |
+
|
| 113 |
+
Args:
|
| 114 |
+
grad: Gradient tensor to reduce
|
| 115 |
+
bins: Tensor containing bin sizes
|
| 116 |
+
out: Output tensor (modified in-place)
|
| 117 |
+
|
| 118 |
+
Returns:
|
| 119 |
+
The output tensor
|
| 120 |
+
"""
|
| 121 |
+
return ops.replicate_backward(grad, bins, out)
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def sort(
|
| 125 |
+
x: torch.Tensor, end_bit: int, x_out: torch.Tensor, iota_out: torch.Tensor
|
| 126 |
+
) -> torch.Tensor:
|
| 127 |
+
"""
|
| 128 |
+
Radix sort with index tracking.
|
| 129 |
+
|
| 130 |
+
Args:
|
| 131 |
+
x: Input tensor to sort
|
| 132 |
+
end_bit: Number of bits to consider in sorting
|
| 133 |
+
x_out: Output tensor for sorted values
|
| 134 |
+
iota_out: Output tensor for sorted indices
|
| 135 |
+
|
| 136 |
+
Returns:
|
| 137 |
+
The sorted values tensor
|
| 138 |
+
"""
|
| 139 |
+
return ops.sort(x, end_bit, x_out, iota_out)
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
# Convenience functions for common use cases
|
| 143 |
+
def cumsum(x: torch.Tensor, dim: int = -1, exclusive: bool = False) -> torch.Tensor:
|
| 144 |
+
"""
|
| 145 |
+
Compute cumulative sum with automatic output allocation.
|
| 146 |
+
|
| 147 |
+
Args:
|
| 148 |
+
x: Input tensor
|
| 149 |
+
dim: Dimension along which to compute cumsum (default: last dimension)
|
| 150 |
+
exclusive: Whether to compute exclusive (True) or inclusive (False) cumsum
|
| 151 |
+
|
| 152 |
+
Returns:
|
| 153 |
+
New tensor containing the cumulative sum
|
| 154 |
+
"""
|
| 155 |
+
out = torch.empty_like(x)
|
| 156 |
+
if exclusive:
|
| 157 |
+
return exclusive_cumsum(x, dim, out)
|
| 158 |
+
else:
|
| 159 |
+
return inclusive_cumsum(x, dim, out)
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
def argsort(x: torch.Tensor, end_bit: int = 32) -> tuple[torch.Tensor, torch.Tensor]:
|
| 163 |
+
"""
|
| 164 |
+
Sort tensor and return both sorted values and indices.
|
| 165 |
+
|
| 166 |
+
Args:
|
| 167 |
+
x: Input tensor to sort
|
| 168 |
+
end_bit: Number of bits to consider in sorting
|
| 169 |
+
|
| 170 |
+
Returns:
|
| 171 |
+
Tuple of (sorted_values, sorted_indices)
|
| 172 |
+
"""
|
| 173 |
+
x_out = torch.empty_like(x)
|
| 174 |
+
iota_out = torch.empty_like(x)
|
| 175 |
+
sort(x, end_bit, x_out, iota_out)
|
| 176 |
+
return x_out, iota_out
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
# Export public API
|
| 180 |
+
__all__ = [
|
| 181 |
+
"MyReplacementLayer",
|
| 182 |
+
# Direct kernel exports
|
| 183 |
+
"exclusive_cumsum",
|
| 184 |
+
"inclusive_cumsum",
|
| 185 |
+
"histogram",
|
| 186 |
+
"indices",
|
| 187 |
+
"replicate_forward",
|
| 188 |
+
"replicate_backward",
|
| 189 |
+
"sort",
|
| 190 |
+
"cumsum",
|
| 191 |
+
"argsort",
|
| 192 |
+
# Original exports
|
| 193 |
+
"Arguments",
|
| 194 |
+
"ParallelDroplessMLP",
|
| 195 |
+
"dMoE",
|
| 196 |
+
"SparseGLU",
|
| 197 |
+
"MLP",
|
| 198 |
+
"SparseMLP",
|
| 199 |
+
"MoE",
|
| 200 |
+
"ParallelMLP",
|
| 201 |
+
"get_load_balancing_loss",
|
| 202 |
+
]
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/__init__.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/activation_fn.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/all_to_all.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/arguments.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/common.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/dmlp_registry.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/dmoe.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/gelu.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/glu.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/memory_test.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/mlp.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/moe.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/mpu.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/router.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_layers/sharedexpert_registry.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks/_megablocks_885c7a2.abi3.so β torch210-cxx11-cu126-x86_64-linux/_megablocks_7314066.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c128009d68feec69e96ff2dbcc7a624fbb592aeaa28ea7b30cd37c86fc56cf66
|
| 3 |
+
size 15061032
|
build/{torch28-cxx11-cu129-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_ops.py
RENAMED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _megablocks_7314066
|
| 3 |
+
ops = torch.ops._megablocks_7314066
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_megablocks_7314066::{op_name}"
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/_version.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/backend/__init__.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/backend/kernels.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/benchmark_util.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/grouped_gemm/__init__.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/grouped_gemm/backend.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/grouped_gemm/ops.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/grouped_gemm_util.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/layers.py
RENAMED
|
File without changes
|
build/torch210-cxx11-cu126-x86_64-linux/megablocks/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ctypes
|
| 2 |
+
import sys
|
| 3 |
+
|
| 4 |
+
import importlib
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
from types import ModuleType
|
| 7 |
+
|
| 8 |
+
def _import_from_path(file_path: Path) -> ModuleType:
|
| 9 |
+
# We cannot use the module name as-is, after adding it to `sys.modules`,
|
| 10 |
+
# it would also be used for other imports. So, we make a module name that
|
| 11 |
+
# depends on the path for it to be unique using the hex-encoded hash of
|
| 12 |
+
# the path.
|
| 13 |
+
path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
|
| 14 |
+
module_name = path_hash
|
| 15 |
+
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
| 16 |
+
if spec is None:
|
| 17 |
+
raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
|
| 18 |
+
module = importlib.util.module_from_spec(spec)
|
| 19 |
+
if module is None:
|
| 20 |
+
raise ImportError(f"Cannot load module {module_name} from spec")
|
| 21 |
+
sys.modules[module_name] = module
|
| 22 |
+
spec.loader.exec_module(module) # type: ignore
|
| 23 |
+
return module
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
|
build/torch210-cxx11-cu126-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"python-depends":[]}
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/__init__.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/all_to_all_benchmark.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/binned_gather.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/binned_scatter.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/cumsum.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/gather.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/histogram.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/histogram_benchmark.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/matmul_benchmark.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/padded_gather.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/padded_scatter.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/padded_scatter_benchmark.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/permute_benchmark.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/repeat.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/replicate.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/round_up.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/scatter.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/sort.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/sort_benchmark.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/stk_autocast.py
RENAMED
|
File without changes
|
build/{torch28-cxx11-cu126-x86_64-linux/megablocks β torch210-cxx11-cu126-x86_64-linux}/ops/sum.py
RENAMED
|
File without changes
|