compressed-tensors 0.9.4a20250421__tar.gz → 0.9.5a20250425__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.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/workflows/build.yml +1 -1
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/workflows/test-check.yaml +5 -5
- {compressed_tensors-0.9.4a20250421/src/compressed_tensors.egg-info → compressed_tensors-0.9.5a20250425}/PKG-INFO +1 -1
- compressed_tensors-0.9.5a20250425/pyproject.toml +7 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/setup.py +1 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/utils/offload.py +20 -16
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/version.py +2 -2
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425/src/compressed_tensors.egg-info}/PKG-INFO +1 -1
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_utils/test_offload.py +46 -1
- compressed_tensors-0.9.4a20250421/pyproject.toml +0 -10
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/.gitkeep +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/actions/test/action.yml +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/scripts/step-status +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/workflows/build-test.yml +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/workflows/report.yml +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/workflows/test.yml +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/workflows/trigger-all.yml +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/workflows/upload.yml +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.gitignore +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/LICENSE +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/Makefile +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/README.md +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/examples/bit_packing/ex_quantize_and_pack.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/examples/bit_packing/int4_config.json +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/examples/bitmask_compression.ipynb +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/examples/llama_1.1b/ex_config_quantization.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/examples/llama_1.1b/ex_llmcompressor_quantization.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/examples/llama_1.1b/example_quant_config.json +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/examples/llama_1.1b/example_quant_recipe.yaml +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/examples/quantize_and_pack_int4.ipynb +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/setup.cfg +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/README.md +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/base.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/base.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/helpers.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/model_compressors/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/model_compressors/model_compressor.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/quantized_compressors/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/quantized_compressors/base.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/quantized_compressors/naive_quantized.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/quantized_compressors/pack_quantized.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/sparse_compressors/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/sparse_compressors/base.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/sparse_compressors/dense.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/sparse_compressors/sparse_24_bitmask.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/sparse_compressors/sparse_bitmask.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/sparse_quantized_compressors/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/compressors/sparse_quantized_compressors/marlin_24.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/config/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/config/base.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/config/dense.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/config/sparse_24_bitmask.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/config/sparse_bitmask.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/linear/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/linear/compressed_linear.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/quantization/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/quantization/lifecycle/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/quantization/lifecycle/apply.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/quantization/lifecycle/compressed.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/quantization/lifecycle/forward.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/quantization/lifecycle/helpers.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/quantization/lifecycle/initialize.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/quantization/quant_args.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/quantization/quant_config.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/quantization/quant_scheme.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/quantization/utils/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/quantization/utils/helpers.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/registry/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/registry/registry.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/utils/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/utils/helpers.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/utils/permutations_24.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/utils/permute.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/utils/safetensors_load.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors/utils/semi_structured_conversions.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors.egg-info/SOURCES.txt +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors.egg-info/dependency_links.txt +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors.egg-info/requires.txt +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/src/compressed_tensors.egg-info/top_level.txt +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/conftest.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_compressors/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_compressors/model_compressors/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_compressors/model_compressors/test_model_compressor.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_compressors/quantized_compressors/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_compressors/quantized_compressors/test_fp8_quant.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_compressors/quantized_compressors/test_int_quant.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_compressors/quantized_compressors/test_pack_quant.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_compressors/sparse_compressors/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_compressors/sparse_compressors/test_bitmask.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_compressors/sparse_compressors/test_sparse_24_bitmask.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_compressors/sparse_quantized_compressors/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_compressors/sparse_quantized_compressors/test_marlin_24.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_configs/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_configs/test_base.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_examples/test_bitmask_compression_ipynb.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_linear/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_linear/test_compressed_linear.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/lifecycle/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/lifecycle/conftest.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/lifecycle/test_apply.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/lifecycle/test_dynamic_lifecycle.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/lifecycle/test_enabled.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/lifecycle/test_forward.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/lifecycle/test_helpers.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/lifecycle/test_initialize.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/lifecycle/test_lifecycle.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/test_configs/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/test_configs/test_bit_depths.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/test_configs/test_strategies.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/test_quant_args.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/test_quant_config.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/test_quant_scheme.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_quantization/test_utils/test_helpers.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_registry.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_utils/__init__.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_utils/test_helpers.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_utils/test_safetensors_load.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/testing_utils.py +0 -0
- {compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/utils/copyright.py +0 -0
{compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/workflows/build.yml
RENAMED
@@ -76,7 +76,7 @@ jobs:
|
|
76
76
|
|
77
77
|
- name: build
|
78
78
|
id: build
|
79
|
-
uses: neuralmagic/nm-actions/actions/build-ml-whl@v1.
|
79
|
+
uses: neuralmagic/nm-actions/actions/build-ml-whl@c7e5a66c382104e1beadcb7dadf429f8ab15b344 # v1.20.0
|
80
80
|
with:
|
81
81
|
dev: false
|
82
82
|
release: ${{ inputs.wf_category == 'RELEASE' }}
|
@@ -12,16 +12,16 @@ jobs:
|
|
12
12
|
python-tests:
|
13
13
|
runs-on: ubuntu-24.04
|
14
14
|
steps:
|
15
|
-
- uses: actions/setup-python@
|
15
|
+
- uses: actions/setup-python@v5
|
16
16
|
with:
|
17
17
|
python-version: '3.10'
|
18
|
-
- uses: actions/checkout@
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
with:
|
20
|
+
fetch-depth: 0
|
21
|
+
fetch-tags: true
|
19
22
|
- name: Set Env
|
20
23
|
run: |
|
21
24
|
pip3 install --upgrade pip && pip3 install --upgrade setuptools
|
22
|
-
pip3 install virtualenv
|
23
|
-
virtualenv venv
|
24
|
-
source venv/bin/activate
|
25
25
|
- name: "⚙️ Install dependencies"
|
26
26
|
run: pip3 install .[dev,accelerate]
|
27
27
|
- name: "🔬 Running tests"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: compressed-tensors
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.5a20250425
|
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.
|
@@ -94,22 +94,6 @@ def is_module_offloaded(module: torch.nn.Module) -> bool:
|
|
94
94
|
return has_offloaded_params(module)
|
95
95
|
|
96
96
|
|
97
|
-
def get_execution_device(module: torch.nn.Module) -> torch.device:
|
98
|
-
"""
|
99
|
-
:param module: module to check
|
100
|
-
:return: device module is loaded onto during forward pass
|
101
|
-
"""
|
102
|
-
if has_offloaded_params(module):
|
103
|
-
return module._hf_hook.execution_device
|
104
|
-
device = next(module.parameters()).device
|
105
|
-
|
106
|
-
# offload only gets set for leaf modules, fallback to checking for device type
|
107
|
-
if device.type == "meta":
|
108
|
-
return module._hf_hook.execution_device
|
109
|
-
|
110
|
-
return device
|
111
|
-
|
112
|
-
|
113
97
|
def get_offloaded_device(module: torch.nn.Module) -> torch.device:
|
114
98
|
"""
|
115
99
|
:param module: module to check
|
@@ -158,6 +142,26 @@ def update_parameter_data(
|
|
158
142
|
""" Candidates for Upstreaming """
|
159
143
|
|
160
144
|
|
145
|
+
def get_execution_device(module: torch.nn.Module) -> torch.device:
|
146
|
+
"""
|
147
|
+
Get the device which inputs should be moved to before module execution
|
148
|
+
|
149
|
+
:param module: module to check, may be offloaded
|
150
|
+
:return: onload device of module
|
151
|
+
"""
|
152
|
+
if has_offloaded_params(module):
|
153
|
+
return module._hf_hook.execution_device
|
154
|
+
|
155
|
+
first_param = next(module.parameters(), None)
|
156
|
+
if first_param is None:
|
157
|
+
warnings.warn(
|
158
|
+
f"Unable able to infer execution device of {module}, falling back to CPU"
|
159
|
+
)
|
160
|
+
return torch.device("cpu")
|
161
|
+
|
162
|
+
return first_param.device
|
163
|
+
|
164
|
+
|
161
165
|
def register_offload_parameter(
|
162
166
|
module: torch.nn.Module,
|
163
167
|
name: str,
|
@@ -17,5 +17,5 @@ __version__: str
|
|
17
17
|
__version_tuple__: VERSION_TUPLE
|
18
18
|
version_tuple: VERSION_TUPLE
|
19
19
|
|
20
|
-
__version__ = version = '0.9.
|
21
|
-
__version_tuple__ = version_tuple = (0, 9,
|
20
|
+
__version__ = version = '0.9.5.a20250425'
|
21
|
+
__version_tuple__ = version_tuple = (0, 9, 5)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: compressed-tensors
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.5a20250425
|
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.
|
@@ -17,12 +17,13 @@ from compressed_tensors.utils import (
|
|
17
17
|
align_module_device,
|
18
18
|
delete_offload_parameter,
|
19
19
|
disable_hf_hook,
|
20
|
+
get_execution_device,
|
20
21
|
has_offloaded_params,
|
21
22
|
register_offload_parameter,
|
22
23
|
update_offload_parameter,
|
23
24
|
)
|
24
25
|
from compressed_tensors.utils.offload import offload_to_weights_map
|
25
|
-
from tests.testing_utils import requires_accelerate
|
26
|
+
from tests.testing_utils import requires_accelerate, requires_gpu
|
26
27
|
|
27
28
|
|
28
29
|
class ExampleModule(torch.nn.Module):
|
@@ -55,8 +56,46 @@ def test_has_offloaded_params():
|
|
55
56
|
assert has_offloaded_params(module)
|
56
57
|
|
57
58
|
|
59
|
+
@requires_gpu
|
60
|
+
@requires_accelerate()
|
61
|
+
def test_get_execution_device():
|
62
|
+
from accelerate import init_empty_weights
|
63
|
+
from accelerate.big_modeling import attach_align_device_hook
|
64
|
+
|
65
|
+
# no offloading
|
66
|
+
module = ExampleModule()
|
67
|
+
assert get_execution_device(module) == torch.device("cpu")
|
68
|
+
|
69
|
+
# with offloading
|
70
|
+
attach_align_device_hook(module, torch.device("cuda:0"))
|
71
|
+
assert get_execution_device(module) == torch.device("cuda:0")
|
72
|
+
|
73
|
+
# in meta context
|
74
|
+
with torch.device("meta"):
|
75
|
+
module = ExampleModule()
|
76
|
+
assert get_execution_device(module) == torch.device("meta")
|
77
|
+
|
78
|
+
# offloaded in meta context
|
79
|
+
module = ExampleModule()
|
80
|
+
attach_align_device_hook(module, torch.device("cuda:0"))
|
81
|
+
with torch.device("meta"):
|
82
|
+
assert get_execution_device(module) == torch.device("cuda:0")
|
83
|
+
|
84
|
+
# in empty weights context
|
85
|
+
with init_empty_weights():
|
86
|
+
module = ExampleModule()
|
87
|
+
assert get_execution_device(module) == torch.device("meta")
|
88
|
+
|
89
|
+
# offloaded in empty weights context
|
90
|
+
module = ExampleModule()
|
91
|
+
attach_align_device_hook(module, torch.device("cuda:0"))
|
92
|
+
with init_empty_weights():
|
93
|
+
assert get_execution_device(module) == torch.device("cuda:0")
|
94
|
+
|
95
|
+
|
58
96
|
@requires_accelerate()
|
59
97
|
def test_register_offload_parameter():
|
98
|
+
from accelerate import init_empty_weights
|
60
99
|
from accelerate.hooks import attach_align_device_hook
|
61
100
|
|
62
101
|
module = ExampleModule()
|
@@ -94,6 +133,12 @@ def test_register_offload_parameter():
|
|
94
133
|
assert module.f.device == torch.device("cpu")
|
95
134
|
assert module._hf_hook.weights_map["f"].device == torch.device("cpu")
|
96
135
|
|
136
|
+
# parameters registered in the empty init context are still empty
|
137
|
+
with init_empty_weights():
|
138
|
+
module = ExampleModule()
|
139
|
+
register_offload_parameter(module, "c", parameter)
|
140
|
+
assert module.a.device == module.b.device == module.c.device == torch.device("meta")
|
141
|
+
|
97
142
|
|
98
143
|
@requires_accelerate()
|
99
144
|
def test_update_offload_parameter():
|
File without changes
|
File without changes
|
{compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/scripts/step-status
RENAMED
File without changes
|
File without changes
|
{compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/workflows/report.yml
RENAMED
File without changes
|
{compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/workflows/test.yml
RENAMED
File without changes
|
File without changes
|
{compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/.github/workflows/upload.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
|
{compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_registry.py
RENAMED
File without changes
|
{compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/test_utils/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{compressed_tensors-0.9.4a20250421 → compressed_tensors-0.9.5a20250425}/tests/testing_utils.py
RENAMED
File without changes
|
File without changes
|