nemo_automodel.components.models.common.sinkhorn
nemo_automodel.components.models.common.sinkhorn
Sinkhorn normalization of hyper-connection (mHC) mixing logits.
The torch implementation is the numerical reference. The optional CUDA path
uses DeepSeek TileKernels tile_kernels.modeling.mhc.ops.sinkhorn_normalize
and its low-level kernels; no TileKernels source is vendored. Upstream source:
https://github.com/deepseek-ai/TileKernels/blob/36d9e45d38e204ebb87e6f6e833821eee0482fe5/tile_kernels/modeling/mhc/ops/sinkhorn.py
Upstream license: MIT, copyright 2026 DeepSeek.
Module Contents
Classes
Functions
API
Bases: Function
TileKernels Sinkhorn wrapper that accepts non-contiguous backward gradients.
The upstream high-level wrapper launches the backward kernel with
grad_output as-is. Hyper-connection combinations are consumed through
transposed matmul sites, so autograd can provide a transposed gradient
layout. The low-level TileKernels backward kernel requires contiguous
row-major inputs.
Run the TileKernels backward kernel on a contiguous copy of the gradient.
Parameters:
Autograd context.
Gradient of shape […, streams, streams], any strides.
Returns: tuple[torch.Tensor, None, None]
Input gradient with the forward input’s shape, then None for repeat and eps.
Run the TileKernels forward kernel.
Parameters:
Autograd context.
CUDA logits of shape […, streams, streams], with arbitrary leading dimensions.
Number of normalization rounds.
Additive stabilizer.
Returns: torch.Tensor
Tensor with the shape of x, independent of its storage.
Return whether the TileKernels Sinkhorn wrapper and its forward/backward kernels are importable.
Run the TileKernels Sinkhorn; never falls back to the torch path.
Parameters:
CUDA logits of shape […, streams, streams], with arbitrary leading dimensions.
Number of normalization rounds.
Additive stabilizer.
Returns: torch.Tensor
Tensor with the shape of x.
Raises:
RuntimeError: If TileKernels is not importable orxis not a CUDA tensor.
Normalize mixing logits into an approximately doubly stochastic matrix.
Parameters:
Logits of shape […, streams, streams], with arbitrary leading dimensions.
Number of row/column normalization rounds; the first round starts from a softmax.
Additive stabilizer applied to every normalization denominator.
Returns: torch.Tensor
Tensor with the shape and dtype of x.