Add FLOOR_MOD (floored modulo) pointwise mode#393
Draft
vikramchandrashekar wants to merge 1 commit into
Draft
Conversation
Adds PointwiseMode_t::FLOOR_MOD, mapping to the backend CUDNN_POINTWISE_FLOOR_MOD enum (cuDNN 9.26.0+). FLOOR_MOD is floored modulo (y = a - floor(a / b) * b; the result follows the sign of the divisor), complementing the existing truncated MOD (C fmod/%; result follows the sign of the dividend); the two differ only for operands of opposite sign. Exposed as graph.floor_mod in the Python bindings, with a demo notebook contrasting mod (torch.fmod) and floor_mod (torch.remainder). The references to the backend CUDNN_POINTWISE_FLOOR_MOD enum are guarded by CUDNN_VERSION >= 92600, so the header-only frontend still compiles cleanly against older cuDNN releases (there floor_mod resolves to CUDNN_STATUS_NOT_SUPPORTED). Adds unit-test coverage for floor_mod. Signed-off-by: Vikram Chandrashekar <vikramc@nvidia.com>
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Anerudhan
approved these changes
Jul 16, 2026
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.
Summary
Adds a new pointwise mode
PointwiseMode_t::FLOOR_MOD(floored modulo) to complement the existing truncatedMOD.MOD(existing): truncated remainder — Cfmod/%; result follows the sign of the dividend (matchestorch.fmod).FLOOR_MOD(new): floored moduloy = a - floor(a / b) * b; result follows the sign of the divisor (matchestorch.remainder/ Python%).The two differ only for operands of opposite sign.
Changes
PointwiseMode_t::FLOOR_MODenum value, JSON (de)serialization, port-count, and theis_pointwise_math_opallow-list.CUDNN_POINTWISE_FLOOR_MODin both directions, guarded by#if (CUDNN_VERSION >= 92600)so the header-only frontend still compiles cleanly against older cuDNN (mirrors howRECIPROCALis gated).graph.floor_mod(a, b).test/python/test_pointwise.py(modvstorch.fmod,floor_modvstorch.remainder); thefloor_modcase skips on pre-9.26 backends.samples/python/71_pointwise_mod.ipynband asamples/README.mdentry.Requirements
Requires the backend
CUDNN_POINTWISE_FLOOR_MODenum, available in cuDNN 9.26.0+. On older cuDNN the frontend still compiles;floor_modreports unsupported and the test/notebook skip gracefully.Validation
Built and run on a GPU against a cuDNN 9.26 backend:
graph.floor_modmatchestorch.remainderandgraph.modmatchestorch.fmod, bit-exact on opposite-sign operands.Opening as a draft pending the backend enum landing in a public cuDNN release.