Skip to content

[FEA] Add Snake activation functor for Epilogue Visitor Tree (EVT) #3141

Closed

Description

@emre570

Which component requires the feature?

CUTLASS C++

Feature Request

Is your feature request related to a problem? Please describe.

CUTLASS provides several built-in activation functors (GELU, ReLU, SiLU, etc.) that can be used inside the Epilogue Visitor Tree framework. However, there is currently no support for the Snake activation function (x + sin²(αx) / α, Ziyin et al. 2020), a parametric activation that has seen adoption in audio synthesis models (neural vocoders) and other domains where periodic inductive bias is beneficial.

Users who need Snake activation in fused GEMM epilogues currently have to fall back to unfused workflows, running the activation as a separate kernel after GEMM, which incurs additional global memory round-trips.

Describe the solution you'd like

Add a SnakeOp functor to CUTLASS's activation function library, following the same pattern as existing functors like GELU. The implementation would:

  • Support scalar and Array<T, N> specializations
  • Take a learnable per-channel α parameter via Sm90RowBroadcast
  • Be composable within the SM90 EVT framework (e.g. Sm90Compute<SnakeOp, ...>)

I have a working implementation targeting SM90 (Hopper) that I'd be happy to contribute as a PR. The EVT tree structure is:

// EVT tree: SnakeOp(AccFetch, RowBroadcast(alpha))
using SnakeEpilogue = Sm90EVT<
    Sm90Compute<SnakeOp, ElementOut, ElementEpi,
                cutlass::FloatRoundStyle::round_to_nearest>,
    Sm90AccFetch,
    Sm90RowBroadcast<0, TileShape, float>
>;

Describe alternatives you've considered

  • Unfused approach: Running Snake activation as a separate PyTorch/custom CUDA kernel after the GEMM. This works but requires an extra global memory read/write of the full output tensor.
  • Approximating with existing functors: Snake cannot be accurately decomposed into existing CUTLASS activation primitives since it requires sin² and a per-channel learnable parameter.

Additional context

Benchmarks (H100 SXM5 80GB, SM90)

Implicit GEMM shapes from a production neural vocoder (Conv1d k=7 mapped to GEMM as M=T, N=C_out, K=C_in×7):

GEMM Shape (M × N × K) cuDNN Conv + Separate Snake CUTLASS Fused EVT Speedup
1200 × 768 × 5376 0.108 – 0.138 ms 0.078 ms 1.39 – 1.76×
6000 × 384 × 2688 0.125 – 0.664 ms 0.078 ms 1.61 – 8.51×
24000 × 192 × 1344 0.174 – 0.193 ms 0.082 ms 2.12 – 2.35×
48000 × 96 × 672 0.168 – 0.170 ms 0.063 – 0.064 ms 2.65 – 2.70×

Median speedup across all 12 shapes is approximately 2.1×, with the benefit primarily coming from eliminating the extra memory round-trip for the activation kernel.

Implementation

The implementation follows CUTLASS's existing functor conventions (scalar + Array<T, N> specializations, __sinf fast math intrinsic). I'm ready to open a PR if there's interest.

Reference

Ziyin, L., Hartwig, T., & Ueda, M. "Neural Networks Fail to Learn Periodic Functions and How to Fix It." NeurIPS 2020. arXiv:2006.08195 , introduces x + (1/a) sin²(ax).

# [Feature Request] Add Snake activation functor for Epilogue Visitor Tree (EVT)

Is your feature request related to a problem? Please describe.

CUTLASS provides several built-in activation functors (GELU, ReLU, SiLU, etc.) that can be used inside the Epilogue Visitor Tree framework. However, there is currently no support for the Snake activation function (x + sin²(αx) / α, Ziyin et al. 2020), a parametric activation that has seen adoption in audio synthesis models (neural vocoders) and other domains where periodic inductive bias is beneficial.

Users who need Snake activation in fused GEMM epilogues currently have to fall back to unfused workflows, running the activation as a separate kernel after GEMM, which incurs additional global memory round-trips.

Describe the solution you'd like

Add a SnakeOp functor to CUTLASS's activation function library, following the same pattern as existing functors like GELU. The implementation would:

  • Support scalar and Array<T, N> specializations
  • Take a learnable per-channel α parameter via Sm90RowBroadcast
  • Be composable within the Sm90 EVT framework (e.g. Sm90Compute<SnakeOp, ...>)

I have a working implementation targeting SM90 (Hopper) that I'd be happy to contribute as a PR. The EVT tree structure is:

// EVT tree: SnakeOp(AccFetch, RowBroadcast(alpha))
using SnakeEpilogue = Sm90EVT<
    Sm90Compute<SnakeOp, ElementOut, ElementEpi,
                cutlass::FloatRoundStyle::round_to_nearest>,
    Sm90AccFetch,
    Sm90RowBroadcast<0, TileShape, float>
>;

Describe alternatives you've considered

  • Unfused approach: Running Snake activation as a separate PyTorch/custom CUDA kernel after the GEMM. This works but requires an extra global memory read/write of the full output tensor.
  • Approximating with existing functors: Snake cannot be accurately decomposed into existing CUTLASS activation primitives since it requires sin² and a per-channel learnable parameter.

Additional context

Benchmarks (H100 SXM5 80GB, SM90)

Implicit GEMM shapes from a production neural vocoder (Conv1d k=7 mapped to GEMM as M=T, N=C_out, K=C_in×7):

GEMM Shape (M × N × K) cuDNN Conv + Separate Snake CUTLASS Fused EVT Speedup
1200 × 768 × 5376 0.108 – 0.138 ms 0.078 ms 1.39 – 1.76×
6000 × 384 × 2688 0.125 – 0.664 ms 0.078 ms 1.61 – 8.51×
24000 × 192 × 1344 0.174 – 0.193 ms 0.082 ms 2.12 – 2.35×
48000 × 96 × 672 0.168 – 0.170 ms 0.063 – 0.064 ms 2.65 – 2.70×

Median speedup across all 12 shapes is approximately 2.1×, with the benefit primarily coming from eliminating the extra memory round-trip for the activation kernel.

Implementation

The implementation follows CUTLASS's existing functor conventions (scalar + Array<T, N> specializations, __sinf fast math intrinsic). I'm ready to open a PR if there's interest.

Reference

Ziyin, L., Hartwig, T., & Ueda, M. "Neural Networks Fail to Learn Periodic Functions and How to Fix It." NeurIPS 2020. [arXiv:2006.08195](https://arxiv.org/abs/2006.08195), introduces x + (1/a) sin²(ax).

Activity

  1. zeel2104 commented on Apr 5, 2026

    @zeel2104

    Is it open for contribution?

  2. emre570 commented on Apr 6, 2026

    @emre570
    ContributorAuthor

    Is it open for contribution?

    Hi, I have a working implementation ready, planning to open a PR once maintainers signal interest. Happy to collaborate on review and testing once it's up 🙂

  3. github-actions commented on May 6, 2026

    @github-actions

    This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

  4. emre570 commented on May 6, 2026

    @emre570
    ContributorAuthor

    This issue has been linked to a proper working PR. It needs to be reviewed
    #3184

  5. added a commit that references this issue on May 12, 2026
    2e56847
  6. added a commit that references this issue on Jul 20, 2026
    40af5a4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions