Skip to main content

Uni-Quant: CUDA-accelerated quantization/dequantization for TensorFlow models

Project description

Uni-Quant

Small library to quantize/dequantize TensorFlow models using PyTorch CUDA kernels.

Requirements

  • Python: 3.13.13 (haven't tested on any other)
  • CUDA Toolkit: >=12.8
  • Python Dependencies: All required packages are listed in requirements.txt

Installing Dependencies

pip install -r requirements.txt

Installation from pip

pip install uni-quant-cuda

Usage

Importing Functions

from uniquant import quantize, dequantize, dequantize_save

Main Functions

quantize(model_path, quant_directory="", quant_name="", pack_size=32, quant_size=4, overwrite=False)

Quantizes a TensorFlow or XGBoost model.

Arguments:

  • model_path (str): Path to the model to quantize (with extension)
  • quant_directory (str): Directory path to save the quantized model
  • quant_name (str): Filename for the quantized model
  • pack_size (int): Number of weights in one quantization batch (must be divisible by 2)
  • quant_size (int): Number of bits per weight (available: 4 or 8)
  • overwrite (bool): Whether to overwrite existing file

dequantize(quant_path, literal=False, balanced=True)

Dequantizes a model and returns it.

Arguments:

  • quant_path (str): Path to the .uniq file to dequantize
  • literal (bool): Whether weights should be unscaled
  • balanced (bool): Whether weights should be balanced around 0

dequantize_save(quant_path, model_directory="", model_name="", overwrite=False)

Dequantizes a model, saves it, and returns it.

Arguments:

  • quant_path (str): Path to the .uniq file to dequantize
  • model_directory (str): Directory path to save the dequantized model
  • model_name (str): Filename for the dequantized model
  • overwrite (bool): Whether to overwrite existing file

Notes

  • This package compiles CUDA kernels at runtime using torch.utils.cpp_extension.load_inline.
  • Installing and using the CUDA compilation requires a compatible CUDA toolkit on the target machine (tested with >=12.8).

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

uni_quant_cuda-0.2.7.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

uni_quant_cuda-0.2.7-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file uni_quant_cuda-0.2.7.tar.gz.

File metadata

  • Download URL: uni_quant_cuda-0.2.7.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for uni_quant_cuda-0.2.7.tar.gz
Algorithm Hash digest
SHA256 51469e3da3c5885a140317c98dc96ce1d57606299f387c94de0e874f07a33007
MD5 9fe0a9fe42b76008414b1cecbeaec570
BLAKE2b-256 9f3caaebba135027afd33f98bb4e1a30d1e49f4f66d6267c21cc25bda0867e6c

See more details on using hashes here.

File details

Details for the file uni_quant_cuda-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: uni_quant_cuda-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for uni_quant_cuda-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4378a47c7f7257909779d0ce8306ec6f113e4d5b853b17bcc87aeb2a05b3662a
MD5 b0de21be9f570db1146913d19548e42a
BLAKE2b-256 9689b1b047d334d70b516c641f0bf4ccdaadcc7f9698173db4636176a8647869

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