[BugFix] Add support for weight shape constraints and group size selection in Machete (#4911)

This commit is contained in:
Sunny-bot1
2025-11-10 20:57:35 +08:00
committed by GitHub
parent 2dfbcf3cc9
commit 59d2edde29
3 changed files with 139 additions and 59 deletions

View File

@@ -35,6 +35,24 @@ if current_platform.is_cuda() and get_sm_version() == 90:
except Exception:
pass
MACHETE_PREPACKED_BLOCK_SHAPE = [64, 128]
def check_machete_supports_shape(in_features, out_featrues):
if in_features and in_features % MACHETE_PREPACKED_BLOCK_SHAPE[0] != 0:
return False
if out_featrues and out_featrues % MACHETE_PREPACKED_BLOCK_SHAPE[1] != 0:
return False
return True
def query_machete_supported_group_size(in_features):
if in_features % 128 == 0:
return 128
elif in_features % 64 == 0:
return 64
return -1
def get_pack_factor(num_bits):
assert 32 % num_bits == 0, f"Unsupported num_bits = {num_bits}"