Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
JITFunction
✓ from tokenspeed_triton import JITFunction
✗ import triton
autotune
✓ from tokenspeed_triton import autotune
✗ import triton
compile
✓ from tokenspeed_triton import compile
✗ import triton
Defines a Triton kernel for element-wise addition and launches it with a grid.
import torch
import triton
import triton.language as tl
@triton.jit
def add_kernel(x_ptr, y_ptr, output_ptr, n_elements, BLOCK_SIZE: tl.constexpr):
pid = tl.program_id(axis=0)
block_start = pid * BLOCK_SIZE
offsets = block_start + tl.arange(0, BLOCK_SIZE)
mask = offsets < n_elements
x = tl.load(x_ptr + offsets, mask=mask)
y = tl.load(y_ptr + offsets, mask=mask)
output = x + y
tl.store(output_ptr + offsets, output, mask=mask)
def add(x: torch.Tensor, y: torch.Tensor):
output = torch.empty_like(x)
n_elements = output.numel()
grid = lambda meta: (triton.cdiv(n_elements, meta['BLOCK_SIZE']),)
add_kernel[grid](x, y, output, n_elements, BLOCK_SIZE=1024)
return output
# Example usage
device = 'cuda' if torch.cuda.is_available() else 'cpu'
x = torch.randn(10000, device=device)
y = torch.randn(10000, device=device)
result = add(x, y)
print(result[:5])
Upgrade
Version history
3.7.10.post20260531latest on PyPI · released May 31, 2026
Audit
Dependencies
torchrequiredRequired for GPU tensor operations and integration.
litellmoptionalOptional for model serving integration.