torch_tvarant
Open-source PyTorch backend for the Tvarant RISC-V SIMT GPGPU (Xilinx Alveo U55C).
Develop on a CPU simulator, deploy through OpenCL → POCL → libtvarant when hardware is available. Includes a JIT graph compiler for LLM inference fusion.
📖 Documentation · 🐛 Issues · 🗺️ Roadmap · 🤝 Contributing
Quick start
import torch
import torch_tvarant
x = torch.randn(4, 8, device="tvarant")
w = torch.randn(8, 8, device="tvarant")
y = torch.nn.functional.relu(x @ w)
assert y.device.type == "tvarant"
pip install torch pytest ninja
pip install -e .
pytest tests/ -v
See Getting Started for full install instructions.
Features
| Feature | Description |
|---|---|
| Device backend | torch.device("tvarant") via PrivateUse1 |
| CPU simulator | Host-accessible memory for fast iteration |
| OpenCL runtime | Same API on POCL / FPGA path |
| LLM ops | silu, softmax, bmm, layer_norm, embedding, … |
| Fused GEMM | Single kernel for matmul + bias + relu/silu |
| JIT compiler | FX fusion + OpenCL kernel codegen for pointwise chains |
| torch.compile | Registered backend="tvarant" |
JIT compiler
import torch
import torch.nn as nn
import torch_tvarant
model = nn.Sequential(nn.Linear(768, 768), nn.ReLU()).to("tvarant")
compiled = torch_tvarant.compiler.compile(model)
y = compiled(torch.randn(4, 768, device="tvarant"))
Fuses linear + relu/silu into one kernel and collapses pointwise chains.
Details: JIT Compiler docs.
FPGA / OpenCL
USE_OPENCL=1 pip install -e .
TVARANT_BACKEND=opencl python your_script.py
See FPGA / OpenCL docs.
Project structure
csrc/aten/ ATen op registrations
csrc/jit/ Pointwise JIT IR + OpenCL codegen
csrc/kernels/ Host + OpenCL kernels
csrc/runtime/ Sim and OpenCL device runtime
torch_tvarant/ Python package + graph compiler
tests/ Pytest suite
docs/ MkDocs documentation
Contributing
We welcome contributions! See CONTRIBUTING.md.
- Fork the repo
- Create a feature branch
- Add tests
- Open a pull request
Please read our Code of Conduct.
Roadmap
- Fused attention kernel (#1)
- KV-cache + decode GEMM (#2)
- RMSNorm, RoPE, SwiGLU (#3)
- Shape-specialized GEMM JIT (#4)
Full roadmap: docs/roadmap.md
License
Licensed under the Apache License 2.0.
Security
Report vulnerabilities via GitHub Security Advisories. See SECURITY.md.
Changelog
See CHANGELOG.md.
Metadata
Release files for torch-tvarant 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torch_tvarant-0.1.0.tar.gz | 47.4 kB | Without provenance | Details for torch_tvarant-0.1.0.tar.gz |
Release files / torch_tvarant-0.1.0.tar.gz
| Download URL | torch_tvarant-0.1.0.tar.gz |
|---|---|
| Size | 47.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d13504ad95cf8116c93257a1fb563f6e4c5947456823189a408f36a72b1382f7
|
|
BLAKE2b-256 checksum How to use checksums |
3fe2376fc5d121de7beacb07c48d73ce34a189fe66620c39681c98b25c33ff6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for torch-tvarant 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.