Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
35 changes: 14 additions & 21 deletions examples/sparse_2of4_quantization_fp8/llama3_8b_2of4.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from llmcompressor import oneshot
from llmcompressor.modifiers.obcq import SparseGPTModifier
from llmcompressor.modifiers.pruning import ConstantPruningModifier
from llmcompressor.modifiers.quantization import QuantizationModifier

# Configuration
Expand Down Expand Up @@ -52,29 +51,23 @@ def get_recipe(fp8_enabled):
save_dir = MODEL_ID.split("/")[1] + "2of4-sparse"

if fp8_enabled:
base_recipe.extend(
[
QuantizationModifier(
targets=["Linear"],
ignore=["lm_head"],
scheme="FP8_DYNAMIC",
),
ConstantPruningModifier(
targets=[
r"re:.*q_proj.weight",
r"re:.*k_proj.weight",
r"re:.*v_proj.weight",
r"re:.*o_proj.weight",
r"re:.*gate_proj.weight",
r"re:.*up_proj.weight",
r"re:.*down_proj.weight",
],
start=0,
),
]
base_recipe.append(
QuantizationModifier(
targets=["Linear"],
ignore=["lm_head"],
scheme="FP8_DYNAMIC",
)
)
save_dir = MODEL_ID.split("/")[1] + "2of4-W8A8-FP8-Dynamic-Per-Token"

# check that asymmetric quantization is not being used
q_scheme = base_recipe[1].scheme
if not isinstance(q_scheme, str) and not q_scheme["weights"].symmetric:
raise ValueError(
"Asymmetric quantization with 2of4 sparsity is not supported by vLLM. "
"Please use symmetric quantization"
)

return base_recipe, save_dir


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def test_constant_pruning_modifier_e2e(model, optimizer):
state.update(
model=model,
optimizer=optimizer(model.parameters(), lr=0.1),
start=0,
)
modifier = ConstantPruningModifier(
targets="__ALL_PRUNABLE__",
Expand Down