Skip to content

Minimize the memory usage of the fused cross entropy kernel - #3273

Draft
ptrendx wants to merge 2 commits into
NVIDIA:mainfrom
ptrendx:pr_cross_entropy_memory_usage
Draft

Minimize the memory usage of the fused cross entropy kernel#3273
ptrendx wants to merge 2 commits into
NVIDIA:mainfrom
ptrendx:pr_cross_entropy_memory_usage

Conversation

@ptrendx

@ptrendx ptrendx commented Jul 29, 2026

Copy link
Copy Markdown
Member

Description

The changes introduced in #3193, while fixing the numerical issue with the fused cross entropy kernel, introduced additional memory requirement. This PR aims to greatly reduce that additional memory usage while preserving the numerics and optimizing runtime performance.

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • The original algorithm computed the full derivative in the forward pass and then passed it to backward pass in order to be multiplied by the incoming gradients. In this PR the thing saved to backward is instead the statistics needed to compute the derivative. This lowers the memory consumption and the number of bytes needed to be read by the backward kernel.
  • The new flow contains 2 paths - single-GPU with a single kernel for forward computation and the multi-GPU one with 2 kernels, similar to the existing path.

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

ptrendx added 2 commits July 29, 2026 07:16
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant