refactor(nn): modularize nn.cu into separate .inl files (#133)#137
Merged
refactor(nn): modularize nn.cu into separate .inl files (#133)#137
Conversation
Split the monolithic ops_bindings.cpp (~3000 lines) into 39 organized binding files for better maintainability and navigation. Directory structure: - elementwise/: binary, inplace, compare operations - unary/: math, trig operations - reduction/: basic, argmax, softmax operations - tensor/: cast, transpose, reshape, repeat operations - embedding/: lookup, kv_cache operations - nn/: activation, norm, attention, rope operations - gemm/: generic, fp8, nvf4, grouped, int operations - gemv/: generic, fp8, nvf4 operations - sampling/: basic, topk, seed operations - Other: quantize, paged_attention, continuous_batching, audio, cublaslt, moe Changes: - ops_bindings.cpp reduced from ~3000 to ~77 lines (init calls only) - bindings_common.hpp with shared includes and forward declarations - CMakeLists.txt updated with all new source files - Build verified: 238 tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Split the monolithic nn.cu (2673 lines) into modular files matching the binding structure from Issue #131: - activation/: gelu.inl, silu.inl, sigmoid.inl, tanh.inl - norm/: layernorm.inl, rmsnorm.inl - rope/: rope_inplace.inl - linear/: linear_bias.inl (+ softmax) - attention/: sdpa_causal.inl - tensor/: tensor.inl (transpose, reshape, concat, split) - embedding/: embedding.inl (lookup, kv_cache ops) - elementwise/: inplace.inl (add, mul, copy) - cast/: cast.inl (f32<->bf16/f16) Key changes: - nn.cu now aggregates all .inl files as single translation unit - Avoids LNK2005 duplicate symbol errors from CUDA kernels - activation_kernels.cuh uses PYGPUKIT_IMPLEMENT_NN_KERNELS guard - All .inl files use 'using namespace nn;' for kernel access Build: PASS (SM 120a, CUDA 13.1) Tests: 238 passed, 6/6 key NN ops verified 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
nn.cu(2673 lines) into modular.inlfiles matching binding structureFiles Changed
activation/norm/rope/linear/attention/tensor/embedding/elementwise/cast/Key Implementation Details
.inlfiles to compile as single translation unit.inlfiles useusing namespace nn;for kernel accessops/nn/nn.cuTest plan
🤖 Generated with Claude Code