Add AST (Audio Spectrogram Transformer) Adapter#1484
Conversation
map HF ASTConfig to HookedTransformerConfig build custom ASTEmbed w/ 16x16 Conv2d patch extraction translate q/k/v_proj and fc1/fc2 dense weights to TL standard blocks implement CLS and Distillation token averaging for AST MLP head apply dual layernorm architecture to pooled tokens draft local matrix parity test suite (current max diff: ~0.05)
|
Thanks for putting this together @dylanberens! The AST domain work is great, the Q/K/V/O and bias reshapes, MLP transposes, the overlapping-patch Conv2d, the cls-distillation-patches token order, and the pooled dual-token + dual-LayerNorm head are all correct. We will need to address & adjust the approach: this is written against the legacy HookedTransformer Primary issues with the current code:
To make this mergeable:
Also, a couple repo items: make sure to drop Happy to re-review once it's on the TransformerBridge pattern. |
Description
This PR introduces full support for the Audio Spectrogram Transformer (AST) architecture with TransformerLens.
Key Engineering Details
Because AST is built on a ViT-base backbone but processes continuous audio spectrogrmas, several important architectural bridges were necessary:
Adds ast.py (architecture adapter) and test_ast_adapter.py (verifying FP32 mathematical parity with max logit diff < 1e-4).
Fixes # 1484
Type of change
Checklist: