[RL] Fix weight update for mxfp8 flashinfer_cutlass gemm backend (#22484)

This commit is contained in:
Ziang Li
2026-04-12 13:02:17 +00:00
committed by GitHub
parent bcc0c65aa8
commit 31453bb76a
+9 -3
View File
@@ -531,9 +531,11 @@ class Fp8LinearMethod(LinearMethodBase):
from flashinfer import block_scale_interleave from flashinfer import block_scale_interleave
scale_u8 = layer.weight_scale_inv.data scale_u8 = layer.weight_scale_inv.data
# block_scale_interleave may pad and/or reshape scales,
# so store swizzled scales separately to keep weight update working
copy_or_rebind_param( copy_or_rebind_param(
layer, layer,
"weight_scale_inv", "weight_scale_inv_swizzled",
block_scale_interleave(scale_u8.contiguous()).contiguous(), block_scale_interleave(scale_u8.contiguous()).contiguous(),
) )
else: else:
@@ -688,18 +690,22 @@ class Fp8LinearMethod(LinearMethodBase):
) )
if self.use_mxfp8: if self.use_mxfp8:
if get_fp8_gemm_runner_backend().is_flashinfer_cutlass():
weight_scale = layer.weight_scale_inv_swizzled
else:
weight_scale = layer.weight_scale_inv
if isinstance(x, tuple): if isinstance(x, tuple):
return self.w8a8_mxfp8_linear( return self.w8a8_mxfp8_linear(
input=x[0], input=x[0],
weight=layer.weight, weight=layer.weight,
weight_scale=layer.weight_scale_inv, weight_scale=weight_scale,
input_scale=x[1], input_scale=x[1],
bias=bias, bias=bias,
) )
return self.w8a8_mxfp8_linear( return self.w8a8_mxfp8_linear(
input=x, input=x,
weight=layer.weight, weight=layer.weight,
weight_scale=layer.weight_scale_inv, weight_scale=weight_scale,
input_scale=None, input_scale=None,
bias=bias, bias=bias,
) )