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.5.tar.gz (11.6 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.5-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: uni_quant_cuda-0.2.5.tar.gz
  • Upload date:
  • Size: 11.6 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.5.tar.gz
Algorithm Hash digest
SHA256 632dcdb541e24c2ea1e62882ef6594a8ed26ffb95e71845a0057f1ddca69322a
MD5 d80bb5559af236396f5186aba031d34f
BLAKE2b-256 15ca9557e5ab02f3e219d440a1a3e816607972b2a4ea17e34ca2437c0164b5a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: uni_quant_cuda-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 7.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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 48563071f266ef5b82ef39c409ab9a35659e1d58153707bbb7b3c044f16665c4
MD5 92dc45234321c44763c31ed7a0d1f209
BLAKE2b-256 b5c0705a1eca21749a77234e33c22bcb28a70f2750f10387cacdfb14a48bd3d0

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