Dao-AILab/causal-conv1d

Causal depthwise conv1d in CUDA, with a PyTorch interface

What it solves

It provides a highly optimized CUDA implementation of causal depthwise 1D convolutions, which are essential for sequence modeling in AI models. It replaces the standard PyTorch conv1d operation with a specialized kernel that is more efficient for causal operations (where the output at a time step depends only on the past and the past current step).

How it works

The project implements a custom CUDA kernel that performs depthwise 1D convolutions. It supports multiple precision formats (fp32, fp16, bf16) and kernel sizes of 2, 3, and 4. It integrates directly into PyTorch as a function causal_conv1d_fn that takes an input tensor, weights, and an optional bias and activation function (such as SiLU or Swish).

Who it’s for

Developers and researchers building high-performance sequence models or state-space models (SSMs) who need an efficient, low-level CUDA implementation of causal convolutions.

Highlights

  • Optimized CUDA kernels for causal depthwise 1D convolutions.
  • Support for fp32, fp16, and bf16 precision.
  • Support for kernel sizes 2, 3, and 4.
  • Built-in support for optional SiLU and Swish activation functions.
  • Compatibility with both NVIDIA (CUDA) and AMD (ROCm) hardware.

Related

  • Project
  • Project
  • Project
  • Project
  • Project