slangtorch
A package for calling Slang modules from Python and PyTorch.
What it is and what it does
slangtorch bridges the Slang shading language and PyTorch, allowing you to write GPU kernels in Slang and call them from Python. Slang is a language designed for graphics and compute shaders; slangtorch compiles Slang code to CUDA and integrates it with PyTorch's tensor operations. This is useful when you need fine-grained control over GPU computation or want to leverage existing Slang code within a PyTorch workflow.
The package requires external setup: CUDA Toolkit v12.0 or later and PyTorch v2.x built with CUDA support must be installed before slangtorch. It depends on torch, ninja (for build acceleration), filelock, and hatchling. The package is actively maintained and supports Python 3.10 and later on Linux and Windows.
Use it for:
- Write custom PyTorch operations in Slang for performance-critical GPU compute tasks.
- Integrate existing Slang shaders or compute kernels into a PyTorch training or inference pipeline.
- Prototype GPU algorithms using Slang's language features before optimizing further.
- Combine graphics and compute workloads by reusing Slang code across PyTorch and graphics applications.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
slangtorch lets you write PyTorch kernels in the Slang shading language, compiling them to run on CUDA-capable GPUs.
Yes, if you need to write or integrate Slang-based GPU kernels with PyTorch and have the required CUDA and PyTorch setup. The package is actively maintained, permissively licensed, and has no known vulnerabilities. The main barrier is the external dependency on CUDA Toolkit v12.0+ and PyTorch v2.x with CUDA support; if those are already in your environment, installation is straightforward.
Install
slangtorch on PyPI
pip
pip install slangtorchuv
uv add slangtorchpoetry
poetry add slangtorchInstalling slangtorch
Before you install
Medium install friction due to runtime dependencies on torch, ninja, and hatchling; requires CUDA Toolkit v12.0 or later and PyTorch v2.x with CUDA support as external prerequisites. Package itself is actively maintained with a release 14 days old.
License in practice
Licensed under MIT (permissive), so you can use, modify, and distribute slangtorch and code built with it freely, including in commercial projects, provided you retain the license notice.
Quickstart
pip install slangtorch
import slangtorch
# Requires CUDA Toolkit v12.0+ and PyTorch v2.x with CUDA support installed first
CUDA Toolkit v12.0 or later and PyTorch v2.x with CUDA support must be installed before slangtorch; a CUDA-capable GPU is required to run kernels.
Verify before relying
- Whether Slang kernel compilation is transparent to the user or requires explicit build steps beyond import.
- What performance characteristics or overhead slangtorch adds compared to native PyTorch CUDA kernels.
- Whether the package supports AMD GPUs or only NVIDIA CUDA devices.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 4 — filelock, hatchling, ninja, torch |
| Maintenance | actively maintained — 14 days since the last release |
| First released | |
| Downloads | 92,224/month — #13,466 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: slangtorch-1.3.22-py3-none-manylinux_2_27_x86_64.whl; slangtorch-1.3.22-py3-none-manylinux_2_28_aarch64.whl; slangtorch-1.3.22-py3-none-win_amd64.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
sglang-kernelsglang-kernel provides optimized CUDA compute…
permissive · top 15,000 on PyPI
nvidia-cuda-tileirasProvides a portable intermediate representation…
unclear · top 5,000 on PyPI
cuda-pythoncuda-python is a metapackage providing Pythonic…
unclear · top 5,000 on PyPI
cpm-kernelsProvides CUDA kernels optimized for CPM,…
permissive · top 15,000 on PyPI
cuequivariance-ops-torch-cu12Provides CUDA-accelerated PyTorch kernels and…
unclear · top 15,000 on PyPI
nvidia-cuda-nvrtcProvides NVIDIA CUDA NVRTC (NVIDIA Runtime…
unclear · top 1,000 on PyPI
tilelangTilelang is a domain-specific language for…
permissive · top 5,000 on PyPI
cuda-tilecuTile Python is a compiler and programming…
permissive · top 5,000 on PyPI
nvidia-cutlass-dsl-libs-cu13Provides a Python DSL for writing…
unclear · top 5,000 on PyPI
nvidia-cutlass-dsl-libs-cu12Provides a Python DSL for writing…
unclear · top 5,000 on PyPI