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
498 changes: 498 additions & 0 deletions docs/fe-oss-apis/moe_ep.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/fe-oss-apis/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This folder documents the Python FE APIs implemented under `python/cudnn`. For d
- [SDPA Forward FE OSS API (SM100, D=256)](https://docs.nvidia.com/deeplearning/cudnn/frontend/latest/operations/Attention.html#sdpa-forward-fe-oss-sm100-d256)
- [SDPA Backward FE OSS API (SM100, D=256)](https://docs.nvidia.com/deeplearning/cudnn/frontend/latest/operations/Attention.html#sdpa-backward-fe-oss-sm100-d256)
- [RMSNorm + SiLU](rmsnorm_silu.md)
- [MoE + Expert Parallel API proposal](moe_ep.md)

## Installation and setup

Expand Down
3 changes: 3 additions & 0 deletions python/cudnn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ def _dlopen_cudnn():
_OPTIONAL_DEPENDENCY_INSTALL_HINT = "Install with 'pip install nvidia-cudnn-frontend[cutedsl]'"

_LAZY_OPTIONAL_IMPORTS = {
"moe_ep": (".moe_ep", None),
"MoeEp": (".moe_ep", "MoeEp"),
"MoeFormat": (".moe_ep", "MoeFormat"),
Comment on lines +281 to +283

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Repository root: '; pwd
printf '\nFiles:\n'
git ls-files 'python/cudnn/**' | sed -n '1,120p'

printf '\nRelevant files:\n'
git ls-files 'python/cudnn/__init__.py' 'python/cudnn/moe_ep/__init__.py' 'test/python/fe_api/**' 2>/dev/null || true

Repository: NVIDIA/cudnn-frontend

Length of output: 10964


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Repository root: '; pwd

printf '\npython/cudnn/__init__.py outline:\n'
ast-grep outline python/cudnn/__init__.py --view expanded || true

printf '\npython/cudnn/moe_ep/__init__.py outline:\n'
ast-grep outline python/cudnn/moe_ep/__init__.py --view expanded || true

printf '\nfe_api tests mentioning moe_ep / BlockScaledTensor / MoeTensor:\n'
rg -n "BlockScaledTensor|MoeTensor|MoeEp|moe_ep" test/python/fe_api python/cudnn -g'*.py' || true

Repository: NVIDIA/cudnn-frontend

Length of output: 7902


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Searching for root-level imports and docs for moe_ep symbols...\n'
rg -n "from cudnn import (BlockScaledTensor|MoeTensor|MoeEp|MoeFormat)|import .*BlockScaledTensor|import .*MoeTensor|cudnn\.BlockScaledTensor|cudnn\.MoeTensor" \
  python test -g'*.py' -g'*.md' || true

printf '\nTop-level lazy import mapping around moe_ep:\n'
sed -n '275,292p' python/cudnn/__init__.py

printf '\nMoeEp package init:\n'
sed -n '1,40p' python/cudnn/moe_ep/__init__.py

Repository: NVIDIA/cudnn-frontend

Length of output: 1875


Expose BlockScaledTensor and MoeTensor from cudnn if they’re public API. python/cudnn/moe_ep/__init__.py exports both, but python/cudnn/__init__.py only wires up moe_ep, MoeEp, and MoeFormat, so from cudnn import BlockScaledTensor/MoeTensor will fail today. Add the missing lazy imports and a small root-import test if these symbols are meant to be user-facing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/cudnn/__init__.py` around lines 281 - 283, Update the lazy export
mapping in the cudnn package initializer to expose BlockScaledTensor and
MoeTensor from .moe_ep alongside MoeEp and MoeFormat, preserving the existing
lazy-import pattern. Add a focused root-import test verifying both symbols can
be imported from cudnn.

"BSA": (".block_sparse_attention", "BSA"),
"block_sparse_attention_forward": (".block_sparse_attention", "block_sparse_attention_forward"),
"block_sparse_attention_backward": (".block_sparse_attention", "block_sparse_attention_backward"),
Expand Down
6 changes: 6 additions & 0 deletions python/cudnn/moe_ep/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: MIT

from .api import BlockScaledTensor, MoeEp, MoeFormat, MoeTensor

__all__ = ["BlockScaledTensor", "MoeEp", "MoeFormat", "MoeTensor"]
Loading