Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

torch-sql

torch-sql is a skunkworks prototype that runs PyTorch programs, or parts of them, as SQL on XQL, a group of database projects for scientific arrays. It has three frontends:

  • a co-processor, which leaves the model in PyTorch and takes over the training data pipeline and evaluation;
  • a device, device="sql", on which every tensor is a table;
  • a torch.compile backend.

Its first real model is Samudra, an ocean emulator.

The first milestone, M1 in the design, is under way: a two-layer MLP, then nanoGPT (Andrej Karpathy's small GPT), trained on device="sql". Start with the docs:

Install

torch-sql is on PyPI, as an alpha. Install it with an engine, DuckDB or DataFusion, to run anything:

pip install "torch-sql[duckdb]"       # or torch-sql[datafusion], or both

It needs Python 3.12 or later and PyTorch 2.15 or later.

Development

torch-sql uses uv. From the repository root:

uv sync --all-extras   # PyTorch (CPU), ddxdb, DataFusion and DuckDB
uv run pytest          # every test runs on both engines
uv run ruff check && uv run ruff format --check

On NixOS, first put libstdc++ and zlib on LD_LIBRARY_PATH, as the XQL repositories' flake.nix files do.

Example

nanoGPT's model.py, unchanged but for its GELU, trains on device="sql" and matches PyTorch step by step (tests/test_nanogpt.py). A smaller example, a two-layer MLP run on DuckDB:

import torch, torch_sql

with torch_sql.Environment("duckdb"):
    mlp = torch.nn.Sequential(torch.nn.Linear(3, 5), torch.nn.Tanh(), torch.nn.Linear(5, 2))
    mlp = mlp.double().to("sql")
    y = mlp(torch.randn(4, 3, dtype=torch.float64, device="sql"))
    print(y)  # runs one SQL query on DuckDB

Metadata

Release files for torch-sql 0.1.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torch-sql 0.1.0rc1
File Size Uploaded Provenance Actions
torch_sql-0.1.0rc1.tar.gz 256.4 kB With provenance Details for torch_sql-0.1.0rc1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for torch-sql 0.1.0rc1
File Interpreter ABI Platform Actions
torch_sql-0.1.0rc1-py3-none-any.whl Python 3 none any Details for torch_sql-0.1.0rc1-py3-none-any.whl

Total release size: 324.8 kB

Release files / torch_sql-0.1.0rc1.tar.gz

Download URL torch_sql-0.1.0rc1.tar.gz
Size 256.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0091751dd1343fa9f6726b61b4dbeef6b3250d44ce711b19d0c501b6351538da
BLAKE2b-256 checksum
How to use checksums
b546bc3313655cdd84908b442d12538d719b88ea3189e032d7a9ce57aa1cfa1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / torch_sql-0.1.0rc1-py3-none-any.whl

Download URL torch_sql-0.1.0rc1-py3-none-any.whl
Size 68.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef623047e35b206fd066951b7b3a92efd28a0254dcd0f0cf5f96d9af0ae21866
BLAKE2b-256 checksum
How to use checksums
75a79d84e095654171cd95dba0ca585ae73652cfdfb8cdc3ec17477567112ed2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for torch-sql 0.1.0rc1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for torch_sql-0.1.0rc1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

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.

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