Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch #26

Draft
wants to merge 2 commits into
base: semi_struc_dipika_rahul
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,40 @@ def process_weights_after_loading(self, layer: torch.nn.Module) -> None:
weight_packed_data = layer.weight_packed.data
meta = layer.meta.data

weight_data = {
"weight_packed": weight_packed_data,
"meta": meta
}
#decompress = self.model_compressor.sparsity_compressor.decompress_weight(weight_data).contiguous()
# Temporarily swap in to use Alex's method. Seems like the compression might be wrong?
decompress = sparse_semi_structured_to_dense_cutlass(weight_packed_data, meta)
compressed = compress_to_torch_sparse_semi_structured_mat(decompress)
qkv_sizes = [2048, 256, 256]
gate_up_sizes = [5632, 5632]
split_weights = None
split_meta = None

def _process_split(input_weight, input_meta):
weight_data = {
"weight_packed": input_weight,
"meta": input_meta
}
decompress = self.model_compressor.sparsity_compressor.decompress_weight(weight_data)
return decompress

print(self.layer_name)
if "qkv" in self.layer_name:
split_weights = torch.split(weight_packed_data, qkv_sizes)
split_meta = torch.split(meta, qkv_sizes)
elif "gate_up" in self.layer_name:
split_weights = torch.split(weight_packed_data, gate_up_sizes)
split_meta = torch.split(meta, gate_up_sizes)

if split_weights:
all_compress = []
for i in range(len(split_weights)):
print(split_weights[i].shape, split_meta[i].shape)
compress_i = _process_split(split_weights[i], split_meta[i])
all_compress.append(compress_i)

compressed = torch.cat(all_compress)
compressed = compress_to_torch_sparse_semi_structured_mat(compressed)
else:
decompress = _process_split(weight_packed_data, meta)
compressed = compress_to_torch_sparse_semi_structured_mat(decompress)

layer.weight = Parameter(compressed, requires_grad=False)

else:
Expand Down