@@ -272,6 +272,7 @@ def newton_schulz_tp(
272272 tp_group : torch .distributed .ProcessGroup ,
273273 partition_dim : int | None = None ,
274274 tp_mode : Literal ["duplicated" , "distributed" ] = "duplicated" ,
275+ use_syrk : bool = False ,
275276) -> torch .Tensor :
276277 """Tensor Parallel Newton-Schulz iteration.
277278
@@ -299,14 +300,20 @@ def newton_schulz_tp(
299300 partition_dim: The dimension to partition the tensor.
300301 tp_group: The process group for communication if input is distributed.
301302 tp_mode: The mode to use for the Newton-Schulz iteration.
303+ use_syrk: Whether to use the Triton SYRK kernel for the Newton-Schulz iteration. Forwarded to the
304+ underlying ``newton_schulz`` in every path (non-TP fallback, ``duplicated``, ``distributed``); it only
305+ takes effect when the fp32 matmul precision is ``"medium"`` (see ``newton_schulz``).
306+ Requires both matrix dimensions to be multiples of 8 (16-byte stride alignment for bf16/fp32);
307+ weights with unaligned shapes will raise an ``AssertionError`` inside ``tsyrk_ex``.
302308 """
303309 if partition_dim is None :
304310 # Fallback path for non TP params.
305- return newton_schulz (x , steps , coefficient_type )
311+ return newton_schulz (x , steps , coefficient_type , use_syrk = use_syrk )
306312
307313 kwargs : Any = {
308314 "steps" : steps ,
309315 "coefficient_type" : coefficient_type ,
316+ "use_syrk" : use_syrk ,
310317 }
311318
312319 if tp_mode == "duplicated" :
0 commit comments