Rewrite C++ meta funcs to Python (#28595)
Signed-off-by: Jane Xu <janeyx@meta.com>
This commit is contained in:
+38
-1
@@ -1174,13 +1174,50 @@ def gptq_marlin_repack(
|
||||
return torch.ops._C.gptq_marlin_repack(b_q_weight, perm, size_k, size_n, num_bits)
|
||||
|
||||
|
||||
# gptq_marlin
|
||||
if hasattr(torch.ops._C, "gptq_marlin_repack"):
|
||||
|
||||
@register_fake("_C::gptq_marlin_repack")
|
||||
def _gptq_marlin_repack_fake(
|
||||
b_q_weight: torch.Tensor,
|
||||
perm: torch.Tensor,
|
||||
size_k: torch.SymInt,
|
||||
size_n: torch.SymInt,
|
||||
num_bits: int,
|
||||
) -> torch.Tensor:
|
||||
pack_factor = 32 // num_bits
|
||||
marlin_tile_size = 16
|
||||
return torch.empty(
|
||||
(size_k // marlin_tile_size, size_n * marlin_tile_size // pack_factor),
|
||||
dtype=b_q_weight.dtype,
|
||||
device=b_q_weight.device,
|
||||
)
|
||||
|
||||
|
||||
# awq_marlin
|
||||
def awq_marlin_repack(
|
||||
b_q_weight: torch.Tensor, size_k: int, size_n: int, num_bits: int
|
||||
) -> torch.Tensor:
|
||||
return torch.ops._C.awq_marlin_repack(b_q_weight, size_k, size_n, num_bits)
|
||||
|
||||
|
||||
if hasattr(torch.ops._C, "awq_marlin_repack"):
|
||||
|
||||
@register_fake("_C::awq_marlin_repack")
|
||||
def _awq_marlin_repack_fake(
|
||||
b_q_weight: torch.Tensor,
|
||||
size_k: torch.SymInt,
|
||||
size_n: torch.SymInt,
|
||||
num_bits: int,
|
||||
) -> torch.Tensor:
|
||||
pack_factor = 32 // num_bits
|
||||
marlin_tile_size = 16
|
||||
return torch.empty(
|
||||
(size_k // marlin_tile_size, size_n * marlin_tile_size // pack_factor),
|
||||
dtype=b_q_weight.dtype,
|
||||
device=b_q_weight.device,
|
||||
)
|
||||
|
||||
|
||||
def gptq_marlin_moe_repack(
|
||||
b_q_weight: torch.Tensor,
|
||||
perm: torch.Tensor,
|
||||
|
||||
Reference in New Issue
Block a user