MCPcopy Create free account
hub / github.com/EmbodiedGPT/EmbodiedGPT_Pytorch / decompress

Function decompress

robohusky/compression.py:197–230  ·  view source on GitHub ↗

Simulate group-wise dequantization.

(packed_data, config)

Source from the content-addressed store, hash-verified

195
196
197def decompress(packed_data, config):
198 """Simulate group-wise dequantization."""
199 if not config.enabled:
200 return packed_data
201
202 group_size, num_bits, group_dim, symmetric = (
203 config.group_size,
204 config.num_bits,
205 config.group_dim,
206 config.symmetric,
207 )
208
209 # Dequantize
210 if symmetric:
211 data, scale, original_shape = packed_data
212 data = data / scale
213 else:
214 data, mn, scale, original_shape = packed_data
215 data = data / scale
216 data.add_(mn)
217
218 # Unpad
219 pad_len = (group_size - original_shape[group_dim] % group_size) % group_size
220 if pad_len:
221 padded_original_shape = (
222 original_shape[:group_dim]
223 + (original_shape[group_dim] + pad_len,)
224 + original_shape[group_dim + 1 :]
225 )
226 data = data.reshape(padded_original_shape)
227 indices = [slice(0, x) for x in original_shape]
228 return data[indices].contiguous()
229 else:
230 return data.view(original_shape)

Callers 1

forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected