--- id: slangtorch version: "1.3.22" license: unclear license_treatment: permissive maintenance: active --- # slangtorch — A package for calling Slang modules from Python and PyTorch. License: permissive · Maintenance: active · Downloads: 92.2K/mo ## 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 above — 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 pip install slangtorch uv add slangtorch poetry add slangtorch ## Installing 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_current - Install friction: medium - Maintenance: active - Downloads: 92.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytorch custom kernels, slang gpu compute, cuda kernel writing, pytorch shader language, gpu kernel compilation, slang pytorch integration, custom cuda kernels, gpu-compute, shader-language, pytorch-extension [View on SkillFed](https://skillfed.io/packages/slangtorch) · [View on PyPI](https://pypi.org/project/slangtorch/)