[Bugfix] Canonicalize FP8 weight layout to (K, N) at the source (#44735)

Signed-off-by: mgoin <mgoin64@gmail.com>
This commit is contained in:
Michael Goin
2026-06-08 14:37:36 -06:00
committed by GitHub
parent 823a0ab754
commit 6afa25000c
3 changed files with 11 additions and 29 deletions
@@ -75,25 +75,7 @@ class MarlinFP8ScaledMMLinearKernel(FP8ScaledMMLinearKernel):
# Update layer with new values
replace_parameter(layer, "weight", weight.data)
replace_parameter(layer, "weight_scale_inv", weight_scale_inv.data)
else:
w_q, *_ = self._get_layer_params(layer)
# Compressed tensors transposes the weight to (K, N)
# for channel and tensor quant strategies.
# So we can skip the transpose if the layout is
# already (K, N).
# TODO: Remove this check once the layouts have been
# canonicalized to a standard (N, K) dimension. See issue
# #33314 for more details.
if w_q.shape != (
layer.input_size_per_partition,
layer.output_size_per_partition,
):
# transpose the weights to (K,N)
replace_parameter(
layer,
"weight",
w_q.t(),
)
# Non-block: callers must pass weight in (K, N) layout.
layer.input_scale = None
prepare_fp8_layer_for_marlin(