Skip to content
Back to skills

Lora Guided Importance

ASecurity

Compute LoRAPrune's LoRA-gradient-only Taylor importance estimate for structured pruning without frozen base-weight gradients.

  • 247 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 9, 2026
testingpythonbashbackend

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill lora_guided_importance --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Lora Guided Importance?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Lora Guided Importance
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-lora-guided-importance/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-lora-guided-importance)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: lora_guided_importance
description: Compute LoRAPrune's LoRA-gradient-only Taylor importance estimate for structured pruning without frozen base-weight gradients.
---

# LoRA-Guided Importance

Use this skill when implementing or checking LoRAPrune-style pruning criteria for a LoRA-adapted linear module. Do not use it for ordinary magnitude pruning or for methods that explicitly require gradients of the frozen pretrained weights.

## Inputs

- `W0`: frozen base matrix shaped `(d, k)`.
- `B`: LoRA matrix shaped `(d, r)`.
- `A`: LoRA matrix shaped `(r, k)`.
- `grad_B` and `grad_A`: gradients from the current calibration batch.

The contract deliberately has no `grad_W0` input.

## Outputs

- Elementwise nonnegative importance matrix shaped like `W0`.
- Diagnostics with `uses_base_gradients: false` and shape/rank metadata.

## Workflow

1. Validate all matrix dimensions and reject accidental broadcasting.
2. Compute `BA = B @ A`.
3. Approximate `dL/d(BA)` as `grad_B @ A + B @ grad_A - grad_B @ grad_A`.
4. Return `((approx_grad) * (W0 + BA)) ** 2` elementwise.
5. Pass the importance matrix to a structured grouping skill; do not threshold individual weights here.

## Validation

Run:

```bash
python /share/project/yuyang/workspace/Paper2Skills/Distiller/skills/module-to-skill/scripts/validate_skill_tree.py <this_skill_dir> --run-tests
```

The included tests verify the exact formula, zero-gradient behavior, and shape mismatch handling.

## Limitations

This skill implements the criterion, not the whole pruning loop. It assumes a dense matrix representation in small examples; large model implementations should call the same formula on tensor backends while preserving the no-base-gradient invariant.

Files in this skill

  • SKILL.md1.7 KB
  • scripts/lora_importance.py2.6 KB
  • tests/test_cli_lora_importance.py887 B
  • tests/test_lora_importance.py937 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.