feat(nn): add positional encoding operations (PoPE, ALiBi, YaRN, NTK, ReLU2)#174
Merged
feat(nn): add positional encoding operations (PoPE, ALiBi, YaRN, NTK, ReLU2)#174
Conversation
… ReLU2) Implements issues #136, #167, #169, #171: - ReLU2 activation (squared ReLU from Primer paper) - PoPE (sinusoidal positional encoding, additive alternative to RoPE) - ALiBi (attention with linear biases) - YaRN/NTK-aware RoPE extensions for context length scaling - Linear position interpolation for RoPE New kernels: - native/ops/nn/activation/relu2.inl - native/ops/nn/pope/pope_kernels.cuh, pope.inl - native/ops/nn/alibi/alibi_kernels.cuh, alibi.inl - native/ops/nn/rope/rope_ext_kernels.cuh, rope_ext.inl Tests: 22 passed, 2 skipped (GPU-only bf16/f16 tests) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add CPU implementations for PoPE, ALiBi, and RoPE extension functions to support testing in CI environments without GPU: - rope_init_ntk_aware: NTK-aware frequency scaling - rope_init_yarn: YaRN dimension-wise interpolation - rope_init_linear: Linear position interpolation - pope_init_encoding: Sinusoidal positional encoding - pope_inplace: Additive positional encoding - alibi_init_slopes: ALiBi head slopes - alibi_compute_bias: ALiBi bias matrix - alibi_add_bias: In-place bias addition Also fixed in-place update bug in _rope_inplace_cpu using proper backend.copy_host_to_device() instead of non-existent _data attribute. Fixes CI test failures for positional encoding tests. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This was referenced Dec 30, 2025
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
Implements issues #136, #167, #169, #171:
New Files
Kernels:
native/ops/nn/activation/relu2.inlnative/ops/nn/pope/pope_kernels.cuh,pope.inlnative/ops/nn/alibi/alibi_kernels.cuh,alibi.inlnative/ops/nn/rope/rope_ext_kernels.cuh,rope_ext.inlTests:
tests/test_relu2.pytests/test_positional_encoding.pyTest Plan
Closes #136, #167, #169, #171
🤖 Generated with Claude Code