Prequantization utilities (MXFP8 / NVFP4) for Fireworks AI hot-load / incremental snapshot pipelines
Project description
fireworks-prequant
Prequantization utilities used by the Fireworks AI serving/training stack to produce already-quantized model checkpoints (MXFP8 / NVFP4) so that both the upload and the deployment-side download are smaller, and serving loads the packed weights directly instead of converting bf16 on the fly.
The quantization is byte-identical to the Fireworks runtime's on-the-fly
--convert-to-precision (it uses the same flashinfer MXFP8 kernel), so a
prequantized checkpoint serves identically to the bf16 checkpoint + on-the-fly
conversion.
Install
pip install fireworks-prequant[mxfp8] # torch + safetensors + flashinfer
torch and flashinfer are already present in the Fireworks trainer/learner
image, so this is effectively just adding the pure-Python package there.
Quick start
In-memory (the hook the stage-sharded hot-load weight publisher calls on each PP-stage owner's gathered HF state):
from fireworks_prequant import quantize_state_dict
# hf_state: dict[str, torch.Tensor] of one PP stage (bf16 on CPU)
packed = quantize_state_dict(hf_state, fmt="mxfp8", device="cuda")
# expert weights -> {..}.weight (float8_e4m3fn) + {..}.weight_scale_inv (uint8 E8M0)
# non-expert tensors pass through unchanged
Offline (directory of safetensors shards):
from fireworks_prequant import quantize_checkpoint_dir
quantize_checkpoint_dir(
"/path/to/bf16-checkpoint",
"/path/to/mxfp8-checkpoint",
fmt="mxfp8",
num_workers=8,
) # rebuilds the weight index + stamps quantization_config into config.json
Formats
fmt |
Target | Serving precision |
|---|---|---|
mxfp8 |
1x32 block FP8, E8M0 scales | moe=mxfp8 |
nvfp4 |
packed FP4 + FP8 block scales | FP4 |
Only the routed MoE expert projections (model.layers.*.mlp.experts.*.{gate,up,down}_proj.weight,
prefix-tolerant) are quantized; dense/attention/gate/shared-expert weights pass
through in their original dtype — matching the runtime precision policy.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fireworks_prequant-0.1.0.tar.gz.
File metadata
- Download URL: fireworks_prequant-0.1.0.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a27fdd3df1af12e957e0769ae85f444f6be1cd95e0daf6a6cdc434e93f4c4158
|
|
| MD5 |
db40f93f4817457a55d1730d1ee37450
|
|
| BLAKE2b-256 |
1da554d7272282e36565cbd34a40d928bf75d9f4c31bb386f913255434a6eace
|
File details
Details for the file fireworks_prequant-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fireworks_prequant-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54421b32ec0e80895bfa3da3e3e9f60e0bfc0fac0ed0a1d2b0395882cc508c92
|
|
| MD5 |
d948d027dfd63cba738c66ed31eeffa8
|
|
| BLAKE2b-256 |
f34465557ad685b90553aa01944ebb7f280113a5a01720e3c12b81525ae5ade3
|