From c1719496b20e3ab3692936b8972a73ad2b01714c Mon Sep 17 00:00:00 2001 From: lxcxjxhx Date: Wed, 18 Nov 2026 02:36:38 +0800 Subject: [PATCH 1/2] [Docs] Name the parameters these docstrings actually take Signed-off-by: lxcxjxhx --- tests/jax/utils.py | 1 - .../jax/cpp_extensions/attention.py | 18 ++++++------------ transformer_engine/jax/flax/module.py | 2 +- transformer_engine/jax/quantize/dequantizer.py | 10 ++++------ .../ops/fused/userbuffers_backward_linear.py | 2 -- transformer_engine/pytorch/triton/mhc.py | 1 - 6 files changed, 11 insertions(+), 23 deletions(-) diff --git a/tests/jax/utils.py b/tests/jax/utils.py index f0a6928f1b2..04e56fa1cd5 100644 --- a/tests/jax/utils.py +++ b/tests/jax/utils.py @@ -233,7 +233,6 @@ def __call__( bias: bias for the attention weights. This should be broadcastable to the shape `[batch, num_heads, q_length, kv_length]` This can be used for incorporating causal masks, padding masks, proximity bias, etc. - dropout_rng: JAX PRNGKey: to be used for dropout deterministic: bool, deterministic or not (to apply dropout) Returns: Output of shape `[batch, length, num_heads, v_depth_per_head]`. diff --git a/transformer_engine/jax/cpp_extensions/attention.py b/transformer_engine/jax/cpp_extensions/attention.py index 3a1de7bd677..18a8bdb557c 100644 --- a/transformer_engine/jax/cpp_extensions/attention.py +++ b/transformer_engine/jax/cpp_extensions/attention.py @@ -3751,12 +3751,9 @@ def fused_attn_fwd( - `(query, key, value)`: For separate query, key, and value tensors. bias (Optional[jnp.ndarray]): An optional bias tensor to be added to the attention scores. softmax_offset (Optional[jnp.ndarray]): An optional softmax offset tensor. - q_seqlen (jnp.ndarray): Sequence lengths for the query, with shape [batch,]. - kv_seqlen (jnp.ndarray): Sequence lengths for the key and value, with shape [batch,]. - q_seq_offsets (jnp.ndarray): - The offsets in the sequence dim for the query, with shape [batch + 1,]. - kv_seq_offsets (jnp.ndarray): - The offsets in the sequence dim for the query, with shape [batch + 1,]. + sequence_descriptor (SequenceDescriptor): Sequence lengths and offsets for the query, + key and value, and optionally segment ids and positions. Replaces the separate + q_seqlen / kv_seqlen / q_seq_offsets / kv_seq_offsets arguments. seed (Optional[jnp.ndarray]): Optional random seed for dropout. attn_bias_type (AttnBiasType): Type of attention bias. attn_mask_type (AttnMaskType): Type of attention mask. @@ -3920,12 +3917,9 @@ def fused_attn_bwd( rng_state (jnp.ndarray): Auxiliary tensors to save the random state in the forward pass. output (jnp.ndarray): The output tensor from the forward pass. doutput (jnp.ndarray): The gradient with respect to the output. - q_seqlen (jnp.ndarray): Sequence lengths for the query, with shape [batch,]. - kv_seqlen (jnp.ndarray): Sequence lengths for the key and value, with shape [batch,]. - q_seq_offsets (jnp.ndarray): - The offsets in the sequence dim for the query, with shape [batch + 1,]. - kv_seq_offsets (jnp.ndarray): - The offsets in the sequence dim for the query, with shape [batch + 1,]. + sequence_descriptor (SequenceDescriptor): Sequence lengths and offsets for the query, + key and value, and optionally segment ids and positions. Replaces the separate + q_seqlen / kv_seqlen / q_seq_offsets / kv_seq_offsets arguments. attn_bias_type (AttnBiasType): Type of attention bias. attn_mask_type (AttnMaskType): Type of attention mask. softmax_type (AttnSoftmaxType): Type of softmax. diff --git a/transformer_engine/jax/flax/module.py b/transformer_engine/jax/flax/module.py index 17c9a242f04..094717c32b7 100644 --- a/transformer_engine/jax/flax/module.py +++ b/transformer_engine/jax/flax/module.py @@ -335,7 +335,7 @@ def __call__(self, x: jnp.ndarray) -> jnp.ndarray: Parameters ---------- - inputs : jax.numpy.ndarray + x : jax.numpy.ndarray Input tensors. Returns diff --git a/transformer_engine/jax/quantize/dequantizer.py b/transformer_engine/jax/quantize/dequantizer.py index ca44c2e4af4..bab5aac7993 100644 --- a/transformer_engine/jax/quantize/dequantizer.py +++ b/transformer_engine/jax/quantize/dequantizer.py @@ -143,12 +143,10 @@ def dequantize(scaled_tensor): """Dequantize a tensor using block scaling. Args: - data: The quantized tensor data - scale_inv: The inverse scaling factors - dq_dtype: The data type for dequantized values - scaling_mode: The scaling mode used for quantization - is_colwise: Whether the scaling is column-wise - flatten_axis: The axis along which the tensor could be flattened to 2D + scaled_tensor: The block-scaled tensor to dequantize. Its fields supply the + quantized data, the inverse scaling factors, the output dtype, the scaling + mode, whether the scaling is column-wise, and the axis it can be flattened + to 2D along. Returns: The dequantized tensor diff --git a/transformer_engine/pytorch/ops/fused/userbuffers_backward_linear.py b/transformer_engine/pytorch/ops/fused/userbuffers_backward_linear.py index c924f9d7b16..63f34c64d69 100644 --- a/transformer_engine/pytorch/ops/fused/userbuffers_backward_linear.py +++ b/transformer_engine/pytorch/ops/fused/userbuffers_backward_linear.py @@ -661,8 +661,6 @@ def fuse_backward_ops( ---------- ops : list of FusibleOperation Backward pass operations. - recipe : Recipe, optional - Quantization recipe. Returns ------- diff --git a/transformer_engine/pytorch/triton/mhc.py b/transformer_engine/pytorch/triton/mhc.py index 180c9be78e0..388734bc144 100644 --- a/transformer_engine/pytorch/triton/mhc.py +++ b/transformer_engine/pytorch/triton/mhc.py @@ -487,7 +487,6 @@ def forward( norm_weight (tensor or None): Optional, or tensor of shape (K,). RMSNorm's learnable per-element affine parameters use_tf32 (bool): Whether to use TF32 precision for matmul operations. If False, uses IEEE or TF32x3 for better precision. Due to a triton bug (https://github.com/triton-lang/triton/issues/10176), we will use TF32x3 if x is bf16 and phi is fp32, or use IEEE if otherwise. - n (int): Number of hyper connections, where only n=4 is supported in the current implementation. fused_grad_x_acc_buffer (torch.Tensor or None): A pre-allocated buffer for inplace gradient accumulation to avoid PyTorch autograd overhead. Returns: From e3178d9bf10989cb75697e93be368d51b35c80ad Mon Sep 17 00:00:00 2001 From: Kshitij Lakhani <33047503+KshitijLakhani@users.noreply.github.com> Date: Tue, 17 Nov 2026 18:44:08 -0800 Subject: [PATCH 2/2] Update transformer_engine/jax/cpp_extensions/attention.py Signed-off-by: Kshitij Lakhani <33047503+KshitijLakhani@users.noreply.github.com> --- transformer_engine/jax/cpp_extensions/attention.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/transformer_engine/jax/cpp_extensions/attention.py b/transformer_engine/jax/cpp_extensions/attention.py index 18a8bdb557c..172ff3ac622 100644 --- a/transformer_engine/jax/cpp_extensions/attention.py +++ b/transformer_engine/jax/cpp_extensions/attention.py @@ -3752,8 +3752,7 @@ def fused_attn_fwd( bias (Optional[jnp.ndarray]): An optional bias tensor to be added to the attention scores. softmax_offset (Optional[jnp.ndarray]): An optional softmax offset tensor. sequence_descriptor (SequenceDescriptor): Sequence lengths and offsets for the query, - key and value, and optionally segment ids and positions. Replaces the separate - q_seqlen / kv_seqlen / q_seq_offsets / kv_seq_offsets arguments. + key and value, and optionally segment ids and positions. seed (Optional[jnp.ndarray]): Optional random seed for dropout. attn_bias_type (AttnBiasType): Type of attention bias. attn_mask_type (AttnMaskType): Type of attention mask.