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

Update Test Recipes for Latest Modifier Changes #2326

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
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
27 changes: 1 addition & 26 deletions tests/sparseml/transformers/obcq/recipes/quant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,7 @@ test_stage:
[["re:.*q_proj", "re:.*k_proj", "re:.*v_proj"], "re:.*input_layernorm"],
[["re:.*gate_proj", "re:.*up_proj"], "re:.*post_attention_layernorm"]
]
LegacyQuantizationModifier:
ignore:
- LlamaRotaryEmbedding
- LlamaRMSNorm
- SiLU
- model.layers.0.mlp.down_proj
- model.layers.1.mlp.down_proj
- model.layers.2.mlp.down_proj
- model.layers.3.mlp.down_proj
- model.layers.4.mlp.down_proj
- model.layers.5.mlp.down_proj
scheme_overrides:
Embedding:
input_activations: null
weights:
num_bits: 8
symmetric: False
GPTQModifier:
block_size: 128
sequential_update: False
percdamp: 0.01
targets: [
"model.layers.0",
"model.layers.1",
"model.layers.2",
"model.layers.3",
"model.layers.4",
"model.layers.5"
]
percdamp: 0.01
37 changes: 7 additions & 30 deletions tests/sparseml/transformers/obcq/recipes/quant_and_sparse.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
test_stage:
obcq_modifiers:
SparseGPTModifier:
sparsity: 0.5
block_size: 128
sequential_update: False
percdamp: 0.01
mask_structure: "0:0"
SmoothQuantModifier:
smoothing_strength: 0.5
mappings: [
Expand All @@ -11,13 +17,6 @@ test_stage:
- LlamaRotaryEmbedding
- LlamaRMSNorm
- SiLU
- model.layers.0.mlp.down_proj
- model.layers.1.mlp.down_proj
- model.layers.2.mlp.down_proj
- model.layers.3.mlp.down_proj
- model.layers.4.mlp.down_proj
- model.layers.5.mlp.down_proj
post_oneshot_calibration: True
scheme_overrides:
Embedding:
input_activations: null
Expand All @@ -27,26 +26,4 @@ test_stage:
GPTQModifier:
block_size: 128
sequential_update: False
percdamp: 0.01
targets: [
"model.layers.0",
"model.layers.1",
"model.layers.2",
"model.layers.3",
"model.layers.4",
"model.layers.5"
]
SparseGPTModifier:
sparsity: 0.5
block_size: 128
sequential_update: False
percdamp: 0.01
mask_structure: "0:0"
targets: [
"model.layers.0",
"model.layers.1",
"model.layers.2",
"model.layers.3",
"model.layers.4",
"model.layers.5"
]
percdamp: 0.01
5 changes: 2 additions & 3 deletions tests/sparseml/transformers/obcq/recipes/sparse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ test_stage:
block_size: 128
sequential_update: False
percdamp: 0.01
mask_structure: "0:0"
targets: [
"model.layers.0",
"model.layers.1",
"lm_head"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can we remove this target?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, because it's linear layer and will be caught by the logic automatically?

]
]
mask_structure: "0:0"
4 changes: 0 additions & 4 deletions tests/sparseml/transformers/obcq/test_obcq_sparsity.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ def test_sparsities(self):

model = get_session_model()

lm_head_sparsity = tensor_sparsity(model.lm_head.weight)
assert math.isclose(lm_head_sparsity.item(), self.sparsity, rel_tol=1e-4)
layer_1_sparse = tensor_sparsity(model.model.layers[1].self_attn.k_proj.weight)
assert math.isclose(layer_1_sparse.item(), self.sparsity, rel_tol=1e-4)
layer_2_dense = tensor_sparsity(model.model.layers[2].self_attn.k_proj.weight)
Expand Down Expand Up @@ -118,8 +116,6 @@ def test_sparsities_gpu(self):

model = get_session_model()

lm_head_sparsity = tensor_sparsity(model.lm_head.weight)
assert math.isclose(lm_head_sparsity.item(), self.sparsity, rel_tol=1e-4)
layer_1_sparse = tensor_sparsity(model.model.layers[1].self_attn.k_proj.weight)
assert math.isclose(layer_1_sparse.item(), self.sparsity, rel_tol=1e-4)
layer_2_dense = tensor_sparsity(model.model.layers[2].self_attn.k_proj.weight)
Expand Down
Loading