Tensorlink is a decentralized Python library for distributed PyTorch models, providing easy Hugging Face API access and enabling users to share compute resources across a global network.
Project description
Peer-to-peer AI Inference & Distributed Execution with PyTorch
Table of Contents
What is Tensorlink?
Tensorlink is a Python library and decentralized compute platform for running PyTorch and Hugging Face models across peer-to-peer networks. It enables you to easily distribute and remotely access models across devices through PyTorch-facing wrappers or HTTP endpoints via your own hardware or by tapping into public peer-to-peer resources. Hardware owners can leverage their own GPUs for private remote AI services or contribute resources to the public network and earn rewards.
Key Features
- Run Large Models - Automatic offloading and model sharding across peers
- Native PyTorch & REST API - Use models directly in Python or via HTTP endpoints
- Streaming Generation - Token-by-token streaming for real-time responses
- Privacy Controls - Route queries exclusively to your own hardware
- Earn Rewards - Contribute GPU resources to the network and get compensated
Early Access: Tensorlink is under active development. APIs and internals may evolve. Join our Discord for updates, support, and roadmap discussions.
Quick Start
There are three ways to interact with Tensorlink. Choose the path that fits your use case:
- Distributed Models in Python - run PyTorch/Hugging Face models directly from Python
- HTTP API - OpenAI-style REST endpoints for distributed inference
- Run a Node - contribute GPU compute or host your own private cluster
Distributed Models in Python
Installation
pip install tensorlink
Requirements: Python 3.10+, UNIX/macOS (Windows: use WSL). No GPU required to use the public network.
Inference
from tensorlink.ml import DistributedModel
from transformers import AutoTokenizer
MODEL_NAME = "Qwen/Qwen3-14B"
model = DistributedModel(model=MODEL_NAME)
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
inputs = tokenizer("Explain the theory of relativity.", return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=100)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Distributed Training
from tensorlink.ml import DistributedModel
model = DistributedModel(model="Qwen/Qwen3-14B", training=True)
optimizer = model.create_optimizer(optimizer_type="adamw", lr=1e-4, weight_decay=0.01)
# Training loop works like standard PyTorch
outputs = model(**inputs, labels=inputs["input_ids"])
outputs.loss.backward()
optimizer.step()
optimizer.zero_grad()
For private clusters, custom architectures, and full parameter reference, see docs/distributed-models.md.
HTTP API
Access models via HTTP - either through the public network or your own private node. The API is OpenAI-compatible and requires no GPU or Python on the client side.
Simple generation
import requests
response = requests.post(
"http://smartnodes.ddns.net/tensorlink-api/v1/generate",
json={
"hf_name": "Qwen/Qwen2.5-7B-Instruct",
"message": "Explain quantum computing in one sentence.",
"max_new_tokens": 50,
"stream": False,
}
)
print(response.json()["generated_text"])
OpenAI-compatible chat
import requests
response = requests.post(
"http://localhost:64747/v1/chat/completions",
json={
"model": "Qwen/Qwen2.5-7B-Instruct",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What are the benefits of distributed computing?"}
],
"max_tokens": 150,
"stream": False,
}
)
print(response.json()["choices"][0]["message"]["content"])
For all endpoints, streaming, the responses API, and model preloading, see docs/api.md.
Run a Node
Run worker or validator nodes to contribute compute to the public network, host a private cluster, or expose models as API endpoints.
- Download the latest
tensorlink-nodefrom Releases - Edit
config.jsonto configure your node - Run
./run-node.sh
The default config runs a public worker node, where your GPU will process network jobs and earn rewards on the public network via Smartnodes.
For configuration reference, private cluster setup, and network architecture patterns, see docs/nodes.md.
To contribute your GPU in the fastest way possible, see docs/worker-guide.md.
Learn More
| Resource | Description |
|---|---|
| Getting Started | Installation, requirements, and first steps |
| Distributed Models | DistributedModel, DistributedOptimizer, private clusters |
| API Reference | HTTP endpoints, parameters, and examples |
| Node Setup | Workers, validators, config reference, network topologies |
| Worker Quick Start | Contribute GPU compute in minutes |
| Discord Community | Get help and connect with developers |
| Live Demo | Try a chatbot powered by Tensorlink |
| Litepaper | Technical overview and architecture |
Contributing
Read our contribution guide.
Tensorlink is released under the MIT License.
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 tensorlink-0.3.0.tar.gz.
File metadata
- Download URL: tensorlink-0.3.0.tar.gz
- Upload date:
- Size: 226.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1013-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f418dc2863f5f7e6f45204cae9368993ec1bcc91c4747c3a64f1b053a1d5fb2
|
|
| MD5 |
7580053767f0bbe12a723f35507c9a22
|
|
| BLAKE2b-256 |
9b78cbdb05bb0f13cd543fe434a7c5cdb8b237459cd97cee977765af98ee0533
|
File details
Details for the file tensorlink-0.3.0-py3-none-any.whl.
File metadata
- Download URL: tensorlink-0.3.0-py3-none-any.whl
- Upload date:
- Size: 242.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1013-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb1b1e089c66983235fbcbc1f72a0f5a94ac0956a3db716a6ba05092569af08c
|
|
| MD5 |
7808c44bdb83e06d79402b540bd8970c
|
|
| BLAKE2b-256 |
3a55b4f634adfacb0da0cf6c1a09fc548188bd74f687196762512ba0c7dbf3d3
|