Commits/
merge fix/gmm-a5-unified-20261127 into master
5 file(s) changed+167-9
Mgmm/common/tests/ttk/fused_spec.py+16-5
@@ -599,14 +599,21 @@ def _with_transposed_storage(tensor, dim0, dim1):
599 """Give a dense CSV tensor transposed strides without changing logical values."""599 """Give a dense CSV tensor transposed strides without changing logical values."""
600 import torch600 import torch
601 601 
602- if tensor.stride(dim0) < tensor.stride(dim1):602+ first, second = sorted((dim0 % tensor.ndim, dim1 % tensor.ndim))
603+ if tensor.stride(first) < tensor.stride(second):
603 return tensor604 return tensor
604 source = tensor.transpose(dim0, dim1).clone(memory_format=torch.contiguous_format)605 source = tensor.transpose(dim0, dim1).clone(memory_format=torch.contiguous_format)
605 return source.transpose(dim0, dim1)606 return source.transpose(dim0, dim1)
606 607 
607 608 
608def _hook_preprocess(*args, **meta):609def _hook_preprocess(*args, **meta):
609- trans = meta["f_trans"] and not meta.get("f_graph_source")610+ routing_graph = (
611+ meta["f_family"] == "routing" and meta.get("f_graph_source")
612+ and meta["f_trans"] and meta["f_format"] == "FRACTAL_NZ_C0_32"
613+ and meta["f_types"][0] == "float8_e4m3fn"
614+ and meta["f_types"][1] == "float4_e2m1"
615+ )
616+ trans = meta["f_trans"] and (routing_graph or not meta.get("f_graph_source"))
610 nd = meta["f_format"] == "ND"617 nd = meta["f_format"] == "ND"
611 swiglu_trans = trans and meta["f_family"] == "swiglu"618 swiglu_trans = trans and meta["f_family"] == "swiglu"
612 if nd and not swiglu_trans:619 if nd and not swiglu_trans:
@@ -619,6 +626,10 @@ def _hook_preprocess(*args, **meta):
619 scales = args[meta["f_ports"]["ws"]]626 scales = args[meta["f_ports"]["ws"]]
620 for i, scale in enumerate(scales):627 for i, scale in enumerate(scales):
621 scales[i] = _with_transposed_storage(scale, -3, -2)628 scales[i] = _with_transposed_storage(scale, -3, -2)
629+ if routing_graph:
630+ # Graph CSVs carry the packed source layout; eager needs API views.
631+ scale = args[meta["f_ports"]["ws"]]
632+ scale.data = scale.transpose(-3, -2)
622 port = meta["f_ports"]["w"]633 port = meta["f_ports"]["w"]
623 value = args[port]634 value = args[port]
624 listed = isinstance(value, (list, tuple))635 listed = isinstance(value, (list, tuple))
@@ -629,7 +640,7 @@ def _hook_preprocess(*args, **meta):
629 if nd:640 if nd:
630 results.append(_with_transposed_storage(tensor, -1, -2))641 results.append(_with_transposed_storage(tensor, -1, -2))
631 continue642 continue
632- source = tensor.transpose(-1, -2).contiguous() if trans else tensor643+ source = tensor.transpose(-1, -2).contiguous() if trans and not routing_graph else tensor
633 if wd.startswith("float4") and meta["f_format"] == "FRACTAL_NZ_C0_32":644 if wd.startswith("float4") and meta["f_format"] == "FRACTAL_NZ_C0_32":
634 hint = 296 if wd == "float4_e2m1" else 297645 hint = 296 if wd == "float4_e2m1" else 297
635 converted = torch_npu.npu_format_cast(646 converted = torch_npu.npu_format_cast(
@@ -695,8 +706,8 @@ def _hook_golden(*args, _routing_trace=None, **meta):
695 meta["f_trans"],706 meta["f_trans"],
696 c0,707 c0,
697 "int4" if wd == "int4" else "",708 "int4" if wd == "int4" else "",
698- meta["f_shape"][1],709+ meta["f_shape"][-2],
699- meta["f_shape"][2],710+ meta["f_shape"][-1],
700 )711 )
701 w = np.stack(decoded) if len(decoded) > 1 else decoded[0]712 w = np.stack(decoded) if len(decoded) > 1 else decoded[0]
702 else:713 else:
Mgmm/grouped_matmul_finalize_routing/op_kernel/arch35/grouped_matmul_finalize_routing_a8w4_blaze.h+60-1
Mgmm/grouped_matmul_finalize_routing/tests/assets/gmmfr_e2e_golden.py+25-1
Agmm/grouped_matmul_swiglu_quant_v2/tests/ut/ttk/test_weight_storage.py+26-0
Mgmm/quant_grouped_matmul_inplace_add/tests/assets/gmmia_e2e_golden.py+40-2

Comments