Skip to content

causal-conv1d: sync kernels with upstream v1.6.2.post1 (deterministic backward)#939

Closed
kashif wants to merge 2 commits into
huggingface:mainfrom
kashif:causal-conv1d-sync
Closed

causal-conv1d: sync kernels with upstream v1.6.2.post1 (deterministic backward)#939
kashif wants to merge 2 commits into
huggingface:mainfrom
kashif:causal-conv1d-sync

Conversation

@kashif

@kashif kashif commented Jun 8, 2026

Copy link
Copy Markdown

Syncs the causal-conv1d CUDA kernels with upstream v1.6.2.post1. The main thing this brings is an opt-in deterministic backward — set CAUSAL_CONV1D_DETERMINISTIC=1 (or torch.use_deterministic_algorithms(True)) and the bwd accumulates through workspaces instead of atomics, so gradients are reproducible. I kept the kernels-build binding tweaks on top of the upstream sources (<torch/all.h>, op registration stays in torch_binding.cpp).

Also tidies up mamba-ssm: the four modules that optionally use causal_conv1d now import it from one small utils/causal_conv1d.py helper instead of each repeating the same try/except. The helper stays pip-only (use the installed causal_conv1d, else None) to match how every other kernel here works — composing from the Hub stays the caller's job. A lazy get_kernel fallback can be added later, once the updated causal-conv1d is published with a version tag to pin to.

Built and ran against torch 2.12 / cu13 on an sm_86 card — compiles fine and causal_conv1d_fn matches a reference conv1d+SiLU exactly.

The bigger mamba-ssm update (full selective-scan port, Mamba-3 / quack / tilelang) is left for a follow-up.

🤖 Generated with Claude Code

kashif and others added 2 commits June 8, 2026 19:31
… bwd)

Update the CUDA/C++ sources to upstream causal-conv1d v1.6.2.post1, which adds
an opt-in deterministic backward path (CAUSAL_CONV1D_DETERMINISTIC env var /
torch.use_deterministic_algorithms) backed by dweight/dbias workspaces.

Keep the kernels-build binding adaptations on top of the upstream sources:
include <torch/all.h> and let torch-ext/torch_binding.cpp own op registration
(the upstream PYBIND11_MODULE blocks stay commented out). Builds and runs
against torch 2.12/cu13 on sm_86; causal_conv1d_fn matches a reference
conv1d+SiLU exactly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add utils/causal_conv1d.py which imports the pip-installed causal_conv1d when
present and degrades every symbol to None otherwise, then point the mamba /
mamba2 modules at it instead of repeating per-file try/except import guards.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Hi @kashif, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/huggingface/kernels-community/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant