Skip to content

Commit cb944d5

Browse files
Allow Unsloth Dynamic 4bit BnB quants to work (#12974)
1 parent d46d490 commit cb944d5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

vllm/model_executor/layers/quantization/bitsandbytes.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,16 @@ def is_layer_skipped_bnb(prefix: str, llm_int8_skip_modules: List[str]):
133133
components = prefix.split('.')
134134

135135
# Check if any of the skip modules exactly matches any component
136-
return any(module_name in components
137-
for module_name in llm_int8_skip_modules)
136+
substr_check = any(module_name in components
137+
for module_name in llm_int8_skip_modules)
138+
139+
# Allow certain layers to not be quantized
140+
set_components = set(".".join(components[:i + 1])
141+
for i in range(len(components)))
142+
set_llm_int8_skip_modules = set(llm_int8_skip_modules)
143+
prefix_check = len(set_llm_int8_skip_modules & set_components) != 0
144+
145+
return substr_check or prefix_check
138146

139147

140148
class BitsAndBytesLinearMethod(LinearMethodBase):

0 commit comments

Comments
 (0)