|
AQIT 0.1.0
|
Functions | |
| bool | _is_heavy_weight_model (model) |
| bool | _should_skip_weight_param (str name, *, bool heavy) |
| int | _layer_from_key (str key) |
| str | _hf_matrix_label (str key) |
| object | _weight_root (model) |
| bool | _is_hf_weight_model (model) |
| float | _scalar (torch.Tensor t) |
| torch.Tensor | _to_2d (torch.Tensor w) |
| tuple[float, float] | _matrix_ranks (torch.Tensor w) |
| dict | run_weight_rank_hf (model, float collapse_threshold=0.1) |
| dict | run_weight_rank_tl (model, float collapse_threshold=0.1) |
| dict | run_weight_rank_analysis (model, float collapse_threshold=0.1) |
Variables | |
| _LAYER_RE = re.compile(r"(?:^|\.)(?:layers?|layer|block)\.?(\d+)(?:\.|$)", re.I) | |
| _EXPERT_WEIGHT_RE = re.compile(r"\.experts?\.\d+", re.I) | |
|
protected |
Definition at line 54 of file weight_rank.py.
Referenced by run_weight_rank_hf().
|
protected |
Large / MoE models fill VRAM : weight analysis must run on CPU and skip experts.
Definition at line 22 of file weight_rank.py.
Referenced by run_weight_rank_hf().
|
protected |
Definition at line 107 of file weight_rank.py.
Referenced by run_weight_rank_analysis().
|
protected |
Definition at line 49 of file weight_rank.py.
Referenced by run_weight_rank_hf().
|
protected |
Definition at line 133 of file weight_rank.py.
References _scalar(), and _to_2d().
Referenced by run_weight_rank_hf(), and run_weight_rank_tl().
|
protected |
Definition at line 119 of file weight_rank.py.
Referenced by _matrix_ranks().
|
protected |
Skip tensors that are redundant or too large for in-GPU analysis.
Definition at line 35 of file weight_rank.py.
Referenced by run_weight_rank_hf().
|
protected |
HookedTransformer attn weights are often 3D (n_heads, d_in, d_out).
Definition at line 123 of file weight_rank.py.
Referenced by _matrix_ranks().
|
protected |
Definition at line 101 of file weight_rank.py.
Referenced by run_weight_rank_hf().
| dict run_weight_rank_analysis | ( | model, | |
| float | collapse_threshold = 0.1 ) |
Compute stable rank for attention/MLP (TL) or HF-native weights.
Definition at line 237 of file weight_rank.py.
References _is_hf_weight_model(), run_weight_rank_hf(), and run_weight_rank_tl().
| dict run_weight_rank_hf | ( | model, | |
| float | collapse_threshold = 0.1 ) |
Stable rank over HuggingFace parameter names (LFM, Sarvam, etc.).
Definition at line 154 of file weight_rank.py.
References _hf_matrix_label(), _is_heavy_weight_model(), _layer_from_key(), _matrix_ranks(), _should_skip_weight_param(), and _weight_root().
Referenced by run_weight_rank_analysis().
| dict run_weight_rank_tl | ( | model, | |
| float | collapse_threshold = 0.1 ) |
Compute stable rank for Q/K/V/O and MLP matrices across all layers.
Definition at line 197 of file weight_rank.py.
References _matrix_ranks().
Referenced by run_weight_rank_analysis().
|
protected |
Definition at line 19 of file weight_rank.py.
|
protected |
Definition at line 18 of file weight_rank.py.