Skip to main content

Framework-agnostic deep learning API quality verification tool

Project description

tensor-spec

PyPI - Python Version pypi PyPI - Downloads LICENSE

uv ruff Gitmoji

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 -- run, validate, and accuracy commands via Typer

Installation

pip install tensor-spec

Or with uv:

uv add tensor-spec

Quick Start

# Validate a case config (parse-only, no framework needed)
tensor-spec validate "abs(x=Tensor.float32((2, 3)))"

# Run single-backend execution
tensor-spec run --backend paddle "abs(x=Tensor.float32((2, 3)))"

# Cross-framework accuracy comparison (subprocess-isolated)
tensor-spec accuracy "matmul(x=Tensor.float32((2, 3)), y=Tensor.float32((3, 4)))"

Development

Prerequisites

  • Python >= 3.12
  • uv for dependency management
  • just for task running

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.

Contributing

We welcome contributions! Please see CONTRIBUTING.md for development setup and contribution guidelines.

Project details


Download files

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

Source Distribution

tensor_spec-0.1.0.tar.gz (958.6 kB view details)

Uploaded Source

Built Distribution

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

tensor_spec-0.1.0-py3-none-any.whl (47.7 kB view details)

Uploaded Python 3

File details

Details for the file tensor_spec-0.1.0.tar.gz.

File metadata

  • Download URL: tensor_spec-0.1.0.tar.gz
  • Upload date:
  • Size: 958.6 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for tensor_spec-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e935ff666df04e8c4a429a048f52ce128bd98c9e9c786165e19ae976520eb56a
MD5 304ebe96c6947c333643ea15c2369f9e
BLAKE2b-256 3cc6b78a240de65be00501254c1a04dc5ec7b0dd7f3a9959a5dc06b10910d598

See more details on using hashes here.

File details

Details for the file tensor_spec-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tensor_spec-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 47.7 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for tensor_spec-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35dd921a138fe9b8d72bdb30a04f8a22ef987d8ddbcc8e1ee104a860c5ada8cf
MD5 4cc04ff6a6a6d5f144d7429189e23065
BLAKE2b-256 7e53e1079c6aa6aa8ee627f9b5b09193fec50e4042a02db7834a8b6bc3d4b240

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page