Skip to content

Add FLOOR_MOD (floored modulo) pointwise mode#393

Draft
vikramchandrashekar wants to merge 1 commit into
NVIDIA:developfrom
vikramchandrashekar:add-floor-mod-pointwise
Draft

Add FLOOR_MOD (floored modulo) pointwise mode#393
vikramchandrashekar wants to merge 1 commit into
NVIDIA:developfrom
vikramchandrashekar:add-floor-mod-pointwise

Conversation

@vikramchandrashekar

Copy link
Copy Markdown

Summary

Adds a new pointwise mode PointwiseMode_t::FLOOR_MOD (floored modulo) to complement the existing truncated MOD.

  • MOD (existing): truncated remainder — C fmod/%; result follows the sign of the dividend (matches torch.fmod).
  • FLOOR_MOD (new): floored modulo y = a - floor(a / b) * b; result follows the sign of the divisor (matches torch.remainder / Python %).

The two differ only for operands of opposite sign.

Changes

  • PointwiseMode_t::FLOOR_MOD enum value, JSON (de)serialization, port-count, and the is_pointwise_math_op allow-list.
  • Backend mapping to CUDNN_POINTWISE_FLOOR_MOD in both directions, guarded by #if (CUDNN_VERSION >= 92600) so the header-only frontend still compiles cleanly against older cuDNN (mirrors how RECIPROCAL is gated).
  • Python binding graph.floor_mod(a, b).
  • Unit test test/python/test_pointwise.py (mod vs torch.fmod, floor_mod vs torch.remainder); the floor_mod case skips on pre-9.26 backends.
  • Sample notebook samples/python/71_pointwise_mod.ipynb and a samples/README.md entry.

Requirements

Requires the backend CUDNN_POINTWISE_FLOOR_MOD enum, available in cuDNN 9.26.0+. On older cuDNN the frontend still compiles; floor_mod reports unsupported and the test/notebook skip gracefully.

Validation

Built and run on a GPU against a cuDNN 9.26 backend: graph.floor_mod matches torch.remainder and graph.mod matches torch.fmod, bit-exact on opposite-sign operands.


Opening as a draft pending the backend enum landing in a public cuDNN release.

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>
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3a2eba88-2107-4e53-bb2c-736644beff03

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@Anerudhan Anerudhan added cat-feature Requests for new functionality, APIs, examples, or behavior improvements. mod-backend cuDNN backend API, graph execution, descriptors, engines, or backend integration. orig-nv-eng Reported or requested by NVIDIA engineering. labels Jul 16, 2026
@Anerudhan Anerudhan added this to the Frontend 1.27.0 milestone Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat-feature Requests for new functionality, APIs, examples, or behavior improvements. mod-backend cuDNN backend API, graph execution, descriptors, engines, or backend integration. orig-nv-eng Reported or requested by NVIDIA engineering.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants