Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

pruning-kernel-v1

Version: 1.0.0

Pruning kernel — WANDA and magnitude-based weight pruning

References

  • Sun et al. (2023) A Simple and Effective Pruning Approach for Large Language Models (WANDA)
  • Han et al. (2015) Learning both Weights and Connections for Efficient Neural Networks

Equations

magnitude_score

$$ score(w_ij) = |w_ij| $$

Domain: $w_ij: weight value$

Codomain: $score in [0, +inf)$

Invariants:

  • $score >= 0$
  • $score = 0 iff w_ij = 0$

sparsity

$$ s = |{w : w = 0}| / |w| $$

Domain: $w: weight tensor$

Codomain: $s in [0, 1]$

Invariants:

  • $s = 0 means no pruning$
  • $s = 1 means all weights zeroed$
  • $After pruning with target s, achieved sparsity within 0.1% of s$

wanda_score

$$ score(w_ij) = |w_ij| * ||X_j||_2 $$

Domain: $w_ij: weight, X_j: activation column vector$

Codomain: $score in [0, +inf)$

Invariants:

  • $score >= 0 (product of norms)$
  • $score = 0 iff w_ij = 0 or X_j = 0$

Proof Obligations

#TypePropertyFormal
1invariantSparsity target met$Achieved sparsity within +/-0.1% of target$
2orderingScore ordering preserved$All pruned weights have score <= all surviving weights$
3invariantWANDA activation dependency$Same weight magnitude + different activation norms => different WANDA scores$
4invariantZero sparsity is identity$prune(model, sparsity=0) returns original model unchanged$
5invariantFull sparsity zeroes all$prune(model, sparsity=1.0) zeroes all prunable weights$
6invariantEmbedding layer excluded$Embedding and output projection weights untouched by pruning$

Kernel Phases

  1. compute_scores: Compute importance score for each weight — scores are non-negative
  2. determine_threshold: Find threshold score for target sparsity — threshold partitions weights into keep/prune sets
  3. apply_mask: Zero out weights below threshold — sparsity matches target within tolerance

Falsification Tests

IDRulePredictionIf Fails
FALSIFY-PRUNE-001Sparsity guaranteeExactly 50% of weights zero after prune –sparsity 0.5Threshold computation error or layer exclusion bug
FALSIFY-PRUNE-002Score orderingAll pruned weights have score <= all surviving weightsSorting or partitioning algorithm bug
FALSIFY-PRUNE-003Identity at zero sparsityPruning with sparsity=0 returns original weightsOff-by-one in threshold or mask computation

Kani Harnesses

IDObligationBoundStrategy
KANI-PRUNE-001PRUNE-INV-00116stub_float

QA Gate

Pruning Contract (F-PRUNE-001)

Weight pruning correctness for Albor model compression

Checks: sparsity_guarantee, score_ordering, identity_at_zero

Pass criteria: All 3 falsification tests pass + Kani sparsity harness verifies