Skip to main content

d-Matrix Compressor

Project description

dmx-compressor

Build License Documentation GitHub release Commits Contributors Stars


This project contains tools for deep neural net co-design for custom hardware accelerators.


Overview

In essence this is an extension of the PyTorch framework that implements hardware-efficient features, including

  • custom low-precision numerical formats and arithmetic,
  • fine-grain structured weight sparsity, and
  • custom operator approximation logic.

In addition, the project provides a set of optimization tools for co-design using the above features.

Getting started

pip install dmx-compressor

Usage

Basic API

Given a PyTorch model, e.g. Net(), wrap it in a DmxModel container:

from dmx.compressor.modeling import DmxModel

model = DmxModel.from_torch(Net())

Here model is functionally equivalent to Net(), and all torch functionalities are still available, but model is equipped with d-Matrix specific features, making it ready for co-design configuration and/or optimization, at training time or post-training. See advanced topics for further details.

model.dmx_config is a dictionary that contains all, and only those, configurations that affect the functional behavior of the model, different from the behavior of the original Net(). Use method model.transform() to set these configurations, through application of configuration rules. See advanced topics for engineering of configuration rules.

There are two predefined special rule sets config_rules.BASELINE and config_rules.BASIC; the former is a dummy that does not change the original model's functional behavior, whereas the latter brings the model to a functional state that is equivalent to basic-mode execution on d-Matrix's hardware, e.g.

from dmx.compressor import config_rules
model = model.transform(
    model.dmx_config,
    *config_rules.BASIC,
)

Hugging Face pipeline API

To leverage the popularity of Hugging Face's pipeline API for inference, we extend transformers.pipeline() to dmx.compressor.modeling.hf.pipeline(), which retains all existing functionality of pipelines while enabling model transformation and configuration for deployment on d-Matrix hardware.

from dmx.compressor.modeling.hf import pipeline

pipe = pipeline(
    task="text-generation",
    model="facebook/opt-125m",
    dmx_config="BASIC",  # make the model deployable on d-Matrix backend
    ...
)

# Deploy pipe the same way as Hugging Face provides.

Next steps

For more detailed information, go over the following documents on specific topics. Find more usage examples here.

  • Configurations
  • Numerics
  • Weight sparsity
  • Custom approximation logic

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

dmx_compressor-0.1.9.tar.gz (108.2 kB view details)

Uploaded Source

Built Distribution

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

dmx_compressor-0.1.9-py3-none-any.whl (117.3 kB view details)

Uploaded Python 3

File details

Details for the file dmx_compressor-0.1.9.tar.gz.

File metadata

  • Download URL: dmx_compressor-0.1.9.tar.gz
  • Upload date:
  • Size: 108.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.15 Linux/5.15.0-1057-azure

File hashes

Hashes for dmx_compressor-0.1.9.tar.gz
Algorithm Hash digest
SHA256 b61b3069a7f2e4332053e192b6a18015e3de067b3d7dbb340248a866e59acf3d
MD5 c2449052a6da8fb32ff2cae7d9fa1086
BLAKE2b-256 7bcb2176ad4e7aacf6eec59eec01ae19acbdd32e8d02516ef9bfd0947d53b3bc

See more details on using hashes here.

File details

Details for the file dmx_compressor-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: dmx_compressor-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 117.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.15 Linux/5.15.0-1057-azure

File hashes

Hashes for dmx_compressor-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 bd69febed81a695e18c9ec8870d69fa19da388326c42a7a616396cc3496ed10c
MD5 40f74e12dbc9b1cc31e45a92297e374f
BLAKE2b-256 04dc9687e0ce8fc53b582e0e3dd205e9b34b38db34503bb7fd7b26e8ec9f2457

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