hip-quant 2.2.4__tar.gz → 2.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hip_quant-2.2.4 → hip_quant-2.3.0}/MANIFEST.in +2 -0
- hip_quant-2.3.0/PKG-INFO +369 -0
- hip_quant-2.3.0/README.md +146 -0
- hip_quant-2.3.0/_C.cp312-win_amd64.pyd +4 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/__init__.py +17 -5
- {hip_quant-2.2.4 → hip_quant-2.3.0}/build.ps1 +17 -1
- {hip_quant-2.2.4 → hip_quant-2.3.0}/device_info.py +12 -4
- hip_quant-2.3.0/hip_quant.egg-info/PKG-INFO +369 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hip_quant.egg-info/SOURCES.txt +24 -0
- hip_quant-2.3.0/hip_quant.egg-info/requires.txt +4 -0
- hip_quant-2.3.0/hip_quantize_rocm101.dll +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/pyproject.toml +3 -7
- {hip_quant-2.2.4 → hip_quant-2.3.0}/setup_torch.py +63 -15
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_aq2.py +9 -6
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_compat.py +64 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_fused_ssm_prefill.py +141 -137
- hip_quant-2.3.0/tests/test_gemv_kquants.py +71 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_iq2s_iq1m_byte_exact.py +13 -8
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_pipeline.py +1151 -1136
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_prefill_with_lse.py +14 -1
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_qol.py +7 -3
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_v8.py +6 -2
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_wave_prefill_gqa.py +13 -3
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_wmma_layout.py +6 -2
- hip_quant-2.3.0/tests/torch/test_lfm2_native_ops.py +277 -0
- hip_quant-2.3.0/tests/torch/test_w4a4_gemv.py +87 -0
- hip_quant-2.3.0/tests/torch/test_wave_attn_swa.py +92 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_wave_attn_train_bf16.py +73 -5
- hip_quant-2.3.0/tools/.gpu-smi-version +1 -0
- hip_quant-2.3.0/tools/gpu-smi.exe +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_api.py +1510 -1450
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/decode_quant_kernels.hip +241 -240
- hip_quant-2.3.0/torch_ext/flint_decode.h +76 -0
- hip_quant-2.3.0/torch_ext/flint_inference.hip +708 -0
- hip_quant-2.3.0/torch_ext/flint_wave_prefill.h +190 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/hqnat_grouped_integer.hip +103 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/int4_wmma_kernels.hip +93 -0
- hip_quant-2.3.0/torch_ext/lfm2_moe_int4_prefill.hip +355 -0
- hip_quant-2.3.0/torch_ext/lfm2_moe_int8_pc.hip +447 -0
- hip_quant-2.3.0/torch_ext/lfm2_moe_int8_wmma.hip +569 -0
- hip_quant-2.3.0/torch_ext/lfm2_token_int8.hip +147 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/pytorch_bindings.cpp +653 -16
- hip_quant-2.3.0/torch_ext/runtime_elementwise.hip +81 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/ssm_kernels.hip +485 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wave_attn_backward_bf16.hip +55 -16
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wave_attn_backward_f16.hip +10 -1
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wave_attn_bf16.hip +63 -36
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wave_attn_decode.hip +66 -31
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wave_attn_prefill.hip +20 -10
- hip_quant-2.2.4/PKG-INFO +0 -1433
- hip_quant-2.2.4/README.md +0 -1208
- hip_quant-2.2.4/_C.cp312-win_amd64.pyd +0 -4
- hip_quant-2.2.4/hip_quant.egg-info/PKG-INFO +0 -1433
- hip_quant-2.2.4/hip_quant.egg-info/requires.txt +0 -7
- hip_quant-2.2.4/tests/test_gemv_kquants.py +0 -69
- hip_quant-2.2.4/tools/.gpu-smi-version +0 -1
- hip_quant-2.2.4/tools/gpu-smi.exe +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/DOCUMENTATION.md +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/LICENSE +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/__main__.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/bench_mxfp8.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/bench_wave_attn_inference.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/build.sh +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/cdna_compat.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/codebooks/iq1_s.bin +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/codebooks/iq2_s.bin +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/codebooks/iq2_xs.bin +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/codebooks/iq2_xxs.bin +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/codebooks/iq3_s.bin +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/codebooks/iq3_xxs.bin +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/demo.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/diagnose_fp8_crash.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/e2e_iq2s_iq1m.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/get_hf_tensors.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/gguf.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/gguf_loader.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hip_iquant_util.h +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hip_quant.egg-info/dependency_links.txt +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hip_quant.egg-info/entry_points.txt +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hip_quant.egg-info/not-zip-safe +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hip_quant.egg-info/top_level.txt +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hip_quant_types.h +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hip_quant_util.h +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hip_quantize.cpp +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hip_quantize.dll +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hip_quantize_rocm721.dll +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/__init__.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/__main__.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/analyzer.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/api.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/archive.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/backends.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/format.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/hq3.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/hq8.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/mixed_policy.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/raw.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/safetensors_numpy.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/sensitivity.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/torch_inference.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/hq2/transformers_loader.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/dequant_to_fp8.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/direct_fp8_quant.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/fp8_expand.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/fp8_gemm_test.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_aq2.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_bf16.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_f8_e4m3.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_f8_e5m2.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_hq2.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_iq1_m.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_iq1_s.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_iq2_s.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_iq2_xs.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_iq2_xxs.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_iq3_s.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_iq3_xxs.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_iq4_nl.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_iq4_xs.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q1_0.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q2_0.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q2_K.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q3_K.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q4_0.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q4_1.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q4_K.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q5_0.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q5_1.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q5_K.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q6_K.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q8_0.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q8_1.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_q8_K.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_tq1_0.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/quant_tq2_0.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/kernels/wmma_diag.cu +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/setup.cfg +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/setup.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/smi.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/__init__.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/bench_attn_compare.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/bench_iq2s_variants.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/bench_wave_prefill.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/debug_conv1d.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_bf16_numpy.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_dequant_fp8.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_direct_fp8_quant.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_ffn_layer.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_hq2.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_hq2_portable.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_hq8_g128.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_iquant_parallel.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_lazy_torch_import.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_mixed_policy.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_mixed_sensitivity.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_mxfp4_compat.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_mxfp4_native_contract.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_mxfp8_numerical.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_patch_hq_mixed_archive.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_q_to_fp8_gpu.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_safetensors_numpy.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_ssm_heads_generic.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_wave_attn_decode_hybrid.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/test_wmma_diag.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/bench_compare.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/bench_fp8.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/conftest.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_fp8.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_fp8_v2.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_hip_graph.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_mxfp4_native_contract_torch.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_mxfp4_to_fp8_torch.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_mxfp8_torch.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_q_to_fp8_torch.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_quant_transpose.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_wave_attn_backward_math.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_wave_attn_f16.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_wave_attn_f16_extreme.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/torch/test_wave_helpers_cpu.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tests/verify_fused_fp8_linear.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tools/fetch_gpu_smi.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tools/mlp_codec/analyze.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tools/mlp_codec/clean_wikitext.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tools/mlp_codec/collect_hessians.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tools/mlp_codec/hq2_bridge.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tools/mlp_codec/hq2v.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tools/mlp_codec/ldlq.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tools/mlp_codec/ledger.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tools/mlp_codec/run_ladder.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tools/mlp_codec/safe_run.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/tools/mlp_codec/validate_hessians.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/current_stream.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/dequant_q_to_fp16.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/fp8_linear_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/fp8_linear_kernels_v2.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/fp8_quant_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/gemv_q_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/hq2_linear_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/hq3_linear_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/hq8_g128_linear_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/int3_g32_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/int5_g32_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/int6_g32_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/iq_grid_tables.h +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/kv_iu4_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/lfm2_moe_int3_wmma.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/mxfp4_to_fp8_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/mxfp8_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/ple_io.cpp +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/ple_io.h +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/pytorch_bindings_hip.cpp +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/q_to_fp8_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/qad_scale_gradient.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/ternary_gemv_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/w4a16_gemv_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wave_attn.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wave_attn_backward.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wave_attn_backward_mx.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wave_attn_common.h +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wave_attn_diag.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wave_attn_f16.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wave_attn_long.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/torch_ext/wht_kernels.hip +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/wave_attn_train_strided_triton.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/wave_attn_train_triton.py +0 -0
- {hip_quant-2.2.4 → hip_quant-2.3.0}/wave_helpers.py +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
include hip_quantize.dll
|
|
2
2
|
include hip_quantize_rocm721.dll
|
|
3
|
+
include hip_quantize_rocm101.dll
|
|
3
4
|
include _C.cp312-win_amd64.pyd
|
|
4
5
|
include hip_quant_types.h
|
|
5
6
|
include hip_quant_util.h
|
|
@@ -12,6 +13,7 @@ recursive-include torch_ext *.cpp *.hip *.h
|
|
|
12
13
|
exclude torch_ext/ple_directstorage.cpp
|
|
13
14
|
exclude torch_ext/ple_directstorage.h
|
|
14
15
|
exclude torch_ext/ple_directstorage_hip.hip
|
|
16
|
+
exclude torch_ext/qad_ggml_tq1.hip
|
|
15
17
|
recursive-include tests *.py
|
|
16
18
|
recursive-include codebooks *.bin
|
|
17
19
|
include torch_api.py
|
hip_quant-2.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hip-quant
|
|
3
|
+
Version: 2.3.0
|
|
4
|
+
Summary: High-performance GPU tensor quantization and inference engine for AMD ROCm. Native AOT GEMV (K-Quants & I-Quants), State Space Model (SSM/DeltaNet) kernels, FP8 WMMA WaveAttention, and portable HIP C++ kernels for RDNA4, RDNA3, and CDNA.
|
|
5
|
+
Author-email: Thenukegun10x <conormorris84@gmail.com>
|
|
6
|
+
License: Apache License
|
|
7
|
+
Version 2.0, January 2004
|
|
8
|
+
http://www.apache.org/licenses/
|
|
9
|
+
|
|
10
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
11
|
+
|
|
12
|
+
1. Definitions.
|
|
13
|
+
|
|
14
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
15
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
16
|
+
|
|
17
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
18
|
+
the copyright owner that is granting the License.
|
|
19
|
+
|
|
20
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
21
|
+
other entities that control, are controlled by, or are under common
|
|
22
|
+
control with that entity. For the purposes of this definition,
|
|
23
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
24
|
+
direction or management of such entity, whether by contract or
|
|
25
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
26
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
27
|
+
|
|
28
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
29
|
+
exercising permissions granted by this License.
|
|
30
|
+
|
|
31
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
32
|
+
including but not limited to software source code, documentation
|
|
33
|
+
source, and configuration files.
|
|
34
|
+
|
|
35
|
+
"Object" form shall mean any form resulting from mechanical
|
|
36
|
+
transformation or translation of a Source form, including but
|
|
37
|
+
not limited to compiled object code, generated documentation,
|
|
38
|
+
and conversions to other media types.
|
|
39
|
+
|
|
40
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
41
|
+
Object form, made available under the License, as indicated by a
|
|
42
|
+
copyright notice that is included in or attached to the work
|
|
43
|
+
(an example is provided in the Appendix below).
|
|
44
|
+
|
|
45
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
46
|
+
form, that is based on (or derived from) the Work and for which the
|
|
47
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
48
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
49
|
+
of this License, Derivative Works shall not include works that remain
|
|
50
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
51
|
+
the Work and Derivative Works thereof.
|
|
52
|
+
|
|
53
|
+
"Contribution" shall mean any work of authorship, including
|
|
54
|
+
the original version of the Work and any modifications or additions
|
|
55
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
56
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
57
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
58
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
59
|
+
means any form of electronic, verbal, or written communication sent
|
|
60
|
+
to the Licensor or its representatives, including but not limited to
|
|
61
|
+
communication on electronic mailing lists, source code control systems,
|
|
62
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
63
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
64
|
+
excluding communication that is conspicuously marked or otherwise
|
|
65
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
66
|
+
|
|
67
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
68
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
69
|
+
subsequently incorporated within the Work.
|
|
70
|
+
|
|
71
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
72
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
73
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
74
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
75
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
76
|
+
Work and such Derivative Works in Source or Object form.
|
|
77
|
+
|
|
78
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
79
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
80
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
81
|
+
(except as stated in this section) patent license to make, have made,
|
|
82
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
83
|
+
where such license applies only to those patent claims licensable
|
|
84
|
+
by such Contributor that are necessarily infringed by their
|
|
85
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
86
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
87
|
+
institute patent litigation against any entity (including a
|
|
88
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
89
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
90
|
+
or contributory patent infringement, then any patent licenses
|
|
91
|
+
granted to You under this License for that Work shall terminate
|
|
92
|
+
as of the date such litigation is filed.
|
|
93
|
+
|
|
94
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
95
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
96
|
+
modifications, and in Source or Object form, provided that You
|
|
97
|
+
meet the following conditions:
|
|
98
|
+
|
|
99
|
+
(a) You must give any other recipients of the Work or
|
|
100
|
+
Derivative Works a copy of this License; and
|
|
101
|
+
|
|
102
|
+
(b) You must cause any modified files to carry prominent notices
|
|
103
|
+
stating that You changed the files; and
|
|
104
|
+
|
|
105
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
106
|
+
that You distribute, all copyright, patent, trademark, and
|
|
107
|
+
attribution notices from the Source form of the Work,
|
|
108
|
+
excluding those notices that do not pertain to any part of
|
|
109
|
+
the Derivative Works; and
|
|
110
|
+
|
|
111
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
112
|
+
distribution, then any Derivative Works that You distribute must
|
|
113
|
+
include a readable copy of the attribution notices contained
|
|
114
|
+
within such NOTICE file, excluding those notices that do not
|
|
115
|
+
pertain to any part of the Derivative Works, in at least one
|
|
116
|
+
of the following places: within a NOTICE text file distributed
|
|
117
|
+
as part of the Derivative Works; within the Source form or
|
|
118
|
+
documentation, if provided along with the Derivative Works; or,
|
|
119
|
+
within a display generated by the Derivative Works, if and
|
|
120
|
+
wherever such third-party notices normally appear. The contents
|
|
121
|
+
of the NOTICE file are for informational purposes only and
|
|
122
|
+
do not modify the License. You may add Your own attribution
|
|
123
|
+
notices within Derivative Works that You distribute, alongside
|
|
124
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
125
|
+
that such additional attribution notices cannot be construed
|
|
126
|
+
as modifying the License.
|
|
127
|
+
|
|
128
|
+
You may add Your own copyright statement to Your modifications and
|
|
129
|
+
may provide additional or different license terms and conditions
|
|
130
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
131
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
132
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
133
|
+
the conditions stated in this License.
|
|
134
|
+
|
|
135
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
136
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
137
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
138
|
+
this License, without any additional terms or conditions.
|
|
139
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
140
|
+
the terms of any separate license agreement you may have executed
|
|
141
|
+
with Licensor regarding such Contributions.
|
|
142
|
+
|
|
143
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
144
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
145
|
+
except as required for reasonable and customary use in describing the
|
|
146
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
147
|
+
|
|
148
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
149
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
150
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
151
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
152
|
+
implied, including, without limitation, any warranties or conditions
|
|
153
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
154
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
155
|
+
appropriateness of using or redistributing the Work and assume any
|
|
156
|
+
risks associated with Your exercise of permissions under this License.
|
|
157
|
+
|
|
158
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
159
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
160
|
+
unless required by applicable law (such as deliberate and grossly
|
|
161
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
162
|
+
liable to You for damages, including any direct, indirect, special,
|
|
163
|
+
incidental, or consequential damages of any character arising as a
|
|
164
|
+
result of this License or out of the use or inability to use the
|
|
165
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
166
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
167
|
+
other commercial damages or losses), even if such Contributor
|
|
168
|
+
has been advised of the possibility of such damages.
|
|
169
|
+
|
|
170
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
171
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
172
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
173
|
+
or other liability obligations and/or rights consistent with this
|
|
174
|
+
License. However, in accepting such obligations, You may act only
|
|
175
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
176
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
177
|
+
defend, and hold each Contributor harmless for any liability
|
|
178
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
179
|
+
of your accepting any such warranty or additional liability.
|
|
180
|
+
|
|
181
|
+
END OF TERMS AND CONDITIONS
|
|
182
|
+
|
|
183
|
+
Copyright 2026 Thenukegun10x
|
|
184
|
+
|
|
185
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
186
|
+
you may not use this file except in compliance with the License.
|
|
187
|
+
You may obtain a copy of the License at
|
|
188
|
+
|
|
189
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
190
|
+
|
|
191
|
+
Unless required by applicable law or agreed to in writing, software
|
|
192
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
193
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
194
|
+
See the License for the specific language governing permissions and
|
|
195
|
+
limitations under the License.
|
|
196
|
+
Project-URL: Homepage, https://github.com/Thenukegun10x/HIP-Quant
|
|
197
|
+
Project-URL: Documentation, https://github.com/Thenukegun10x/HIP-Quant/blob/main/README.md
|
|
198
|
+
Project-URL: Source, https://github.com/Thenukegun10x/HIP-Quant
|
|
199
|
+
Project-URL: Issues, https://github.com/Thenukegun10x/HIP-Quant/issues
|
|
200
|
+
Keywords: quantization,gpu,hip,rocm,amd,fp8,wmma,attention,pytorch,ggml
|
|
201
|
+
Classifier: Development Status :: 4 - Beta
|
|
202
|
+
Classifier: Intended Audience :: Developers
|
|
203
|
+
Classifier: Intended Audience :: Science/Research
|
|
204
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
205
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
206
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
207
|
+
Classifier: Programming Language :: Python :: 3
|
|
208
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
209
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
210
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
211
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
212
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
213
|
+
Classifier: Programming Language :: C++
|
|
214
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
215
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
216
|
+
Requires-Python: >=3.8
|
|
217
|
+
Description-Content-Type: text/markdown
|
|
218
|
+
License-File: LICENSE
|
|
219
|
+
Requires-Dist: numpy
|
|
220
|
+
Provides-Extra: torch
|
|
221
|
+
Requires-Dist: torch>=2.0; extra == "torch"
|
|
222
|
+
Dynamic: license-file
|
|
223
|
+
|
|
224
|
+
# hip-quant
|
|
225
|
+
|
|
226
|
+
`hip-quant` is a Python library and native HIP kernel suite for AMD GPUs. It
|
|
227
|
+
provides GGML-compatible quantization through a NumPy/ctypes API, plus a PyTorch
|
|
228
|
+
extension for GPU-resident quantization, matrix operations, attention, and
|
|
229
|
+
state-space kernels. It is a kernel and tensor library—not a complete chat or
|
|
230
|
+
model-serving application.
|
|
231
|
+
|
|
232
|
+
## What is included
|
|
233
|
+
|
|
234
|
+
### Quantization and low-bit formats
|
|
235
|
+
|
|
236
|
+
The NumPy API packs floating-point arrays into formats used by GGUF and related
|
|
237
|
+
workflows, and can dequantize packed data to floating point. Supported format
|
|
238
|
+
families include:
|
|
239
|
+
|
|
240
|
+
- **Legacy formats:** `Q1_0`, `Q2_0`, `Q4_0`, `Q4_1`, `Q5_0`, `Q5_1`, `Q8_0`,
|
|
241
|
+
and `Q8_1`.
|
|
242
|
+
- **K-quants:** `Q2_K` through `Q6_K`, plus `Q8_K`.
|
|
243
|
+
- **I-quants:** `IQ1_S`, `IQ1_M`, `IQ2_XXS`, `IQ2_XS`, `IQ2_S`, `IQ3_XXS`,
|
|
244
|
+
`IQ3_S`, `IQ4_NL`, and `IQ4_XS`.
|
|
245
|
+
- **Ternary formats:** `TQ1_0` and `TQ2_0`.
|
|
246
|
+
- **Experimental codecs:** HQ2 and AQ2 variants in the GGML-facing API; the
|
|
247
|
+
separate `hq2` package also provides learned-codebook HQ2/HQ3/HQ8 tools.
|
|
248
|
+
|
|
249
|
+
Importance-matrix weighting is supported for applicable quantizers. The API
|
|
250
|
+
accepts a full matrix or a shared per-column vector where supported. Format
|
|
251
|
+
availability and options differ between the NumPy and PyTorch APIs; see
|
|
252
|
+
`GGML_TYPE` and the API modules for the precise interface.
|
|
253
|
+
|
|
254
|
+
### PyTorch and native GPU kernels
|
|
255
|
+
|
|
256
|
+
The optional PyTorch extension exposes lower-level operators for building
|
|
257
|
+
GPU-resident inference and training paths, including:
|
|
258
|
+
|
|
259
|
+
- **FP8 and microscaling:** E4M3/E5M2 quantize/dequantize, transpose and
|
|
260
|
+
block-scaled conversions, scaling metadata helpers, MXFP8 operations, and
|
|
261
|
+
FP8 linear/GEMM paths where supported.
|
|
262
|
+
- **Quantized linear and decode:** selected GGUF-format GEMV kernels, embedding
|
|
263
|
+
lookup with on-the-fly dequantization, packed INT4 helpers, and FP8 weight or
|
|
264
|
+
activation paths.
|
|
265
|
+
- **WaveAttention:** GFX12 FP8 WMMA prefill and decode, grouped-query attention,
|
|
266
|
+
optional sliding windows, long-context helpers, and packed INT4 KV data paths.
|
|
267
|
+
Native FP8, FP16, and BF16 training forward/backward paths are also exposed;
|
|
268
|
+
the FP16/BF16 paths are experimental. Use `precision="sdpa"` to select
|
|
269
|
+
PyTorch SDPA in the training wrapper.
|
|
270
|
+
- **SSM / DeltaNet building blocks:** recurrent state updates, causal Conv1D,
|
|
271
|
+
gated RMSNorm, and related helpers for hybrid Transformer/SSM models.
|
|
272
|
+
- **Runtime utilities:** HIP graph-capture helpers, GPU/device information,
|
|
273
|
+
safety checks on extension inputs, and the bundled `gpu-smi` monitor.
|
|
274
|
+
|
|
275
|
+
These operators are intended to be composed into higher-level applications.
|
|
276
|
+
For a model runner and CLI, see the separate `hip_inference` project.
|
|
277
|
+
|
|
278
|
+
## Hardware and status
|
|
279
|
+
|
|
280
|
+
The default PyTorch extension build targets `gfx90a`, `gfx942`, `gfx1100`–
|
|
281
|
+
`gfx1103`, `gfx1200`, and `gfx1201`. GFX12 WMMA kernels require `gfx1200` or
|
|
282
|
+
`gfx1201`; the RX 9070 XT (`gfx1201`) is the primary runtime-validation GPU.
|
|
283
|
+
The RX 9070 is also `gfx1201`. A build target does not guarantee that every
|
|
284
|
+
operator is available or validated on every GPU—support depends on the API,
|
|
285
|
+
kernel, and architecture.
|
|
286
|
+
|
|
287
|
+
The current `gfx1201` PyTorch target is AMD's Python 3.12 stack with
|
|
288
|
+
`torch==2.14.0+rocm10.1.0`. The PyTorch extension is ABI-specific: it must be
|
|
289
|
+
built for the same PyTorch/ROCm stack used at runtime. Do not load an extension
|
|
290
|
+
from a different Torch or ROCm build. Native training kernels and experimental
|
|
291
|
+
codecs may change; validate accuracy, performance, and memory use for your
|
|
292
|
+
model and workload.
|
|
293
|
+
|
|
294
|
+
## Install and build
|
|
295
|
+
|
|
296
|
+
Create a Python 3.12 environment and install AMD's `gfx1201` PyTorch wheel:
|
|
297
|
+
|
|
298
|
+
```powershell
|
|
299
|
+
py -3.12 -m venv .venv
|
|
300
|
+
.\.venv\Scripts\Activate.ps1
|
|
301
|
+
python -m pip install --upgrade pip
|
|
302
|
+
python -m pip install --index-url https://stable.repo.amd.com/rocm/whl-next/ `
|
|
303
|
+
"torch[device-gfx1201]==2.14.0+rocm10.1.0"
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
From an x64 Visual Studio developer shell with the matching ROCm toolchain,
|
|
307
|
+
install the package and build its PyTorch extension:
|
|
308
|
+
|
|
309
|
+
```powershell
|
|
310
|
+
python -m pip install -e ".[torch]"
|
|
311
|
+
python setup_torch.py build_ext --inplace
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
The NumPy/ctypes API uses the packaged HIP DLL and can be used independently of
|
|
315
|
+
the PyTorch extension. On Windows the ROCm 10.1 DLL is preferred, with older
|
|
316
|
+
DLLs retained as fallbacks. A compatible ROCm runtime is still required for the
|
|
317
|
+
native HIP quantization path. See `build.ps1` for the DLL build entry point.
|
|
318
|
+
|
|
319
|
+
## Quick start
|
|
320
|
+
|
|
321
|
+
Quantize a NumPy matrix to Q4_K:
|
|
322
|
+
|
|
323
|
+
```python
|
|
324
|
+
import numpy as np
|
|
325
|
+
from hip_quant import GGML_TYPE, quantize
|
|
326
|
+
|
|
327
|
+
weights = np.random.randn(4096, 4096).astype(np.float32)
|
|
328
|
+
packed = quantize(weights, GGML_TYPE["Q4_K"])
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Convert a device tensor to FP8 E4M3 bytes with the PyTorch extension:
|
|
332
|
+
|
|
333
|
+
```python
|
|
334
|
+
import torch
|
|
335
|
+
from hip_quant import torch_api
|
|
336
|
+
|
|
337
|
+
x = torch.randn(1024, 1024, device="cuda", dtype=torch.bfloat16)
|
|
338
|
+
x_fp8 = torch_api.quantize_e4m3(x)
|
|
339
|
+
x_roundtrip = torch_api.dequantize_e4m3(x_fp8)
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
The command-line utility can list formats, inspect device/build availability,
|
|
343
|
+
and quantize `.npy` arrays:
|
|
344
|
+
|
|
345
|
+
```powershell
|
|
346
|
+
hip-quant --list-types
|
|
347
|
+
hip-quant --info
|
|
348
|
+
hip-quant weights.npy weights-q4k.bin --type Q4_K
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Tests
|
|
352
|
+
|
|
353
|
+
Run the CPU-safe pipeline tests with:
|
|
354
|
+
|
|
355
|
+
```powershell
|
|
356
|
+
python -m pytest tests/test_pipeline.py -q
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
GPU tests require a working extension built for the active PyTorch/ROCm ABI.
|
|
360
|
+
GFX12 WMMA tests are opt-in with `HIP_QUANT_ENABLE_GFX12_WMMA=1`.
|
|
361
|
+
|
|
362
|
+
## Documentation
|
|
363
|
+
|
|
364
|
+
- [NumPy package API](__init__.py)
|
|
365
|
+
- [PyTorch API](torch_api.py)
|
|
366
|
+
- [GGML type IDs and CLI](__main__.py)
|
|
367
|
+
- [GitHub Releases](https://github.com/Thenukegun10x/HIP-Quant/releases) for
|
|
368
|
+
version-specific changes
|
|
369
|
+
- [Apache-2.0 license](LICENSE)
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# hip-quant
|
|
2
|
+
|
|
3
|
+
`hip-quant` is a Python library and native HIP kernel suite for AMD GPUs. It
|
|
4
|
+
provides GGML-compatible quantization through a NumPy/ctypes API, plus a PyTorch
|
|
5
|
+
extension for GPU-resident quantization, matrix operations, attention, and
|
|
6
|
+
state-space kernels. It is a kernel and tensor library—not a complete chat or
|
|
7
|
+
model-serving application.
|
|
8
|
+
|
|
9
|
+
## What is included
|
|
10
|
+
|
|
11
|
+
### Quantization and low-bit formats
|
|
12
|
+
|
|
13
|
+
The NumPy API packs floating-point arrays into formats used by GGUF and related
|
|
14
|
+
workflows, and can dequantize packed data to floating point. Supported format
|
|
15
|
+
families include:
|
|
16
|
+
|
|
17
|
+
- **Legacy formats:** `Q1_0`, `Q2_0`, `Q4_0`, `Q4_1`, `Q5_0`, `Q5_1`, `Q8_0`,
|
|
18
|
+
and `Q8_1`.
|
|
19
|
+
- **K-quants:** `Q2_K` through `Q6_K`, plus `Q8_K`.
|
|
20
|
+
- **I-quants:** `IQ1_S`, `IQ1_M`, `IQ2_XXS`, `IQ2_XS`, `IQ2_S`, `IQ3_XXS`,
|
|
21
|
+
`IQ3_S`, `IQ4_NL`, and `IQ4_XS`.
|
|
22
|
+
- **Ternary formats:** `TQ1_0` and `TQ2_0`.
|
|
23
|
+
- **Experimental codecs:** HQ2 and AQ2 variants in the GGML-facing API; the
|
|
24
|
+
separate `hq2` package also provides learned-codebook HQ2/HQ3/HQ8 tools.
|
|
25
|
+
|
|
26
|
+
Importance-matrix weighting is supported for applicable quantizers. The API
|
|
27
|
+
accepts a full matrix or a shared per-column vector where supported. Format
|
|
28
|
+
availability and options differ between the NumPy and PyTorch APIs; see
|
|
29
|
+
`GGML_TYPE` and the API modules for the precise interface.
|
|
30
|
+
|
|
31
|
+
### PyTorch and native GPU kernels
|
|
32
|
+
|
|
33
|
+
The optional PyTorch extension exposes lower-level operators for building
|
|
34
|
+
GPU-resident inference and training paths, including:
|
|
35
|
+
|
|
36
|
+
- **FP8 and microscaling:** E4M3/E5M2 quantize/dequantize, transpose and
|
|
37
|
+
block-scaled conversions, scaling metadata helpers, MXFP8 operations, and
|
|
38
|
+
FP8 linear/GEMM paths where supported.
|
|
39
|
+
- **Quantized linear and decode:** selected GGUF-format GEMV kernels, embedding
|
|
40
|
+
lookup with on-the-fly dequantization, packed INT4 helpers, and FP8 weight or
|
|
41
|
+
activation paths.
|
|
42
|
+
- **WaveAttention:** GFX12 FP8 WMMA prefill and decode, grouped-query attention,
|
|
43
|
+
optional sliding windows, long-context helpers, and packed INT4 KV data paths.
|
|
44
|
+
Native FP8, FP16, and BF16 training forward/backward paths are also exposed;
|
|
45
|
+
the FP16/BF16 paths are experimental. Use `precision="sdpa"` to select
|
|
46
|
+
PyTorch SDPA in the training wrapper.
|
|
47
|
+
- **SSM / DeltaNet building blocks:** recurrent state updates, causal Conv1D,
|
|
48
|
+
gated RMSNorm, and related helpers for hybrid Transformer/SSM models.
|
|
49
|
+
- **Runtime utilities:** HIP graph-capture helpers, GPU/device information,
|
|
50
|
+
safety checks on extension inputs, and the bundled `gpu-smi` monitor.
|
|
51
|
+
|
|
52
|
+
These operators are intended to be composed into higher-level applications.
|
|
53
|
+
For a model runner and CLI, see the separate `hip_inference` project.
|
|
54
|
+
|
|
55
|
+
## Hardware and status
|
|
56
|
+
|
|
57
|
+
The default PyTorch extension build targets `gfx90a`, `gfx942`, `gfx1100`–
|
|
58
|
+
`gfx1103`, `gfx1200`, and `gfx1201`. GFX12 WMMA kernels require `gfx1200` or
|
|
59
|
+
`gfx1201`; the RX 9070 XT (`gfx1201`) is the primary runtime-validation GPU.
|
|
60
|
+
The RX 9070 is also `gfx1201`. A build target does not guarantee that every
|
|
61
|
+
operator is available or validated on every GPU—support depends on the API,
|
|
62
|
+
kernel, and architecture.
|
|
63
|
+
|
|
64
|
+
The current `gfx1201` PyTorch target is AMD's Python 3.12 stack with
|
|
65
|
+
`torch==2.14.0+rocm10.1.0`. The PyTorch extension is ABI-specific: it must be
|
|
66
|
+
built for the same PyTorch/ROCm stack used at runtime. Do not load an extension
|
|
67
|
+
from a different Torch or ROCm build. Native training kernels and experimental
|
|
68
|
+
codecs may change; validate accuracy, performance, and memory use for your
|
|
69
|
+
model and workload.
|
|
70
|
+
|
|
71
|
+
## Install and build
|
|
72
|
+
|
|
73
|
+
Create a Python 3.12 environment and install AMD's `gfx1201` PyTorch wheel:
|
|
74
|
+
|
|
75
|
+
```powershell
|
|
76
|
+
py -3.12 -m venv .venv
|
|
77
|
+
.\.venv\Scripts\Activate.ps1
|
|
78
|
+
python -m pip install --upgrade pip
|
|
79
|
+
python -m pip install --index-url https://stable.repo.amd.com/rocm/whl-next/ `
|
|
80
|
+
"torch[device-gfx1201]==2.14.0+rocm10.1.0"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
From an x64 Visual Studio developer shell with the matching ROCm toolchain,
|
|
84
|
+
install the package and build its PyTorch extension:
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
python -m pip install -e ".[torch]"
|
|
88
|
+
python setup_torch.py build_ext --inplace
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The NumPy/ctypes API uses the packaged HIP DLL and can be used independently of
|
|
92
|
+
the PyTorch extension. On Windows the ROCm 10.1 DLL is preferred, with older
|
|
93
|
+
DLLs retained as fallbacks. A compatible ROCm runtime is still required for the
|
|
94
|
+
native HIP quantization path. See `build.ps1` for the DLL build entry point.
|
|
95
|
+
|
|
96
|
+
## Quick start
|
|
97
|
+
|
|
98
|
+
Quantize a NumPy matrix to Q4_K:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
import numpy as np
|
|
102
|
+
from hip_quant import GGML_TYPE, quantize
|
|
103
|
+
|
|
104
|
+
weights = np.random.randn(4096, 4096).astype(np.float32)
|
|
105
|
+
packed = quantize(weights, GGML_TYPE["Q4_K"])
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Convert a device tensor to FP8 E4M3 bytes with the PyTorch extension:
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
import torch
|
|
112
|
+
from hip_quant import torch_api
|
|
113
|
+
|
|
114
|
+
x = torch.randn(1024, 1024, device="cuda", dtype=torch.bfloat16)
|
|
115
|
+
x_fp8 = torch_api.quantize_e4m3(x)
|
|
116
|
+
x_roundtrip = torch_api.dequantize_e4m3(x_fp8)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The command-line utility can list formats, inspect device/build availability,
|
|
120
|
+
and quantize `.npy` arrays:
|
|
121
|
+
|
|
122
|
+
```powershell
|
|
123
|
+
hip-quant --list-types
|
|
124
|
+
hip-quant --info
|
|
125
|
+
hip-quant weights.npy weights-q4k.bin --type Q4_K
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Tests
|
|
129
|
+
|
|
130
|
+
Run the CPU-safe pipeline tests with:
|
|
131
|
+
|
|
132
|
+
```powershell
|
|
133
|
+
python -m pytest tests/test_pipeline.py -q
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
GPU tests require a working extension built for the active PyTorch/ROCm ABI.
|
|
137
|
+
GFX12 WMMA tests are opt-in with `HIP_QUANT_ENABLE_GFX12_WMMA=1`.
|
|
138
|
+
|
|
139
|
+
## Documentation
|
|
140
|
+
|
|
141
|
+
- [NumPy package API](__init__.py)
|
|
142
|
+
- [PyTorch API](torch_api.py)
|
|
143
|
+
- [GGML type IDs and CLI](__main__.py)
|
|
144
|
+
- [GitHub Releases](https://github.com/Thenukegun10x/HIP-Quant/releases) for
|
|
145
|
+
version-specific changes
|
|
146
|
+
- [Apache-2.0 license](LICENSE)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import ctypes
|
|
2
|
+
import glob
|
|
2
3
|
import numpy as np
|
|
3
4
|
import os
|
|
4
5
|
import sys
|
|
5
6
|
import warnings
|
|
6
7
|
|
|
7
|
-
__version__ = "2.
|
|
8
|
+
__version__ = "2.3.0"
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
_TORCH_EXPORTS = {
|
|
@@ -329,7 +330,12 @@ def _add_runtime_dll_dirs():
|
|
|
329
330
|
if path in seen or not os.path.isdir(path):
|
|
330
331
|
continue
|
|
331
332
|
seen.add(path)
|
|
332
|
-
|
|
333
|
+
try:
|
|
334
|
+
_DLL_DIR_HANDLES.append(os.add_dll_directory(path))
|
|
335
|
+
except OSError:
|
|
336
|
+
# These directories are optional search paths. A stale global
|
|
337
|
+
# HIP_PATH must not prevent loading from the active Torch runtime.
|
|
338
|
+
continue
|
|
333
339
|
|
|
334
340
|
def _shared_library_candidates():
|
|
335
341
|
env_dll = os.environ.get("HIP_QUANT_DLL") or os.environ.get("HIP_QUANT_DLL_PATH")
|
|
@@ -343,9 +349,15 @@ def _shared_library_candidates():
|
|
|
343
349
|
)
|
|
344
350
|
yield env_dll
|
|
345
351
|
|
|
346
|
-
|
|
347
|
-
if
|
|
348
|
-
|
|
352
|
+
variant = os.environ.get("HIP_QUANT_DLL_VARIANT", "").lower()
|
|
353
|
+
if variant in ("7.1", "71", "rocm71", "legacy"):
|
|
354
|
+
# Preserve access to the unversioned legacy DLL when explicitly asked.
|
|
355
|
+
win_names = ["hip_quantize.dll", "hip_quantize_rocm721.dll", "hip_quantize_rocm101.dll"]
|
|
356
|
+
elif variant in ("7.2.1", "721", "rocm721"):
|
|
357
|
+
win_names = ["hip_quantize_rocm721.dll", "hip_quantize_rocm101.dll", "hip_quantize.dll"]
|
|
358
|
+
else:
|
|
359
|
+
# The 10.1 build is the release default; older DLLs remain fallbacks.
|
|
360
|
+
win_names = ["hip_quantize_rocm101.dll", "hip_quantize_rocm721.dll", "hip_quantize.dll"]
|
|
349
361
|
names = win_names if os.name == "nt" else ["libhip_quantize.so"]
|
|
350
362
|
roots = [
|
|
351
363
|
_PKG_DIR,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
param(
|
|
2
|
-
[string]$Output = "
|
|
2
|
+
[string]$Output = "hip_quantize_rocm101.dll",
|
|
3
3
|
[switch]$CDNA,
|
|
4
4
|
[switch]$All,
|
|
5
|
+
[switch]$DevBuild,
|
|
5
6
|
[string]$Arch = "",
|
|
6
7
|
[string]$RocmBin = $env:HIP_QUANT_ROCM_BIN,
|
|
7
8
|
[switch]$SkipSmi = $false,
|
|
@@ -10,6 +11,11 @@ param(
|
|
|
10
11
|
|
|
11
12
|
$ErrorActionPreference = "Continue"
|
|
12
13
|
|
|
14
|
+
if ((-not [string]::IsNullOrWhiteSpace($Arch) -or $CDNA) -and -not $DevBuild) {
|
|
15
|
+
Write-Error "-Arch and -CDNA narrow the DLL target set and are development-only. Pass -DevBuild to opt in; release builds must use the default multi-arch target list."
|
|
16
|
+
exit 2
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
function Get-ShortPath([string]$Path) {
|
|
14
20
|
if (!(Test-Path -LiteralPath $Path)) {
|
|
15
21
|
return $Path
|
|
@@ -30,6 +36,15 @@ function Get-ShortPath([string]$Path) {
|
|
|
30
36
|
if ([string]::IsNullOrWhiteSpace($RocmBin)) {
|
|
31
37
|
if ($env:HIP_QUANT_ROCM_BIN -and (Test-Path $env:HIP_QUANT_ROCM_BIN)) {
|
|
32
38
|
$RocmBin = $env:HIP_QUANT_ROCM_BIN
|
|
39
|
+
} elseif ($env:HIP_QUANT_ROCM_HOME) {
|
|
40
|
+
$RocmBin = Join-Path $env:HIP_QUANT_ROCM_HOME "bin"
|
|
41
|
+
if (!(Test-Path (Join-Path $RocmBin "hipcc.exe"))) {
|
|
42
|
+
Write-Error "HIP_QUANT_ROCM_HOME has no bin\hipcc.exe: $env:HIP_QUANT_ROCM_HOME"
|
|
43
|
+
exit 1
|
|
44
|
+
}
|
|
45
|
+
} elseif (Test-Path "C:\TheRock\build-10.1\bin\hipcc.exe") {
|
|
46
|
+
# Default compiler for the Torch 2.14 / ROCm 10.1 release environment.
|
|
47
|
+
$RocmBin = "C:\TheRock\build-10.1\bin"
|
|
33
48
|
} elseif ($env:ROCM_PATH -and (Test-Path (Join-Path $env:ROCM_PATH "bin"))) {
|
|
34
49
|
$RocmBin = Join-Path $env:ROCM_PATH "bin"
|
|
35
50
|
} elseif ($env:HIP_PATH -and (Test-Path (Join-Path $env:HIP_PATH "bin"))) {
|
|
@@ -59,6 +74,7 @@ $src_dir_arg = Get-ShortPath $src_dir
|
|
|
59
74
|
$out_file = Join-Path $src_dir $Output
|
|
60
75
|
$out_file_arg = Join-Path $src_dir_arg $Output
|
|
61
76
|
|
|
77
|
+
Write-Host "HIP compiler: $hipcc"
|
|
62
78
|
Write-Host "Compiling HIP quantization DLL..."
|
|
63
79
|
|
|
64
80
|
# Determine target architectures
|
|
@@ -52,7 +52,11 @@ def _add_runtime_dll_dirs():
|
|
|
52
52
|
if path in seen or not os.path.isdir(path):
|
|
53
53
|
continue
|
|
54
54
|
seen.add(path)
|
|
55
|
-
|
|
55
|
+
try:
|
|
56
|
+
_DLL_DIR_HANDLES.append(os.add_dll_directory(path))
|
|
57
|
+
except OSError:
|
|
58
|
+
# Device probing is best-effort; ignore stale optional HIP paths.
|
|
59
|
+
continue
|
|
56
60
|
|
|
57
61
|
_add_dll_directories = _add_runtime_dll_dirs
|
|
58
62
|
|
|
@@ -157,9 +161,13 @@ def _resolve_dll(dll_path=None):
|
|
|
157
161
|
"HIP_QUANT_DLL / HIP_QUANT_DLL_PATH must be an absolute path, got "
|
|
158
162
|
f"{env_dll!r}"
|
|
159
163
|
)
|
|
160
|
-
|
|
161
|
-
if
|
|
162
|
-
win_names.
|
|
164
|
+
variant = os.environ.get("HIP_QUANT_DLL_VARIANT", "").lower()
|
|
165
|
+
if variant in ("7.1", "71", "rocm71", "legacy"):
|
|
166
|
+
win_names = ["hip_quantize.dll", "hip_quantize_rocm721.dll", "hip_quantize_rocm101.dll"]
|
|
167
|
+
elif variant in ("7.2.1", "721", "rocm721"):
|
|
168
|
+
win_names = ["hip_quantize_rocm721.dll", "hip_quantize_rocm101.dll", "hip_quantize.dll"]
|
|
169
|
+
else:
|
|
170
|
+
win_names = ["hip_quantize_rocm101.dll", "hip_quantize_rocm721.dll", "hip_quantize.dll"]
|
|
163
171
|
names = win_names if os.name == "nt" else ["libhip_quantize.so"]
|
|
164
172
|
candidates = [env_dll] if env_dll else []
|
|
165
173
|
for root in (_PKG_DIR, os.path.join(_PKG_DIR, ".."), os.path.join(_PKG_DIR, "..", "..", "src")):
|