Skip to content
Back to skills

Attention Path Expansion

ASecurity

Compute frozen-attention direct, head, and virtual-head path contributions for attention-only circuits.

  • 247 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 9, 2026
toolsgit

Security analysis

A100/100

Scanned September 9, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Attention Path Expansion?

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

Security grade badge for Attention Path Expansion
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-attention-path-expansion/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-attention-path-expansion)

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

SKILL.md
---
name: attention_path_expansion
description: Compute frozen-attention direct, head, and virtual-head path contributions for attention-only circuits.
---

# Attention Path Expansion

Use this skill when you have fixed or frozen attention patterns and want to decompose attention-only logits into additive circuit paths. It is suited for toy transformers, ablations, and mechanism checks inspired by Transformer Circuits. Do not use it for full transformers with changing layer normalization or MLP paths unless those parts are explicitly separated.

## Inputs

- Token ids and an embedding matrix.
- Unembedding matrix.
- One or more attention patterns shaped destination-position by source-position.
- Matching OV matrices shaped model-by-model.

## Outputs

- Direct residual-to-logit contribution.
- First-order per-head contributions.
- Optional virtual-head contribution for a two-head sequence.
- Maximum consistency error against explicit frozen-attention forward computation.

## Workflow

1. Embed tokens into residual states.
2. Compute direct logits through the unembedding.
3. Apply each head as `attention @ residual @ OV` and unembed the result.
4. For two sequential heads, compute the virtual contribution `A2 @ A1 @ residual @ OV1 @ OV2`.
5. Compare the expanded sum with an explicit sequential frozen-attention forward pass.

## Validation

Run the deterministic tests or validate with the module-to-skill tree validator.

## Limitations

The script implements the paper's simplified attention-only setting with supplied attention patterns. It intentionally does not implement softmax QK score construction.

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.