Skip to main content

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, and is extensible through a plugin architecture.

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

Metadata

Release files for dmx-compressor 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dmx-compressor 0.1.11
File Size Uploaded
dmx_compressor-0.1.11.tar.gz 122.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dmx-compressor 0.1.11
File Interpreter ABI Platform
dmx_compressor-0.1.11-py3-none-any.whl Python 3 none any Details

Total release size: 250.8 kB

Release files / dmx_compressor-0.1.11.tar.gz

Download URL dmx_compressor-0.1.11.tar.gz
Size 122.1 kB
Tags Source
SHA-256 checksum
How to use checksums
901bd45c544b5532786aca8e2b5649d7f2a493ac1276048bbbf4bb6ea4aacf5c
BLAKE2b-256 checksum
How to use checksums
708d6a058b871a058b89b33207c7e606a01bb857931f2827c4cb6a90d2e7a700
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.10.15 Linux/5.15.0-1057-azure

Release files / dmx_compressor-0.1.11-py3-none-any.whl

Download URL dmx_compressor-0.1.11-py3-none-any.whl
Size 128.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
daec5b6a6443e91dbb15d3e6032df65dd9090ce9e7de2918d49142900dda3b5d
BLAKE2b-256 checksum
How to use checksums
2816b5d0a8e03f003151d216cd96b493f624f476517356a9107acfbb0a8fe185
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.10.15 Linux/5.15.0-1057-azure

Release history Release notifications | RSS feed

This release

0.1.11 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page