Skip to content

Commit e30f336

Browse files
committed
Rename package and release materials to NodeLens.
1 parent 26cb299 commit e30f336

576 files changed

Lines changed: 1095 additions & 88523 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ jobs:
2626
pip install "black==25.9.0" isort flake8 mypy ruff
2727
2828
- name: Run black (code formatting)
29-
run: black --check --diff src/alignment/ tests/ scripts/
29+
run: black --check --diff src/nodelens/ tests/ scripts/
3030

3131
- name: Run isort (import sorting)
32-
run: isort --check-only --diff --profile black src/alignment/ tests/ scripts/
32+
run: isort --check-only --diff --profile black src/nodelens/ tests/ scripts/
3333

3434
- name: Run flake8 (linting)
35-
run: flake8 src/alignment/ tests/ scripts/ --max-line-length=100 --ignore=E203,W503 || echo "Flake8 has warnings"
35+
run: flake8 src/nodelens/ tests/ scripts/ --max-line-length=100 --ignore=E203,W503 || echo "Flake8 has warnings"
3636

3737
- name: Run mypy (type checking)
38-
run: mypy src/alignment/ --ignore-missing-imports --no-strict-optional || echo "Type checking has warnings"
38+
run: mypy src/nodelens/ --ignore-missing-imports --no-strict-optional || echo "Type checking has warnings"

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ jobs:
3636
with:
3737
files: dist/*
3838
body: |
39-
Public research-code release for LossLens.
39+
Public research-code release for NodeLens.
4040
41-
The Python package is currently imported as `alignment`.
41+
The Python package is imported as `nodelens`.
4242
4343
## Install From Source
4444
4545
```bash
46-
git clone https://github.com/KempnerInstitute/alignment.git
47-
cd alignment
46+
git clone https://github.com/KempnerInstitute/nodelens.git
47+
cd nodelens
4848
pip install -e .
4949
```
5050

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
4646
- name: Run tests
4747
run: |
48-
pytest tests/ -v --cov=src/alignment --cov-report=xml --cov-report=html --cov-report=term-missing --tb=short -ra
48+
pytest tests/ -v --cov=src/nodelens --cov-report=xml --cov-report=html --cov-report=term-missing --tb=short -ra
4949
5050
- name: Check coverage threshold
5151
run: |

CITATION.cff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
cff-version: 1.2.0
22
message: "If you use this code or the Supernodes and SCAR artifacts, please cite the paper and archived release."
3-
title: "LossLens"
3+
title: "NodeLens"
44
version: "0.2.0"
5-
repository-code: "https://github.com/KempnerInstitute/alignment"
6-
url: "https://github.com/KempnerInstitute/alignment"
5+
repository-code: "https://github.com/KempnerInstitute/nodelens"
6+
url: "https://github.com/KempnerInstitute/nodelens"
77
license: "MIT"
88
authors:
99
- family-names: "Cherilyn"
@@ -23,7 +23,7 @@ preferred-citation:
2323
given-names: "Houman"
2424
affiliation: "Kempner Institute at Harvard University"
2525
year: 2026
26-
url: "https://github.com/KempnerInstitute/alignment"
26+
url: "https://github.com/KempnerInstitute/nodelens"
2727
identifiers:
2828
- type: url
2929
value: "https://huggingface.co/datasets/hsafaai/supernodes-scar-artifacts"

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# LossLens
1+
# NodeLens
22

3-
Loss-sensitive neural network analysis and structured pruning tools.
3+
Node and channel metrics for neural network interpretability, importance, and interventions.
44

5-
[![Tests](https://github.com/KempnerInstitute/alignment/actions/workflows/test.yml/badge.svg)](https://github.com/KempnerInstitute/alignment/actions/workflows/test.yml)
6-
[![Lint](https://github.com/KempnerInstitute/alignment/actions/workflows/lint.yml/badge.svg)](https://github.com/KempnerInstitute/alignment/actions/workflows/lint.yml)
7-
[![Documentation](https://github.com/KempnerInstitute/alignment/actions/workflows/docs.yml/badge.svg)](https://github.com/KempnerInstitute/alignment/actions/workflows/docs.yml)
8-
[![Release](https://github.com/KempnerInstitute/alignment/actions/workflows/release.yml/badge.svg)](https://github.com/KempnerInstitute/alignment/actions/workflows/release.yml)
5+
[![Tests](https://github.com/KempnerInstitute/nodelens/actions/workflows/test.yml/badge.svg)](https://github.com/KempnerInstitute/nodelens/actions/workflows/test.yml)
6+
[![Lint](https://github.com/KempnerInstitute/nodelens/actions/workflows/lint.yml/badge.svg)](https://github.com/KempnerInstitute/nodelens/actions/workflows/lint.yml)
7+
[![Documentation](https://github.com/KempnerInstitute/nodelens/actions/workflows/docs.yml/badge.svg)](https://github.com/KempnerInstitute/nodelens/actions/workflows/docs.yml)
8+
[![Release](https://github.com/KempnerInstitute/nodelens/actions/workflows/release.yml/badge.svg)](https://github.com/KempnerInstitute/nodelens/actions/workflows/release.yml)
99
[![Python](https://img.shields.io/badge/python-%3E%3D3.8-3776AB?logo=python&logoColor=white)](pyproject.toml)
1010
[![Artifacts](https://img.shields.io/badge/Hugging%20Face-artifacts-ffcc33)](https://huggingface.co/datasets/hsafaai/supernodes-scar-artifacts)
1111
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
1212

13-
LossLens is a research codebase for studying which channels, neurons, and
14-
features matter most for model behavior. The current Python package is imported
15-
as `alignment` for backward compatibility.
13+
NodeLens is a research codebase for studying which channels, neurons, and
14+
features matter most for model behavior. The Python package is imported as
15+
`nodelens`.
1616

1717
The repository supports two related workflows:
1818

@@ -47,10 +47,10 @@ LLM backends through Hugging Face causal language models.
4747
## Installation
4848

4949
```bash
50-
git clone https://github.com/KempnerInstitute/alignment.git
51-
cd alignment
50+
git clone https://github.com/KempnerInstitute/nodelens.git
51+
cd nodelens
5252
conda env create -f environment.yml
53-
conda activate alignment
53+
conda activate nodelens
5454
pip install -e .
5555
```
5656

@@ -87,7 +87,7 @@ python projects/supernodes_scar/scripts/verify_hf_artifacts.py \
8787
## Paper Releases
8888

8989
Paper-specific release material lives under `projects/`. Reusable library code
90-
stays in `src/alignment`, while each project folder records the exact configs,
90+
stays in `src/nodelens`, while each project folder records the exact configs,
9191
artifact layout, reproducibility notes, and release checklist for a paper.
9292

9393
Current project:
@@ -112,7 +112,7 @@ Derived artifacts for this project are staged on Hugging Face:
112112
## Repository Layout
113113

114114
```text
115-
alignment/
115+
nodelens/
116116
|-- configs/
117117
| |-- prune_llm/ # LLM and SCAR configs
118118
| |-- vision_prune/ # Vision pruning configs
@@ -121,7 +121,7 @@ alignment/
121121
|-- scripts/
122122
| |-- run_experiment.py # Main experiment entry point
123123
| `-- run_analysis.py # Post-hoc analysis
124-
|-- src/alignment/
124+
|-- src/nodelens/
125125
| |-- analysis/ # Visualization, clustering, cascade analysis
126126
| |-- experiments/ # Experiment classes
127127
| |-- metrics/ # Importance metrics

RELEASE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ draft files, cluster paths, logs, or model weights.
55

66
## Before Tagging
77

8-
- Confirm that paper-facing code lives in `src/alignment/` and
8+
- Confirm that paper-facing code lives in `src/nodelens/` and
99
`projects/supernodes_scar/`.
1010
- Confirm that private draft material under `drafts/` is not tracked for the
1111
public release.
@@ -19,7 +19,7 @@ draft files, cluster paths, logs, or model weights.
1919

2020
```bash
2121
python -m pip install -e .
22-
PYTHONPATH=src python -c "import alignment; print(alignment.__version__)"
22+
PYTHONPATH=src python -c "import nodelens; print(nodelens.__version__)"
2323
pytest tests/unit -q
2424
cd docs && make html
2525
```

configs/README.md

Lines changed: 75 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,70 @@
11
# Configuration Files
22

3-
## Structure
3+
NodeLens experiments are driven by YAML configs. The same runner is used for
4+
small examples, vision pruning studies, and LLM supernode/SCAR experiments:
45

6+
```bash
7+
python scripts/run_experiment.py --config path/to/config.yaml
58
```
9+
10+
The Python package is imported as `nodelens`.
11+
12+
## Directory Map
13+
14+
```text
615
configs/
7-
├── template.yaml # Complete template with all options
8-
├── unified_template.yaml # Unified format template
9-
├── vision_prune/ # Vision model pruning configs
10-
| ├── resnet18_cifar10_full.yaml
11-
| ├── resnet18_cifar10_unified.yaml # Unified format version
12-
| ├── resnet50_imagenet100.yaml
13-
| ├── vgg16_cifar10_full.yaml
14-
| └── mobilenetv2_cifar10_full.yaml
15-
├── prune_llm/ # LLM pruning configs
16-
| ├── llama3_8b_full.yaml
17-
| ├── llama3_8b_unified.yaml # Unified format version
18-
| ├── llama2_7b_full.yaml
19-
| ├── mistral_7b_full.yaml
20-
| └── qwen2_7b_full.yaml
21-
└── examples/ # Example configs
22-
├── mnist_basic.yaml
23-
├── resnet_pruning.yaml
24-
└── llm_alignment.yaml
16+
|-- template.yaml # Full legacy-format reference
17+
|-- unified_template.yaml # Unified-format reference
18+
|-- examples/ # Small runnable examples and smoke tests
19+
|-- vision_prune/ # Vision clustering, halo, and channel pruning
20+
`-- prune_llm/ # LLM supernode, SCAR, and paper-scale configs
2521
```
2622

27-
## Usage
23+
Large private sweep grids are not kept in the public config tree. Public
24+
release material for a paper lives under `projects/<project_name>/`; reusable
25+
experiment configs live here.
26+
27+
## Which Config Should I Use?
28+
29+
| Goal | Start with |
30+
|------|------------|
31+
| Quick install check on MNIST | `configs/examples/mnist_basic.yaml` |
32+
| Small vision pruning example | `configs/examples/resnet_pruning.yaml` |
33+
| Vision metric clustering and halo analysis | `configs/vision_prune/resnet18_cifar10_unified.yaml` |
34+
| Larger vision pruning benchmark | `configs/vision_prune/resnet50_imagenet100_unified.yaml` |
35+
| Minimal LLM supernode example | `configs/examples/llm_alignment.yaml` |
36+
| Main 8B LLM SCAR suite | `configs/prune_llm/llama3_8b_unified.yaml` |
37+
| Cross-model 7B/8B LLM checks | `configs/prune_llm/{llama2,mistral,qwen2}_7b_unified.yaml` |
38+
| 70B mechanism check | `configs/prune_llm/llama3_70b_scale_mechanism.yaml` |
39+
| 70B structured pruning curves | `configs/prune_llm/llama3_70b_scale_pruning_curves.yaml` |
40+
| OLMo checkpoint trajectory | `configs/prune_llm/olmo2_7b_ckpt_template.yaml` |
41+
42+
## Experiment Types
43+
44+
| Type | Used for | Typical configs |
45+
|------|----------|-----------------|
46+
| `alignment_analysis` | General activation, alignment, and pruning analysis for small models | `configs/examples/*.yaml` |
47+
| `cluster_analysis` | Vision channel metrics, metric-space clustering, halo analysis, cascade tests, and structured pruning | `configs/vision_prune/*.yaml` |
48+
| `llm_alignment` | Hugging Face causal LMs, SCAR loss-proxy metrics, supernodes, halos, perplexity, and LLM structured pruning | `configs/prune_llm/*.yaml` |
49+
| `vision_synergy` | Older focused vision synergy experiments | `configs/examples/vision_synergy.yaml` |
50+
51+
## Common Commands
2852

2953
```bash
30-
python scripts/run_experiment.py --config configs/cluster_analysis/resnet18_cifar10_full.yaml
31-
python scripts/run_experiment.py --config configs/paper/llama3_8b_full.yaml
32-
python scripts/run_experiment.py --config configs/examples/resnet_pruning.yaml
33-
```
54+
# Quick smoke test
55+
python scripts/run_experiment.py --config configs/examples/mnist_basic.yaml
3456

35-
## Experiment Types
57+
# Vision clustering and pruning
58+
python scripts/run_experiment.py --config configs/vision_prune/resnet18_cifar10_unified.yaml
59+
60+
# LLM supernode and SCAR analysis
61+
python scripts/run_experiment.py --config configs/prune_llm/llama3_8b_unified.yaml
3662

37-
| Type | Description |
38-
|------|-------------|
39-
| `alignment_analysis` | General alignment metrics |
40-
| `llm_alignment` | LLM supernode/SCAR analysis |
41-
| `cluster_analysis` | Metric-space clustering with halos |
63+
# Override output location without editing the YAML
64+
python scripts/run_experiment.py \
65+
--config configs/prune_llm/llama3_8b_unified.yaml \
66+
--base-output-dir /path/to/results
67+
```
4268

4369
## Configuration Blocks
4470

@@ -55,6 +81,10 @@ python scripts/run_experiment.py --config configs/examples/resnet_pruning.yaml
5581
| `pruning` | Strategy, sparsity_levels, scoring |
5682
| `llm` | LLM-specific: scar_metrics, evaluate_perplexity |
5783

84+
Not every block is used by every experiment type. Vision configs usually use
85+
`clustering`, `halo_analysis`, and `cascade_analysis`; LLM configs usually use
86+
`supernode`, `halo_analysis`, `llm`, and `pruning`.
87+
5888
## Metrics
5989

6090
Available metrics for `metrics.enabled`:
@@ -95,24 +125,32 @@ cascade_analysis:
95125
n_remove_per_cluster: 5
96126
```
97127
98-
## LLM Configuration
128+
## Minimal LLM Configuration
99129
100130
```yaml
101-
experiment_type: llm_alignment
131+
experiment:
132+
type: "llm_alignment"
102133

103-
model_config:
134+
model:
135+
name: "hf_causal_lm"
104136
model_id: "meta-llama/Llama-3.1-8B"
105-
torch_dtype: "bfloat16"
137+
dtype: "bfloat16"
106138

107-
do_scar_metrics: true
108-
scar_num_samples: 100
139+
metrics:
140+
scar:
141+
enabled: true
142+
num_samples: 64
143+
max_length: 512
109144

110145
supernode:
111146
enabled: true
112147
core_fraction: 0.01
113148
protect_core: true
114149
```
115150
151+
LLM configs require access to the model provider, enough GPU memory, and the
152+
right license acceptance for gated models.
153+
116154
## Unified Configuration Format
117155
118156
The framework supports a **unified configuration format** that works consistently
@@ -190,7 +228,7 @@ output:
190228
### Loading Unified Configs
191229

192230
```python
193-
from alignment.configs import load_unified_config
231+
from nodelens.configs import load_unified_config
194232
195233
# Works with both old and unified formats!
196234
config = load_unified_config("configs/vision_prune/resnet18_cifar10_unified.yaml")

configs/examples/alexnet_pruning.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ model:
1717
# ImageNet dataset path on Kempner cluster
1818
dataset:
1919
name: "imagenet"
20-
data_path: "/n/holylfs06/LABS/kempner_shared/Everyone/testbed/vision/imagenet_1k"
20+
data_path: "/path/to/datasets/imagenet_1k"
2121
batch_size: 128
2222
num_workers: 4
2323

configs/examples/llama3_extended_analysis.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
# 3. Cross-layer redundancy (redundancy with previous layer)
99
# 4. Layer transition efficiency (new information per layer)
1010
#
11-
# Based on theoretical framework in drafts/alignment_notes/alignment_red.tex
11+
# Use this as a heavier LLM analysis example after the smaller llm_alignment
12+
# example is working in your environment.
1213
# ============================================================================
1314

1415
experiment:

configs/examples/resnet_pruning.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ model:
1616

1717
# Dataset options:
1818
# - cifar10/cifar100: ./data (auto-downloads, but ResNet expects 224x224)
19-
# - imagenet: /n/holylfs06/LABS/kempner_shared/Everyone/testbed/vision/imagenet_1k
19+
# - imagenet: /path/to/datasets/imagenet_1k
2020
dataset:
2121
name: "imagenet"
22-
data_path: "/n/holylfs06/LABS/kempner_shared/Everyone/testbed/vision/imagenet_1k"
22+
data_path: "/path/to/datasets/imagenet_1k"
2323
batch_size: 128
2424
num_workers: 4
2525

0 commit comments

Comments
 (0)