{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/slim-one-shot-quantized-sparse-plus-low-rank","title":"SLiM: One-shot Quantization and Sparsity with Low-rank Approximation for LLM Weight Compression","arxiv_id":"2410.09615","date":"2024-10-12","proceeding":null,"authors":["Mohammad Mozaffari","Amir Yazdanbakhsh","Maryam Mehri Dehnavi"],"abstract":"Conventional model compression techniques for LLMs address high memory consumption and slow inference challenges but typically require computationally expensive retraining to preserve accuracy. In contrast, one-shot compression methods eliminate retraining cost, but struggle to achieve accuracy comparable to dense models. This paper presents SLIM, a new one-shot compression framework that holistically integrates hardware-friendly quantization, sparsity, and low-rank approximation into a unified process. First, we formulate the quantization process using a probabilistic approach (SLIM-Quant) that enables us to apply uniform quantization. Then, we use an existing one-shot pruning method to apply semi-structured sparsity on top of the quantized weights. Finally, to compensate for the introduced aggregated quantization and sparsity error, we use a novel saliency function with unique invertible and additive features that enables us to mathematically compute the value of low-rank adapters. SLIM improves model accuracy by up to 5.66% (LLaMA-2-7B) for 2:4 sparsity with 4-bit weight quantization, outperforming prior methods. Models compressed with SLIM achieve up to 4.3x and 3.8x on Nvidia RTX3060 and A100 GPUs, respectively. Additionally, they achieve up to 0.23x end-to-end memory reduction in comparison to their dense counterparts. We also propose an optional PEFT recipe that further improves accuracy by up to 1.66% (LLaMA-2-13B) compared to SLIM without fine-tuning.","url_abs":"https://arxiv.org/abs/2410.09615v3","url_pdf":"https://arxiv.org/pdf/2410.09615v3.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"slim-one-shot-quantized-sparse-plus-low-rank","repo_url":"https://github.com/mohammad-mozaffari/slim","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"model-compression","task_name":"Model Compression"},{"task_slug":"natural-language-understanding","task_name":"Natural Language Understanding"},{"task_slug":"quantization","task_name":"Quantization"},{"task_slug":"parameter-efficient-fine-tuning","task_name":"parameter-efficient fine-tuning"}],"methods":[{"method_slug":"pruning","method_name":"Pruning"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2410.09615","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.09615"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/mohammad-mozaffari/slim","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":8,"unverified":8},"by_repo_kind":{"official":{"samples":16,"ran":8,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"42183294cfd88747","entry":"check_sparsity","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/utils.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"42183294cfd88747"}},{"code_sha256_prefix":"4571405e8c540b28","entry":"clip_matrix","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/jsq_utils.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/jsq_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4571405e8c540b28"}},{"code_sha256_prefix":"84eb8004af9c2890","entry":"compute_average_error","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/quantization/quantization.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/quantization/quantization.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"84eb8004af9c2890"}},{"code_sha256_prefix":"52c8d10182e8a260","entry":"compute_error","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/quantization/quantization.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/quantization/quantization.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"52c8d10182e8a260"}},{"code_sha256_prefix":"020fcf9a9520fb1e","entry":"find_optimal_quantiztion_cap","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/quantization/quantization.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/quantization/quantization.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"020fcf9a9520fb1e"}},{"code_sha256_prefix":"85fa2999ab638291","entry":"get_layers_list","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/utils.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"85fa2999ab638291"}},{"code_sha256_prefix":"50ceff9d34d96d60","entry":"quantize","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/sparsegpt.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/sparsegpt.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"50ceff9d34d96d60"}},{"code_sha256_prefix":"7e09ff6cd96dfeb0","entry":"shift_zeros","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/utils.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7e09ff6cd96dfeb0"}},{"code_sha256_prefix":"063194fe32e79956","entry":"generate_ss","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/jsq_utils.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/jsq_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"063194fe32e79956"}},{"code_sha256_prefix":"ddc3bcb5e5b4ab8d","entry":"get_c4","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/data.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/data.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ddc3bcb5e5b4ab8d"}},{"code_sha256_prefix":"8bd4db5249a2e99e","entry":"get_openwebtext","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/data.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/data.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8bd4db5249a2e99e"}},{"code_sha256_prefix":"83ea71aadeabb49a","entry":"get_wikitext2","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/data.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/data.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"83ea71aadeabb49a"}},{"code_sha256_prefix":"11faa3c36aa963d7","entry":"prepare_calibration_input","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/prune.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/prune.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"11faa3c36aa963d7"}},{"code_sha256_prefix":"e9ba4d8812c998e4","entry":"prune_and_optimize_lora","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/lora.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/lora.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e9ba4d8812c998e4"}},{"code_sha256_prefix":"dd83c9200ae23e37","entry":"prune_sparsegpt","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/prune.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/prune.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"dd83c9200ae23e37"}},{"code_sha256_prefix":"99c9352eb054f54a","entry":"sparse_quantized_linear","repo":"mohammad-mozaffari/slim","repo_kind":"official","path":"slim/fine_tune.py","file_url":"https://github.com/mohammad-mozaffari/slim/blob/HEAD/slim/fine_tune.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"99c9352eb054f54a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}