tensor-spec
Overview
tensor-spec is a framework-agnostic deep learning API quality verification tool. It compares tensor operation precision across deep learning frameworks (currently PaddlePaddle vs PyTorch) using process isolation and CUDA IPC zero-copy GPU data sharing.
Features
- Framework-agnostic -- Pluggable backend architecture supporting PaddlePaddle and PyTorch
- Process isolation -- Each framework runs in its own subprocess to avoid CUDA/import conflicts
- CUDA IPC zero-copy -- GPU tensor sharing via CUDA IPC handles (1000x faster than CPU roundtrip)
- Secure config parsing -- Whitelist recursive descent parser (no
eval()) - Constraint-driven data generation -- Generate test tensors from specs with composable constraints
- Per-API tolerance -- Configurable atol/rtol with TOML-based overrides per operator
- Structured logging -- JSON Lines output for machine-parseable test results
- CLI interface --
check,bench,doctor,setup,migrate,pack/unpackcommands via Typer
Installation
pip install tensor-spec
Or with uv:
uv add tensor-spec
Quick Start
# Check a single case on one backend
tensor-spec check 'abs(x=Tensor.float32((2, 3)))' --target backend=torch,python=/path/to/python
# Cross-framework comparison (auto-selects reference)
tensor-spec check cases/ --target torch-cu124 --target paddle-cu124
# e2e benchmark
tensor-spec bench --mode e2e cases/ --target torch-cu124 --target paddle-cu124 --baseline torch-cu124
# NCU benchmark (artifacts default to ./.tensor-spec/bench-artifacts)
tensor-spec bench --mode ncu cases/ --target torch-cu124 --target paddle-cu124
# Dry-run validation (no execution)
tensor-spec check cases/ --target torch-cu124 --dry-run
# Environment diagnosis
tensor-spec doctor
Development
Prerequisites
Setup
just install
Common Commands
just # List all available commands
just format # Format code (Python + justfile)
just lint # Run linter
just check # Type checking (pyright)
just test # Run all tests
just cov # Run tests with coverage
just docs # Serve docs locally
just ci # Full CI check (format + check + lint + cov)
Architecture
The project follows a 10-layer modular architecture:
| Layer | Module | Responsibility |
|---|---|---|
| 1 | spec |
Pure data structures for tensor specifications |
| 2 | config |
Secure whitelist recursive descent parser |
| 3 | datagen |
Constraint-driven numpy array generation |
| 4 | backend |
Pluggable framework backends (Paddle, PyTorch) |
| 5 | mapping |
API name/argument mapping between frameworks |
| 6 | compare |
Tensor comparison with configurable tolerance |
| 7 | tester |
Test execution modes (in-process, isolated) |
| 8 | worker |
Subprocess management and IPC protocol |
| 9 | ipc |
SharedMemory (CPU) and CUDA IPC (GPU) transport |
| 10 | cli |
Typer-based CLI entry point |
Documentation
For detailed usage and API documentation, please visit our documentation site. For CLI design details, see CLI Specification.
Contributing
We welcome contributions! Please see CONTRIBUTING.md for development setup and contribution guidelines.
Metadata
Release files for tensor-spec 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tensor_spec-0.1.2.tar.gz | 1.0 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tensor_spec-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.1 MB
Release files / tensor_spec-0.1.2.tar.gz
| Download URL | tensor_spec-0.1.2.tar.gz |
|---|---|
| Size | 1.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2ade9316e8df66fcfe7deb07d22b22b9c174fe643840fd33f4fa4489d58c4dc
|
|
BLAKE2b-256 checksum How to use checksums |
2ba534d1ae7a2a0a612b4590992ea59d98f0da55bd3160a9a462673534d64e1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / tensor_spec-0.1.2-py3-none-any.whl
| Download URL | tensor_spec-0.1.2-py3-none-any.whl |
|---|---|
| Size | 57.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c3df23cbb22972827c604d0a5fa19ae6a159a5f23ddc607e2e9bb6a64008ab8a
|
|
BLAKE2b-256 checksum How to use checksums |
bcd82551cdfe99f861060283025945f65d5fe7f195ea42c9722bb7419a12526d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for tensor-spec 0.1.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.