Skip to main content

Turbo-Torch

Turbo-Torch is a performance-oriented drop-in interface inspired by PyTorch, designed around the idea of reducing repeated computation overhead through internal caching, Cython-backed execution paths, and lightweight runtime optimizations.

The goal is simple:

Keep the PyTorch-style developer experience, while making repeated workloads feel faster.

Turbo-Torch preserves familiar tensor operations, module APIs, optimizers, and utility patterns while introducing an internal optimization layer that can cache reusable intermediate state and avoid unnecessary Python-level overhead.

Installation

pip install turbo-torch

Quick Start

Turbo-Torch follows the familiar PyTorch programming model.

import turbo_torch as torch
from turbo_torch import nn
from turbo_torch import optim

This allows existing PyTorch-style code to remain largely unchanged while using Turbo-Torch's runtime layer.

Example

import turbo_torch as torch
from turbo_torch import nn

model = nn.Sequential(
    nn.Linear(784, 256),
    nn.ReLU(),
    nn.Linear(256, 10)
)

x = torch.randn(64, 784)

output = model(x)

print(output.shape)

Why Turbo-Torch?

Traditional tensor workloads can repeatedly perform the same bookkeeping and dispatch operations:

Python
  ↓
Tensor API
  ↓
Operator dispatch
  ↓
Kernel execution

Turbo-Torch introduces an internal optimization layer:

Python
  ↓
Turbo-Torch API
  ↓
Cython Runtime Layer
  ↓
Cache / Dispatch Layer
  ↓
Tensor Operations
  ↓
Backend Kernel

Frequently reused execution paths can therefore bypass portions of the normal Python-side dispatch overhead.

Internal Architecture

Turbo-Torch is built around several internal components.

Runtime Cache

The runtime maintains lightweight caches for reusable execution metadata, including:

  • operator dispatch information
  • tensor shape signatures
  • dtype/device combinations
  • frequently accessed execution paths
  • reusable intermediate metadata
  • module-level execution state

A simplified lookup can be thought of as:

(operation, shape, dtype, device)
              ↓
        cache lookup
        ↙         ↘
    HIT             MISS
     ↓                ↓
cached path       resolve path
     ↓                ↓
execution ←────── cache update

The cache is designed to reduce repeated resolution work rather than blindly caching tensor values.

Cython Execution Layer

Performance-sensitive runtime components are implemented through Cython-oriented paths where appropriate.

Instead of performing every piece of dispatch logic through Python objects, Turbo-Torch can move selected hot-path operations closer to the CPython C-API boundary.

Conceptually:

Python API
    ↓
Cython bridge
    ↓
typed runtime structures
    ↓
cached dispatch
    ↓
backend operation

This reduces Python interpreter overhead for workloads containing large numbers of small or repeatedly invoked operations.

Drop-In PyTorch Style

Turbo-Torch intentionally follows familiar PyTorch conventions.

For example:

import turbo_torch as torch
import turbo_torch.nn as nn
import turbo_torch.optim as optim

Common APIs retain their expected usage patterns:

x = torch.tensor([1, 2, 3])

model = nn.Linear(3, 2)

optimizer = optim.Adam(
    model.parameters(),
    lr=1e-3
)

The intention is that developers should not need to learn an entirely new tensor programming model just to take advantage of the runtime layer.

Tensor Operations

a = torch.randn(1024, 1024)
b = torch.randn(1024, 1024)

c = torch.matmul(a, b)

Repeated operations can benefit from cached runtime metadata:

for _ in range(1000):
    c = torch.matmul(a, b)

Turbo-Torch's optimization layer can reuse information associated with previously resolved execution paths where the workload characteristics remain compatible.

Neural Networks

Turbo-Torch supports the familiar module-oriented programming model:

class Network(nn.Module):
    def __init__(self):
        super().__init__()

        self.layers = nn.Sequential(
            nn.Linear(784, 512),
            nn.ReLU(),
            nn.Linear(512, 10)
        )

    def forward(self, x):
        return self.layers(x)

Training remains familiar:

model = Network()
optimizer = optim.Adam(model.parameters())

for x, y in dataloader:
    optimizer.zero_grad()

    output = model(x)
    loss = loss_fn(output, y)

    loss.backward()
    optimizer.step()

Optimization Strategy

Turbo-Torch focuses primarily on reducing runtime overhead around tensor execution, rather than attempting to replace the underlying numerical backend.

The optimization stack can be summarized as:

┌─────────────────────────────┐
│       Turbo-Torch API       │
├─────────────────────────────┤
│     Runtime Dispatch        │
├─────────────────────────────┤
│   Cython Optimization Layer │
├─────────────────────────────┤
│     Internal Cache Layer     │
├─────────────────────────────┤
│   Tensor / Backend Runtime   │
└─────────────────────────────┘

This separation allows the user-facing API to remain familiar while optimization decisions happen internally.

What Gets Cached?

Turbo-Torch does not simply cache every tensor produced by an operation.

Instead, the runtime can cache reusable execution metadata such as:

  • operator signatures
  • dispatch decisions
  • compatible tensor layouts
  • dtype/device resolution
  • shape-dependent execution information
  • Python-to-runtime conversion metadata

This makes the cache significantly lighter than storing complete tensor results.

Cache Invalidation

Cached execution paths are associated with the characteristics that produced them.

When those characteristics become incompatible, Turbo-Torch can invalidate or bypass the cached path.

For example:

Cached:
    matmul
    float32
    CUDA
    [1024, 1024]

New request:
    matmul
    float16
    CUDA
    [2048, 2048]

                ↓

       cache mismatch
                ↓
        resolve new path
                ↓
          cache update

This prevents stale execution metadata from being reused incorrectly.

Performance Philosophy

Turbo-Torch is designed around a simple principle:

Optimize the path to the operation, not just the operation itself.

For workloads dominated by large GPU kernels, the performance difference may be limited because the underlying kernel execution dominates total runtime.

Turbo-Torch is therefore particularly interested in workloads where Python-side dispatch and repeated runtime bookkeeping represent a meaningful portion of execution time.

API Compatibility

Turbo-Torch intentionally mirrors the PyTorch programming model wherever practical.

Typical imports can be adapted from:

import torch
import torch.nn as nn
import torch.optim as optim

to:

import turbo_torch as torch
import turbo_torch.nn as nn
import turbo_torch.optim as optim

The rest of the application can remain structurally similar.

Design Goals

  • Familiar PyTorch-style API
  • Low Python-level dispatch overhead
  • Cython-assisted runtime paths
  • Lightweight internal caching
  • Shape/dtype/device-aware execution metadata
  • Minimal changes to existing code
  • Transparent cache invalidation
  • Backend-agnostic optimization where possible

Project Status

Turbo-Torch is currently an experimental runtime layer / research project exploring whether transparent caching and Cython-assisted dispatch can reduce overhead in PyTorch-style workloads.

Performance characteristics depend heavily on workload, tensor sizes, backend, device, and execution pattern.

Benchmarks should therefore be performed against the specific workload rather than assuming a universal speedup.

License

This project is intended for experimentation and research.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

turbo_toorch-0.1.7.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

turbo_toorch-0.1.7-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file turbo_toorch-0.1.7.tar.gz.

File metadata

  • Download URL: turbo_toorch-0.1.7.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for turbo_toorch-0.1.7.tar.gz
Algorithm Hash digest
SHA256 b3d68547e6eebf7d148e5401504d48bad3223857e84f8a508d68958061e03fc1
MD5 7847e8ca1e29df46a98bb34026141cd2
BLAKE2b-256 acc17c6110dd63111971994ec8f5fd7cf478abd6aa2e7a7c9d10ec4a4b5ea993

See more details on using hashes here.

File details

Details for the file turbo_toorch-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: turbo_toorch-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for turbo_toorch-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 70e7bf94a94371de8f39adb24d8aa253938d6e298c7033b4badecee5795bf60b
MD5 b2bee08ee1f3ad7a2e67045c7770e7d7
BLAKE2b-256 a1c3ebdc79649b369719218577f5e09aca4c052c44ba78c1095bd1824b9c99b8

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.9

2 files

0.1.8

2 files

This release

0.1.7 This release

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page