compressed-tensors 0.10.3a20250805__tar.gz → 0.10.3a20250806__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.
- {compressed_tensors-0.10.3a20250805/src/compressed_tensors.egg-info → compressed_tensors-0.10.3a20250806}/PKG-INFO +1 -1
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/factory/base.py +48 -3
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/factory/matrix_multiply.py +1 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/version.py +1 -1
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806/src/compressed_tensors.egg-info}/PKG-INFO +1 -1
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors.egg-info/SOURCES.txt +1 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_transform/conftest.py +4 -3
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_transform/factory/test_correctness.py +15 -17
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_transform/factory/test_memory.py +6 -6
- compressed_tensors-0.10.3a20250806/tests/test_transform/factory/test_serialization.py +54 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/.github/.gitkeep +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/.github/actions/test/action.yml +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/.github/scripts/step-status +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/.github/workflows/build-test.yml +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/.github/workflows/build.yml +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/.github/workflows/report.yml +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/.github/workflows/test-check.yaml +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/.github/workflows/test.yml +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/.github/workflows/trigger-all.yml +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/.github/workflows/upload.yml +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/.gitignore +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/LICENSE +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/Makefile +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/README.md +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/examples/bit_packing/ex_quantize_and_pack.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/examples/bit_packing/int4_config.json +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/examples/bitmask_compression.ipynb +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/examples/llama_1.1b/ex_config_quantization.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/examples/llama_1.1b/ex_llmcompressor_quantization.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/examples/llama_1.1b/example_quant_config.json +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/examples/llama_1.1b/example_quant_recipe.yaml +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/examples/quantize_and_pack_int4.ipynb +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/pyproject.toml +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/setup.cfg +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/setup.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/README.md +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/base.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/base.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/helpers.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/model_compressors/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/model_compressors/model_compressor.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/quantized_compressors/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/quantized_compressors/base.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/quantized_compressors/naive_quantized.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/quantized_compressors/nvfp4_quantized.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/quantized_compressors/pack_quantized.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/sparse_compressors/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/sparse_compressors/base.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/sparse_compressors/dense.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/sparse_compressors/sparse_24_bitmask.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/sparse_compressors/sparse_bitmask.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/sparse_quantized_compressors/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/compressors/sparse_quantized_compressors/marlin_24.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/config/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/config/base.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/config/dense.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/config/sparse_24_bitmask.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/config/sparse_bitmask.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/linear/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/linear/compressed_linear.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/quantization/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/quantization/lifecycle/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/quantization/lifecycle/apply.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/quantization/lifecycle/compressed.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/quantization/lifecycle/forward.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/quantization/lifecycle/helpers.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/quantization/lifecycle/initialize.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/quantization/quant_args.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/quantization/quant_config.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/quantization/quant_scheme.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/quantization/utils/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/quantization/utils/helpers.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/registry/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/registry/registry.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/apply.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/factory/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/factory/hadamard.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/factory/random_hadamard.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/transform_args.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/transform_config.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/transform_scheme.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/utils/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/utils/hadamard.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/utils/hadamards.safetensors +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/transform/utils/matrix.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/utils/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/utils/helpers.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/utils/internal.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/utils/match.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/utils/offload.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/utils/permutations_24.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/utils/permute.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/utils/safetensors_load.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors/utils/semi_structured_conversions.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors.egg-info/dependency_links.txt +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors.egg-info/requires.txt +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/src/compressed_tensors.egg-info/top_level.txt +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/conftest.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/model_compressors/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/model_compressors/test_model_compressor.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/quantized_compressors/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/quantized_compressors/test_fp8_quant.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/quantized_compressors/test_int_quant.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/quantized_compressors/test_nvfp4_quant.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/quantized_compressors/test_pack_quant.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/sparse_compressors/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/sparse_compressors/test_bitmask.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/sparse_compressors/test_sparse_24_bitmask.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/sparse_quantized_compressors/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_compressors/sparse_quantized_compressors/test_marlin_24.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_configs/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_configs/test_base.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_examples/test_bitmask_compression_ipynb.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_linear/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_linear/test_compressed_linear.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/lifecycle/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/lifecycle/conftest.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/lifecycle/test_apply.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/lifecycle/test_dynamic_lifecycle.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/lifecycle/test_enabled.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/lifecycle/test_forward.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/lifecycle/test_helpers.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/lifecycle/test_initialize.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/lifecycle/test_lifecycle.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/test_configs/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/test_configs/test_bit_depths.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/test_configs/test_strategies.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/test_quant_args.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/test_quant_config.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/test_quant_scheme.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_quantization/test_utils/test_helpers.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_registry.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_transform/test_transform_args.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_transform/test_transform_config.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_transform/test_transform_scheme.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_transform/utils/test_hadamard.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_utils/__init__.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_utils/test_helpers.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_utils/test_match.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_utils/test_offload.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_utils/test_safetensors_load.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/testing_utils.py +0 -0
- {compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/utils/copyright.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: compressed-tensors
|
3
|
-
Version: 0.10.
|
3
|
+
Version: 0.10.3a20250806
|
4
4
|
Summary: Library for utilization of compressed safetensors of neural network models
|
5
5
|
Home-page: https://github.com/neuralmagic/compressed-tensors
|
6
6
|
Author: Neuralmagic, Inc.
|
@@ -13,7 +13,8 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
from abc import ABC, abstractmethod
|
16
|
-
from
|
16
|
+
from collections import defaultdict
|
17
|
+
from typing import List, Optional, Tuple, Set
|
17
18
|
|
18
19
|
import torch
|
19
20
|
import torch.nn.utils.parametrize as P
|
@@ -49,10 +50,13 @@ class TransformFactory(RegistryMixin, ABC):
|
|
49
50
|
:param seed: random seed used to transform weight randomization
|
50
51
|
"""
|
51
52
|
|
53
|
+
transforms: List["TransformBase"]
|
54
|
+
|
52
55
|
def __init__(self, name: str, scheme: TransformScheme, seed: Optional[int] = None):
|
53
56
|
self.name = name
|
54
57
|
self.scheme = scheme
|
55
58
|
self.generator = torch.Generator()
|
59
|
+
self.transforms = list()
|
56
60
|
if seed is not None:
|
57
61
|
self.generator.manual_seed(seed)
|
58
62
|
|
@@ -90,6 +94,8 @@ class TransformFactory(RegistryMixin, ABC):
|
|
90
94
|
for _, module in match_named_modules(model, arg.targets, arg.ignore):
|
91
95
|
self._apply_to_module(module, arg)
|
92
96
|
|
97
|
+
self._update_tied_weights()
|
98
|
+
|
93
99
|
def _apply_to_module(self, module: Module, args: TransformArgs):
|
94
100
|
"""
|
95
101
|
Create transforms and apply them to the module
|
@@ -97,9 +103,17 @@ class TransformFactory(RegistryMixin, ABC):
|
|
97
103
|
:param module: target module to apply transforms to
|
98
104
|
:param args: defines how the transform will be applied to the target module
|
99
105
|
"""
|
106
|
+
if has_offloaded_params(module):
|
107
|
+
if module._hf_hook.place_submodules:
|
108
|
+
raise NotImplementedError(
|
109
|
+
"Applying transforms to offloaded submodules with "
|
110
|
+
"`place_submodules=True` is not supported"
|
111
|
+
)
|
112
|
+
|
100
113
|
# create transform as submodule
|
101
114
|
transform_name = f"{self.name}_{args.location}"
|
102
115
|
transform = self.create_transform(module, args)
|
116
|
+
self.transforms.append(transform)
|
103
117
|
register_offload_module(module, transform_name, transform)
|
104
118
|
|
105
119
|
# register input transformation hook
|
@@ -128,8 +142,9 @@ class TransformFactory(RegistryMixin, ABC):
|
|
128
142
|
raise ValueError("Offloaded training is not supported")
|
129
143
|
P.register_parametrization(module, "weight", transform)
|
130
144
|
|
131
|
-
|
132
|
-
|
145
|
+
else:
|
146
|
+
# transform is no longer needed (unfusing is not supported)
|
147
|
+
delete_offload_module(module, transform_name)
|
133
148
|
|
134
149
|
# register output transformation hook
|
135
150
|
elif args.location == TransformLocation.OUTPUT:
|
@@ -143,6 +158,31 @@ class TransformFactory(RegistryMixin, ABC):
|
|
143
158
|
else:
|
144
159
|
raise NotImplementedError()
|
145
160
|
|
161
|
+
def _update_tied_weights(self):
|
162
|
+
"""
|
163
|
+
Populate the `_dynamic_tied_weights_keys` attribute of transforms,
|
164
|
+
which is used by transformers to detect and remove shared pointers
|
165
|
+
during saving
|
166
|
+
"""
|
167
|
+
# map from data_ptrs to keys
|
168
|
+
ptr_to_keys: dict[int, List[Tuple[TransformBase, str]]] = defaultdict(list)
|
169
|
+
for transform in self.transforms:
|
170
|
+
for name, param in transform.named_parameters(recurse=False):
|
171
|
+
# NOTE: previously asserted that parent._hf_hook.place_submodules=False
|
172
|
+
if has_offloaded_params(transform):
|
173
|
+
param = transform._hf_hook.weights_map[name]
|
174
|
+
ptr_to_keys[param.data_ptr()].append((transform, name))
|
175
|
+
|
176
|
+
# populate `_dynamic_tied_weights_keys` if there is more than one key
|
177
|
+
# and ensure that they share tensors
|
178
|
+
for shared_keys in ptr_to_keys.values():
|
179
|
+
if len(shared_keys) > 1:
|
180
|
+
tensor = getattr(shared_keys[0][0], shared_keys[0][1])
|
181
|
+
|
182
|
+
for transform, name in shared_keys:
|
183
|
+
transform._dynamic_tied_weights_keys.add(name)
|
184
|
+
setattr(transform, name, tensor)
|
185
|
+
|
146
186
|
|
147
187
|
class TransformBase(InternalModule, ABC):
|
148
188
|
"""
|
@@ -151,6 +191,11 @@ class TransformBase(InternalModule, ABC):
|
|
151
191
|
|
152
192
|
args: TransformArgs
|
153
193
|
weight: Parameter
|
194
|
+
_dynamic_tied_weights_keys: Set[str]
|
195
|
+
|
196
|
+
def __init__(self):
|
197
|
+
super().__init__()
|
198
|
+
self._dynamic_tied_weights_keys = set()
|
154
199
|
|
155
200
|
@abstractmethod
|
156
201
|
def forward(self, value: Tensor) -> Tensor:
|
@@ -70,6 +70,7 @@ class RandomMatrixFactory(TransformFactory):
|
|
70
70
|
|
71
71
|
def _create_inverse(self, weight: Parameter) -> Parameter:
|
72
72
|
data = high_precision_invert(weight.data)
|
73
|
+
data = data.contiguous() # ensure proper serialization
|
73
74
|
return Parameter(data, requires_grad=False)
|
74
75
|
|
75
76
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: compressed-tensors
|
3
|
-
Version: 0.10.
|
3
|
+
Version: 0.10.3a20250806
|
4
4
|
Summary: Library for utilization of compressed safetensors of neural network models
|
5
5
|
Home-page: https://github.com/neuralmagic/compressed-tensors
|
6
6
|
Author: Neuralmagic, Inc.
|
@@ -139,6 +139,7 @@ tests/test_transform/test_transform_config.py
|
|
139
139
|
tests/test_transform/test_transform_scheme.py
|
140
140
|
tests/test_transform/factory/test_correctness.py
|
141
141
|
tests/test_transform/factory/test_memory.py
|
142
|
+
tests/test_transform/factory/test_serialization.py
|
142
143
|
tests/test_transform/utils/test_hadamard.py
|
143
144
|
tests/test_utils/__init__.py
|
144
145
|
tests/test_utils/test_helpers.py
|
@@ -14,12 +14,13 @@
|
|
14
14
|
|
15
15
|
import pytest
|
16
16
|
import torch
|
17
|
-
from compressed_tensors.transform import TransformArgs
|
17
|
+
from compressed_tensors.transform import TransformArgs, TransformFactory
|
18
|
+
from transformers import PretrainedConfig, PreTrainedModel
|
18
19
|
|
19
20
|
|
20
|
-
class TransformableModel(
|
21
|
+
class TransformableModel(PreTrainedModel):
|
21
22
|
def __init__(self, *sizes):
|
22
|
-
super().__init__()
|
23
|
+
super().__init__(config=PretrainedConfig())
|
23
24
|
self.fcs = torch.nn.ModuleList(
|
24
25
|
[
|
25
26
|
torch.nn.Linear(sizes[index], sizes[index + 1], bias=False)
|
@@ -27,13 +27,13 @@ from tests.testing_utils import requires_accelerate, requires_gpu
|
|
27
27
|
|
28
28
|
|
29
29
|
@pytest.mark.parametrize("type", ("hadamard", "random-hadamard"))
|
30
|
-
@pytest.mark.parametrize("
|
30
|
+
@pytest.mark.parametrize("randomize", (True, False))
|
31
31
|
@pytest.mark.parametrize("head_dim", (None, 2, 4))
|
32
32
|
@pytest.mark.parametrize("input_batch_size", (1, 5, 17))
|
33
|
-
def test_correctness_linear(type,
|
33
|
+
def test_correctness_linear(type, randomize, head_dim, input_batch_size):
|
34
34
|
size = (4, 8)
|
35
35
|
module = torch.nn.Linear(*size, bias=False)
|
36
|
-
scheme = TransformScheme(type=type,
|
36
|
+
scheme = TransformScheme(type=type, randomize=randomize, head_dim=head_dim)
|
37
37
|
factory = TransformFactory.from_scheme(scheme, name="")
|
38
38
|
|
39
39
|
input_tfm = factory.create_transform(
|
@@ -58,10 +58,10 @@ def test_correctness_linear(type, randomized, head_dim, input_batch_size):
|
|
58
58
|
|
59
59
|
|
60
60
|
@pytest.mark.parametrize("type", ("hadamard", "random-hadamard"))
|
61
|
-
@pytest.mark.parametrize("
|
61
|
+
@pytest.mark.parametrize("randomize", (True, False))
|
62
62
|
@pytest.mark.parametrize("embed_loc", ("weight_output", "output"))
|
63
63
|
@pytest.mark.parametrize("linear_loc", ("input", "weight_input"))
|
64
|
-
def test_correctness_embedding(type,
|
64
|
+
def test_correctness_embedding(type, randomize, embed_loc, linear_loc):
|
65
65
|
model = torch.nn.Sequential(
|
66
66
|
torch.nn.Embedding(2, 4),
|
67
67
|
torch.nn.Linear(4, 8, bias=False),
|
@@ -74,7 +74,7 @@ def test_correctness_embedding(type, randomized, embed_loc, linear_loc):
|
|
74
74
|
config_groups={
|
75
75
|
"": TransformScheme(
|
76
76
|
type=type,
|
77
|
-
|
77
|
+
randomize=randomize,
|
78
78
|
apply=[
|
79
79
|
TransformArgs(targets="Embedding", location=embed_loc),
|
80
80
|
TransformArgs(targets="Linear", location=linear_loc, inverse=True),
|
@@ -90,10 +90,10 @@ def test_correctness_embedding(type, randomized, embed_loc, linear_loc):
|
|
90
90
|
|
91
91
|
|
92
92
|
@pytest.mark.parametrize("type", ("hadamard", "random-hadamard"))
|
93
|
-
@pytest.mark.parametrize("
|
93
|
+
@pytest.mark.parametrize("randomize", (True, False))
|
94
94
|
@pytest.mark.parametrize("input_batch_size", (1, 5, 17))
|
95
95
|
def test_correctness_model(
|
96
|
-
type,
|
96
|
+
type, randomize, input_batch_size, model_apply, offload=False
|
97
97
|
):
|
98
98
|
# load model
|
99
99
|
model = model_apply[0]
|
@@ -109,7 +109,7 @@ def test_correctness_model(
|
|
109
109
|
# apply transforms
|
110
110
|
config = TransformConfig(
|
111
111
|
config_groups={
|
112
|
-
"": TransformScheme(type=type,
|
112
|
+
"": TransformScheme(type=type, randomize=randomize, apply=model_apply[1])
|
113
113
|
}
|
114
114
|
)
|
115
115
|
apply_transform_config(model, config)
|
@@ -122,19 +122,17 @@ def test_correctness_model(
|
|
122
122
|
@requires_gpu
|
123
123
|
@requires_accelerate()
|
124
124
|
@pytest.mark.parametrize("type", ("hadamard", "random-hadamard"))
|
125
|
-
@pytest.mark.parametrize("
|
125
|
+
@pytest.mark.parametrize("randomize", (True, False))
|
126
126
|
@pytest.mark.parametrize("input_batch_size", (1, 5, 17))
|
127
|
-
def test_correctness_model_offload(type,
|
128
|
-
test_correctness_model(
|
129
|
-
type, randomized, input_batch_size, model_apply, offload=True
|
130
|
-
)
|
127
|
+
def test_correctness_model_offload(type, randomize, input_batch_size, model_apply):
|
128
|
+
test_correctness_model(type, randomize, input_batch_size, model_apply, offload=True)
|
131
129
|
|
132
130
|
|
133
131
|
@pytest.mark.parametrize("type", ("hadamard", "random-hadamard"))
|
134
|
-
@pytest.mark.parametrize("
|
132
|
+
@pytest.mark.parametrize("randomize", (True, False))
|
135
133
|
@pytest.mark.parametrize("head_dim", (4, 8))
|
136
134
|
@pytest.mark.parametrize("input_batch_size", (1, 5, 17))
|
137
|
-
def test_correctness_attention_heads(type,
|
135
|
+
def test_correctness_attention_heads(type, randomize, head_dim, input_batch_size):
|
138
136
|
hidden_size = 64
|
139
137
|
num_attention_heads = 8
|
140
138
|
|
@@ -151,7 +149,7 @@ def test_correctness_attention_heads(type, randomized, head_dim, input_batch_siz
|
|
151
149
|
config_groups={
|
152
150
|
"": TransformScheme(
|
153
151
|
type=type,
|
154
|
-
|
152
|
+
randomize=randomize,
|
155
153
|
head_dim=head_dim,
|
156
154
|
apply=[
|
157
155
|
TransformArgs(targets="v_proj", location="weight_output"),
|
@@ -29,9 +29,9 @@ from tests.testing_utils import requires_accelerate, requires_gpu
|
|
29
29
|
|
30
30
|
|
31
31
|
@pytest.mark.parametrize("type", ("hadamard", "random-hadamard"))
|
32
|
-
@pytest.mark.parametrize("
|
32
|
+
@pytest.mark.parametrize("randomize", (True, False))
|
33
33
|
@pytest.mark.parametrize("requires_grad", (True, False))
|
34
|
-
def test_memory_sharing(type,
|
34
|
+
def test_memory_sharing(type, randomize, requires_grad, offload=False):
|
35
35
|
# load model (maybe with offloading)
|
36
36
|
model = TransformableModel(2, 2, 4, 4, 8, 8)
|
37
37
|
if offload:
|
@@ -42,7 +42,7 @@ def test_memory_sharing(type, randomized, requires_grad, offload=False):
|
|
42
42
|
config_groups={
|
43
43
|
"": TransformScheme(
|
44
44
|
type=type,
|
45
|
-
randomzied=
|
45
|
+
randomzied=randomize,
|
46
46
|
requires_grad=requires_grad,
|
47
47
|
apply=[
|
48
48
|
TransformArgs(targets="Linear", location="input"),
|
@@ -84,9 +84,9 @@ def test_memory_sharing(type, randomized, requires_grad, offload=False):
|
|
84
84
|
@requires_gpu
|
85
85
|
@requires_accelerate()
|
86
86
|
@pytest.mark.parametrize("type", ("hadamard", "random-hadamard"))
|
87
|
-
@pytest.mark.parametrize("
|
87
|
+
@pytest.mark.parametrize("randomize", (True, False))
|
88
88
|
def test_memory_sharing_offload(
|
89
89
|
type,
|
90
|
-
|
90
|
+
randomize,
|
91
91
|
):
|
92
|
-
test_memory_sharing(type,
|
92
|
+
test_memory_sharing(type, randomize, requires_grad=False, offload=True)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing,
|
10
|
+
# software distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
import pytest
|
16
|
+
import torch
|
17
|
+
from compressed_tensors.transform import (
|
18
|
+
TransformConfig,
|
19
|
+
TransformScheme,
|
20
|
+
apply_transform_config,
|
21
|
+
)
|
22
|
+
from compressed_tensors.utils import offloaded_dispatch
|
23
|
+
from tests.testing_utils import requires_accelerate, requires_gpu
|
24
|
+
|
25
|
+
|
26
|
+
@pytest.mark.parametrize("type", ("hadamard", "random-hadamard"))
|
27
|
+
@pytest.mark.parametrize("randomize", (True, False))
|
28
|
+
def test_serialization(type, randomize, model_apply, tmp_path, offload=False):
|
29
|
+
# get model, maybe offload
|
30
|
+
model, apply = model_apply
|
31
|
+
if offload:
|
32
|
+
offloaded_dispatch(model, torch.device("cuda"))
|
33
|
+
|
34
|
+
# apply transforms to model
|
35
|
+
config = TransformConfig(
|
36
|
+
config_groups={"": TransformScheme(type=type, randomize=randomize, apply=apply)}
|
37
|
+
)
|
38
|
+
apply_transform_config(model, config)
|
39
|
+
|
40
|
+
# save model
|
41
|
+
model.save_pretrained(tmp_path)
|
42
|
+
|
43
|
+
# TODO: reload model
|
44
|
+
|
45
|
+
|
46
|
+
@pytest.mark.skip(reason="Requires changes in upstream transformers")
|
47
|
+
# https://github.com/huggingface/transformers/pull/39280
|
48
|
+
# https://github.com/huggingface/transformers/pull/39263
|
49
|
+
@requires_gpu
|
50
|
+
@requires_accelerate()
|
51
|
+
@pytest.mark.parametrize("type", ("hadamard", "random-hadamard"))
|
52
|
+
@pytest.mark.parametrize("randomize", (True, False))
|
53
|
+
def test_serialization_offload(type, randomize, model_apply, tmp_path):
|
54
|
+
test_serialization(type, randomize, model_apply, tmp_path, offload=True)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/.github/workflows/test.yml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/test_registry.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/tests/testing_utils.py
RENAMED
File without changes
|
{compressed_tensors-0.10.3a20250805 → compressed_tensors-0.10.3a20250806}/utils/copyright.py
RENAMED
File without changes
|