Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/jax/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]`.
Expand Down
17 changes: 5 additions & 12 deletions transformer_engine/jax/cpp_extensions/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -3751,12 +3751,8 @@ 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.
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.
Expand Down Expand Up @@ -3920,12 +3916,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.
Expand Down
2 changes: 1 addition & 1 deletion transformer_engine/jax/flax/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def __call__(self, x: jnp.ndarray) -> jnp.ndarray:

Parameters
----------
inputs : jax.numpy.ndarray
x : jax.numpy.ndarray
Input tensors.

Returns
Expand Down
10 changes: 4 additions & 6 deletions transformer_engine/jax/quantize/dequantizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment on lines -146 to +149

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay. Seems like the docstring was erroneously copied from _dequantize_func

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were right about the copy: that block described _dequantize_func's arguments, not _dequantize.

Checked both against their signatures now — _dequantize(x, quantized_dtype, scale, scale_inv, block_scaling_dim) versus _dequantize_func(x, quantized_dtype, scale, scale_inv, block_scaling_dim) — they do take the same parameter list, which is why the copy was wrong in wording rather than in content. The docstring in this PR names the parameters those two actually take, so the description no longer claims a different function's behaviour.


Returns:
The dequantized tensor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,6 @@ def fuse_backward_ops(
----------
ops : list of FusibleOperation
Backward pass operations.
recipe : Recipe, optional
Quantization recipe.

Returns
-------
Expand Down
1 change: 0 additions & 1 deletion transformer_engine/pytorch/triton/mhc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down