PitchHut logo
A PyTorch-compatible tensor library for machine learning.
Pitch

DSC is an intuitive tensor library and inference framework designed for machine learning. With a familiar API similar to NumPy and PyTorch, it enables easy transition for existing models. Supporting both CPU and CUDA backends, DSC prioritizes performance, minimal dependencies, and ensures no runtime memory allocations, making it an efficient solution for developers.

Description

DSC: A Tensor Library & Inference Framework for Machine Learning

DSC is a powerful, PyTorch-compatible tensor library designed specifically for machine learning models. It offers a low-level API that is C-compatible, wrapped in a modern Python interface that resembles popular libraries like NumPy and PyTorch, while also providing notable usability enhancements.

Key Features

  • Intuitive API: The DSC Python API is designed to be user-friendly, making it easy for developers familiar with NumPy and PyTorch to get started.

  • Built-In Neural Network Support: DSC includes nn.Module built-in functionality, making the transition from PyTorch to DSC straightforward. For illustrative examples, refer to the examples directory.

  • Support for Multiple Backends: Whether utilizing CPU or CUDA, DSC accommodates various backends effortlessly. Users can switch between backends by using the dsc.set_default_device('...') command, ensuring minimal code changes.

  • Minimal External Dependencies: Efficiency is a key focus of DSC. It requires no external libraries, and core operations are crafted from the ground up in portable C++, ensuring high portability of the code.

  • Custom Memory Allocation: DSC features a custom memory allocator that pre-allocates memory only once, eliminating the overhead of frequent calls to malloc() and free(). Additionally, users can opt for a linear allocator for further optimization.

Quick Start Guide

Getting started with DSC is straightforward. Below are the primary requirements:

  • A C++20-compatible compiler
  • GNU Make for building

To set up on a Linux-based system, use the following commands:

sudo apt update
sudo apt install build-essential

For installation from source:

git clone git@github.com:nirw4nna/dsc.git
cd dsc/
python3 -m venv venv
source venv/bin/activate
python3 -m pip install -e .

To compile the C++ library:

make clean; make shared DSC_FAST=1

Verify the installation by performing a simple operation:

python3 -c "import dsc; x = dsc.arange(10); print(x)"

Utilizing the CUDA Backend

For GPU acceleration on NVIDIA GPUs, ensure that the CUDA Toolkit is installed. To build the C++ library with CUDA support:

make clean; make shared DSC_FAST=1 DSC_CUDA=1

Run a simple GPU operation to check if the CUDA backend is functioning:

python3 -c "import dsc; x = dsc.arange(10, device='cuda'); print(x)"

Testing Framework

DSC employs pytest for unit testing against NumPy, the reference for correctness. To run all tests:

cd python/tests/
pytest -s test_ops.py --no-header --no-summary -q

Compile DSC with DSC_FAST=1 for optimized testing.

DSC stands out as a compact yet efficient framework for machine learning inference, ensuring both performance and ease of use.

0 comments

No comments yet.

Sign in to be the first to comment.