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

For installed package (from pip):

from Uniquant import quantize, dequantize, dequantize_save

For local clone repo:

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.3.tar.gz (7.7 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.3-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: uni_quant_cuda-0.2.3.tar.gz
  • Upload date:
  • Size: 7.7 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.3.tar.gz
Algorithm Hash digest
SHA256 2386695a38c1d3907a40beca223378cce3b75e0f47bf8abdbb9c91d89eb30c25
MD5 66078f2381be74ddbc1911fc16ab0f48
BLAKE2b-256 afca4f4fd6daf6c78022afa13bf8559ed24c6095667da536f58dc09130a63c26

See more details on using hashes here.

File details

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

File metadata

  • Download URL: uni_quant_cuda-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 2.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 da5d494ff1fb8aaa1581d97d66afe2a4ee65bca395b8d873267cd6a63b3f730d
MD5 b17a500d22343e569af14967efd67f19
BLAKE2b-256 11325e42d04f6d06813f9748da0012374154fd6568387e79e380a670921694d0

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