A multi-backend SYRK (Symmetric Rank-K Update) implementation
Project description
SYRK
A multi-backend implementation of the Symmetric Rank-K Update (SYRK) operation.
Overview
SYRK computes the symmetric rank-k update operation:
D = α × A × Aᵀ + β × C
Where:
Ais an (N, K) input matrixCis an optional (N, N) symmetric matrixαandβare scalar coefficientsDis the (N, N) symmetric output matrix
Installation
# Basic installation
pip install .
# With Triton backend support
pip install ".[triton]"
# With all optional dependencies
pip install ".[all]"
Quick Start
import torch
from syrk import syrk
# Create input tensor (bfloat16 on CUDA)
a = torch.randn(1024, 512, dtype=torch.bfloat16, device='cuda')
# Compute A @ A^T
result = syrk(a)
print(result.shape) # torch.Size([1024, 1024])
# With scaling factors
result = syrk(a, alpha=0.5)
# With additive term
c = torch.randn(1024, 1024, dtype=torch.bfloat16, device='cuda')
c = (c + c.T) / 2 # Make symmetric
result = syrk(a, c=c, alpha=1.0, beta=0.5)
API Reference
syrk(a, c=None, alpha=1.0, beta=0.0, skip_upper_triangle=False, backend=None)
Compute the Symmetric Rank-K Update operation.
Parameters:
a(torch.Tensor): Input tensor of shape (N, K). Must be bfloat16.c(torch.Tensor, optional): Symmetric input tensor of shape (N, N). Required if beta != 0.alpha(float): Scaling factor for the matrix multiplication. Default: 1.0.beta(float): Scaling factor for the matrix addition. Default: 0.0.skip_upper_triangle(bool): If True, only compute the lower triangle. Default: False.backend(Backend, optional): The backend to use. Auto-selects if None.
Returns:
- torch.Tensor: Output tensor of shape (N, N).
Backends
Triton Backend
The Triton backend provides a high-performance GPU implementation using NVIDIA's Triton compiler. It requires:
- Triton >= 3.4.0 with TMA (Tensor Memory Accelerator) support
- NVIDIA GPU with appropriate compute capability
from syrk import syrk
from syrk.backends import Backend, get_available_backends
# Check available backends
print(get_available_backends()) # [<Backend.TRITON: 'triton'>]
# Explicitly use Triton backend
result = syrk(a, backend=Backend.TRITON)
Requirements
- Python >= 3.9
- PyTorch >= 2.0.0
- (Optional) Triton >= 3.4.0 for Triton backend
License
This project is licensed under the MIT License. See LICENSE for details.
The Triton backend implementation is based on code from NVIDIA Corporation, originally licensed under the Apache License 2.0.
Acknowledgments
- NVIDIA Corporation for the original Triton SYRK implementation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file syrk-0.1.0.tar.gz.
File metadata
- Download URL: syrk-0.1.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b11a4313d2b6ccd0dddd436b41b5d91008dabffa430592d1d6bf319011b0671f
|
|
| MD5 |
ff3929664f16d06d67fda797bc3770aa
|
|
| BLAKE2b-256 |
46e9f267f62e75fe3ca1cce672accb951eb814b2028836f1402848f5f6450f8b
|
Provenance
The following attestation bundles were made for syrk-0.1.0.tar.gz:
Publisher:
workflow.yml on pysyrk/syrk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
syrk-0.1.0.tar.gz -
Subject digest:
b11a4313d2b6ccd0dddd436b41b5d91008dabffa430592d1d6bf319011b0671f - Sigstore transparency entry: 789489797
- Sigstore integration time:
-
Permalink:
pysyrk/syrk@76651ea1323fe5ab2aa39f8763709d2da2f21aa6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/pysyrk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@76651ea1323fe5ab2aa39f8763709d2da2f21aa6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file syrk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: syrk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d27c653d563c4f886f4c67ceef2ae17936ad8c4203cac0546067b6463396c56
|
|
| MD5 |
e962ea62ebd54a2a4d636692fc170961
|
|
| BLAKE2b-256 |
19a3512b0831ab1dfce4cd5bc5c40a6ccdb9d13a64fadfe6752f055e51e33aea
|
Provenance
The following attestation bundles were made for syrk-0.1.0-py3-none-any.whl:
Publisher:
workflow.yml on pysyrk/syrk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
syrk-0.1.0-py3-none-any.whl -
Subject digest:
5d27c653d563c4f886f4c67ceef2ae17936ad8c4203cac0546067b6463396c56 - Sigstore transparency entry: 789489801
- Sigstore integration time:
-
Permalink:
pysyrk/syrk@76651ea1323fe5ab2aa39f8763709d2da2f21aa6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/pysyrk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@76651ea1323fe5ab2aa39f8763709d2da2f21aa6 -
Trigger Event:
push
-
Statement type: