Skip to content

[Core] Fix normalization plan caching across CUDA devices - #3969

Open
jberchtold-nvidia wants to merge 2 commits into
NVIDIA:mainfrom
jberchtold-nvidia:jberchtold/fix-normalization-cache-and-capture
Open

jberchtold-nvidia wants to merge 2 commits into
NVIDIA:mainfrom
jberchtold-nvidia:jberchtold/fix-normalization-cache-and-capture

Conversation

@jberchtold-nvidia

Copy link
Copy Markdown
Collaborator

Description

Partition the per-thread normalization plan cache by CUDA device so cached cuDNN handles and execution plans match the device of the execution stream. Add numerical LayerNorm and RMSNorm forward/backward coverage while switching devices on explicit CUDA streams.

The regression fails on prebuilt core with CUDNN_STATUS_BAD_PARAM_STREAM_MISMATCH and passes on the fixed core.

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

  • Make cuDNN normalization plan keyed by GPU to support >1 GPU per process

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

Partition the per-thread normalization plan cache by CUDA device so cached
cuDNN handles and execution plans match the device of the execution stream.
Add numerical LayerNorm and RMSNorm forward/backward coverage while switching
devices on explicit CUDA streams.

The regression fails on the pipeline 82664301 prebuilt core with
CUDNN_STATUS_BAD_PARAM_STREAM_MISMATCH and passes on the fixed core.

Signed-off-by: Jeremy Berchtold <jberchtold@nvidia.com>
@greptile-apps

greptile-apps Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; the previous finding is fixed and no new actionable issues were found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous finding is fixed and no new actionable issues were found.

Summary

Partitions the per-thread normalization plan cache by CUDA device so each device reuses its own plans.

  • Normalization calls use a separate cached plan for each CUDA device.

Reviews (2) · Last reviewed commit: "Query the active CUDA device in normaliz..." · Reviewed by Greptile

normalizationPlanMap;
using PlanMap =
std::unordered_map<TupleKeyType, std::unique_ptr<NormalizationPlanBase>, TupleHash>;
std::unordered_map<int, PlanMap> normalizationPlanMaps;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

To keep the diff small and strictly relevant to the bug fix, I added a nested map instead of extending TupleKeyType as TupleKeyType is used in other places.

If we would instead like to extend TupleKeyType, let me know and I can make that change. The other cases may have similar issues where they assume 1 GPU per process, I'm not sure yet. Regardless of whether it merges in this change or not, looking into the other cases of 1 GPU per process assumptions in TE core is something we should do

@jberchtold-nvidia

Copy link
Copy Markdown
Collaborator Author

/te-ci L1

Read the active device's properties on each performTest invocation. Use its
compute capability for the cuDNN support guard and its SM count for
normalization plans, avoiding cached or hard-coded device-0 properties when
the device-switch regression runs on heterogeneous GPU hosts.

Validation: the cross-device normalization regression and two existing cuDNN
and TE normalization cases pass on GB200. Pre-commit and git diff --check pass.

Signed-off-by: Jeremy Berchtold <jberchtold@nvidia.com>
@jberchtold-nvidia

Copy link
Copy Markdown
Collaborator Author

/te-ci L1

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants