Features:
- Support fp32, fp16, bf16.
- Kernel size 2, 3, 4.
from causal_conv1d import causal_conv1d_fndef causal_conv1d_fn(x, weight, bias=None, activation=None):
"""
x: (batch, dim, seqlen)
weight: (dim, width)
bias: (dim,)
activation: either None or "silu" or "swish"
out: (batch, dim, seqlen)
"""Equivalent to:
import torch.nn.functional as F
F.conv1d(x, weight.unsqueeze(1), bias, padding=width - 1, groups=dim)[..., :seqlen]causal-conv1d supports AMD GPUs via ROCm/HIP (ROCm 6.1+).
# Set your GPU architecture
export HIP_ARCHITECTURES=gfx1201 # e.g., gfx1100, gfx1101, gfx1201
# --no-build-isolation ensures the build uses your existing ROCm PyTorch
# instead of pulling the default CUDA PyTorch from PyPI
CAUSAL_CONV1D_FORCE_BUILD=TRUE pip install --no-build-isolation -e .--no-build-isolation is required because pip's default build isolation installs a CUDA-only PyTorch, which causes the HIP detection to fail.
If you are on ROCm 6.0, apply the following patch before building. This is not required for ROCm 6.1 onwards.
-
Locate your ROCm installation directory. This is typically found at
/opt/rocm/, but may vary depending on your installation. -
Apply the Patch. Run with
sudoin case you encounter permission issues.patch /opt/rocm/include/hip/amd_detail/amd_hip_bf16.h < rocm_patch/rocm6_0.patch