Imported from yzj623/pplab (
basicagent-skill/skill_library/paperbench/adaptive-pruning/skill/wanda_outlier_pruning/structured_sparsity_patterns/SKILL.md). Install upstream withnpx skills add yzj623/pplab --skill structured_sparsity_patterns. Copyright stays with the author.
Structured Sparsity Patterns
Use this skill when a Wanda recovery or implementation needs 2:4, 4:8, or other N:M pruning masks. It operates on score matrices after activation-aware scoring has already been computed.
Inputs
- Score matrix shaped outputs by inputs.
prune_n: number of entries to prune in each group.prune_m: group width along the input-channel dimension.
Outputs
- Boolean mask with exactly
prune_ntrue values per complete group in each row. - Metadata describing complete groups, ignored tail width, and achieved sparsity.
Workflow
- Validate
0 < prune_n <= prune_m. - Split each row into consecutive groups of width
prune_m. - In each complete group, mark the
prune_nlowest scores for pruning with deterministic tie-breaking by column index. - Leave incomplete tail groups unpruned unless the caller pads them explicitly.
Validation
Tests assert exact group counts and unpruned tail behavior.
Limitations
The skill only creates masks. Applying them and checking model quality belongs to an evaluation skill.