Skip to main content

A library for pytorch layer testing.

Project description

tencheck

tencheck provides a simple set of utilities for analyzing and validating the properties of layers of deep neural nets.

It's typically quite difficult to validate that a layer "behaves properly" (oftentimes, the final barometer is simply how well a model performs with the layer included), and many brittle unit tests have been written involving randomly instantiated tensors and is_close checks. We believe a good "first line of defense" for neural nets is to create a suite of properties that can be asserted about a layer, while requiring minimal effort per layer in order to do so.

There are two aspects of property-based testing that are quite useful to take inspiration from:

  • Automatically generating inputs (and generating inputs of variable sizes and values to elucidate properties of interest).
  • Evaluating properties based on the maintenance of invariants instead of attempting to exactly match values (which is particularly difficult to interpret in deep neural nets).

However, an important difference is that the properties of interest are generally fairly generic and often shared between layers, while the input generation strategies are pretty similar (they're all tensors). So the focus of tencheck is to provide:

  • An (attempted) universal input generation harness.
  • A variety of interesting properties.
  • Three modalities: assertion, analysis, and profiling.

The following requirements need to be met for tencheck to work:

  • Your layers are implemented in torch.
  • The .forward() method is annotated with jaxtyping.

Usage

Create a unit test like the following and define the modules you'd like to have tested:

from tencheck.harness import check_layers

def test_check_layers(self):
    LAYERS_TO_TEST = [
        MyTorchModule(c=4),
        MyTorchModule2(a=4, b=2),
    ]    
    check_layers(LAYERS_TO_TEST)

The .forward() method can be type annotated with the following "tencheck"-table types:

  • Jaxtyped Tensors
  • Dataclasses where each attribute is "tencheck"-able
  • list[tencheckable]
    • Tencheck will always generate a list of length 2.
  • Optional[tencheckable]
    • Tencheck will always generate the non-null value.

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

tencheck-0.0.4a1.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

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

tencheck-0.0.4a1-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file tencheck-0.0.4a1.tar.gz.

File metadata

  • Download URL: tencheck-0.0.4a1.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tencheck-0.0.4a1.tar.gz
Algorithm Hash digest
SHA256 8f991b75c883692883680b1e1106e39681514979609dad89eb4765a86714066e
MD5 051260a25a663ca318fb321c9aa944b2
BLAKE2b-256 3e6b2d5f7fd12c2c4c77d85f3670c76c36519495fc8e28463b4ae508d58ce757

See more details on using hashes here.

File details

Details for the file tencheck-0.0.4a1-py3-none-any.whl.

File metadata

  • Download URL: tencheck-0.0.4a1-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tencheck-0.0.4a1-py3-none-any.whl
Algorithm Hash digest
SHA256 bc6b402a84da09a30f87f93523bbdce6c4d080d64f34d00fe24df5f229a6554f
MD5 5069723a9c9993f8dda7e9059caf1433
BLAKE2b-256 33dcf188aa8a8d86cb32226e7915e582c62550ad087bcd15568264488f58dc4c

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