Restore pre-1.27 module paths as deprecated aliases; clearer lazy-import errors - #724
Draft
Anerudhan wants to merge 1 commit into
Draft
Restore pre-1.27 module paths as deprecated aliases; clearer lazy-import errors#724Anerudhan wants to merge 1 commit into
Anerudhan wants to merge 1 commit into
Conversation
…ional deps for internal import failures The 1.27 "Reorganize Gemm fusion" commit kept every symbol importable as cudnn.<symbol>, but the old dotted module paths (import cudnn.grouped_gemm, from cudnn.grouped_gemm.grouped_gemm_wgrad.api import ...) broke: the attribute-level aliases in cudnn.__getattr__ cannot satisfy an import statement. The design doc called for sys.modules compatibility aliases; this implements them without violating the import-boundary rule that `import cudnn` must not pull torch / nvidia-cutlass-dsl: - cudnn/_legacy_aliases.py: a meta-path finder maps every legacy path (cudnn.grouped_gemm*, cudnn.discrete_grouped_gemm*, cudnn.gemm_amax, cudnn.gemm_swiglu, cudnn.gemm_srelu, cudnn.gemm_dsrelu, cudnn.gemm_proj_rope_mxfp8, and their submodules) onto its canonical cudnn.gemm.cutedsl.* module lazily, on first import of the legacy path. sys.modules[legacy] is sys.modules[canonical] afterwards, the canonical module keeps its own metadata, and a DeprecationWarning names the new path. The finder sits in front of PathFinder, which would otherwise resolve legacy children through the aliased parent's __path__ and execute the same file twice as two distinct modules. - _load_optional_symbol: only claim "requires optional dependencies. pip install nvidia-cudnn-frontend[cutedsl]" when the failure is an ImportError of a non-cudnn module; a missing cudnn-internal module is reported as a packaging bug and any other exception is surfaced as the real failure. All paths chain the underlying error and include its message, so a broken environment no longer masquerades as "the API was removed". - Docs: import-path note in fe-oss-apis/overview.md, alias note in cudnn.gemm docstring. - test/python/test_legacy_import_aliases.py: fresh-interpreter probes for alias identity, fromlist spelling, deprecation warning, finder idempotence, and both error-message classes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The 1.27 GEMM reorganization kept every public symbol importable as
from cudnn import <symbol>, but the old dotted module paths broke:The attribute-level aliases in
cudnn.__getattr__cannot satisfy an import statement (import a.bresolves through the import system, notgetattr). The package-structure design doc called forsys.modulescompatibility aliases, but they were never implemented.Separately,
_load_optional_symbolwrapped every failure as"<name> requires optional dependencies. Install with pip install nvidia-cudnn-frontend[cutedsl]", so an internal packaging bug or a real error inside a fusion module masqueraded as a missing optional dependency — which in turn read as "the API was removed".Change
cudnn/_legacy_aliases.py— asys.meta_pathfinder lazily maps every legacy path (cudnn.grouped_gemm*,cudnn.discrete_grouped_gemm*,cudnn.gemm_amax,cudnn.gemm_swiglu,cudnn.gemm_srelu,cudnn.gemm_dsrelu,cudnn.gemm_proj_rope_mxfp8, and their submodules, including the renamed per-fusion children likegrouped_gemm_wgrad→wgrad) onto its canonicalcudnn.gemm.cutedsl.*module on first import. After the import,sys.modules[legacy] is sys.modules[canonical]— one module, not a copy — and aDeprecationWarningnames the canonical path. Lazy by construction:import cudnnstill pulls no framework (the eager-sys.modulesapproach from the design doc would have violatedtest_import_boundaries.py). The finder must sit in front ofPathFinder, which would otherwise resolve legacy children through the aliased parent's__path__and execute the same file twice as two distinct modules._load_optional_symbol— failure classes are now distinguished: a missing third-party module keeps the[cutedsl]install hint (with the underlying error appended), a missingcudnn.*internal module is reported as a packaging bug, and any other exception is surfaced as the real failure. All paths chain viaraise ... from.docs/fe-oss-apis/overview.md; alias note in thecudnn.gemmdocstring.test/python/test_legacy_import_aliases.py: fresh-interpreter probes for alias identity, thefrom cudnn.grouped_gemm import grouped_gemm_wgradfromlist spelling, deprecation warnings, finder idempotence, and both error-message classes.Verification
cutlass/cuda-pythonimports on a GPU box).test/python/test_import_boundaries.py: 8/8 pass —import cudnnremains framework-free and the gnn/ops optional-dependency guidance is unchanged.🤖 Generated with Claude Code