Skip to content

fix(cudnn): implement cuDNN 9 error codes, replace todo!() panic with proper mapping#371

Draft
CharryWu wants to merge 1 commit intoRust-GPU:mainfrom
CharryWu:fix/cudnn9-error-codes
Draft

fix(cudnn): implement cuDNN 9 error codes, replace todo!() panic with proper mapping#371
CharryWu wants to merge 1 commit intoRust-GPU:mainfrom
CharryWu:fix/cudnn9-error-codes

Conversation

@CharryWu
Copy link
Copy Markdown
Contributor

Summary

Fixes a runtime panic in crates/cudnn/src/error.rs when the cudnn crate is built against cuDNN 9+.

Problem

When DEP_CUDNN_VERSION >= 90000, the build script sets cfg(cudnn9). The into_result() implementation had an unresolved TODO comment followed by _ => todo!(). Any unrecognized status code would panic at runtime rather than return an error.

cuDNN 9 restructured cudnnStatus_t into a hierarchical numeric system. New sub-codes such as CUDNN_STATUS_BAD_PARAM_NULL_POINTER (2002) and CUDNN_STATUS_NOT_SUPPORTED_ARCH_MISMATCH (3007) could trigger the wildcard arm and cause panics.

Changes

  • Add four new CudnnError variants behind #[cfg(cudnn9)]: SublibraryVersionMismatch, SerializationVersionMismatch, Deprecated, SublibraryLoadingFailed
  • Replace _ => todo!() with a category-based fallback mapping cuDNN 9 sub-codes to their parent category variant via integer division: 2xxx=BAD_PARAM, 3xxx=NOT_SUPPORTED, 4xxx=INTERNAL_ERROR, 5xxx=EXECUTION_FAILED
  • Wire new variants in into_raw() for round-trip correctness

Verification

Verified against cudnn_graph.h from cuDNN 9.20 (CUDA 13.2 / anaconda). The cudnn crate compiles cleanly on this setup.

Testing

  • cudnn crate compiles with cuDNN 9.20 on Windows 11 / CUDA 13.2
  • No todo!() remains in error handling path
  • All cuDNN 8 code paths preserved under #[cfg(not(cudnn9))]

…r mapping

cuDNN 9 restructured cudnnStatus_t into a hierarchical numeric system
(2xxx=BAD_PARAM, 3xxx=NOT_SUPPORTED, 4xxx=INTERNAL_ERROR, 5xxx=EXECUTION_FAILED)
and removed several codes present in cuDNN 8.

Changes:
- Add four new CudnnError variants behind #[cfg(cudnn9)]:
  SublibraryVersionMismatch, SerializationVersionMismatch, Deprecated,
  SublibraryLoadingFailed
- Replace the _ => todo!() wildcard in IntoResult::into_result() with a
  category-based fallback that maps cuDNN 9 sub-codes (e.g. BAD_PARAM_NULL_POINTER)
  to their parent category variant using integer division, eliminating the
  runtime panic entirely
- Add wire both new variants in into_raw() for round-trip correctness

Verified against cudnn_graph.h from cuDNN 9.20 (anaconda distribution).
The cudnn crate itself compiles cleanly; only pre-existing cust bindgen
errors prevent a full cargo check -p cudnn from succeeding.

Made-with: Cursor
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