-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpyproject.toml
More file actions
202 lines (187 loc) · 6.24 KB
/
Copy pathpyproject.toml
File metadata and controls
202 lines (187 loc) · 6.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "t2i-interp-toolkit"
version = "0.1.0"
description = "Text-to-Image Interpretation Toolkit with SAE-based analysis and steering"
readme = "README.md"
requires-python = ">=3.10"
license = {text = "MIT"}
authors = [
{name = "Luka", email = "luka@example.com"}
]
keywords = ["diffusion", "interpretability", "SAE", "steering", "text-to-image", "sparse-autoencoders"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"diffusers>=0.34.0",
"transformers>=4.55.0",
"torch>=2.0.0",
"accelerate>=1.10.0",
"pillow>=10.0.0",
"matplotlib>=3.7.0",
"numpy>=1.24.0",
"tqdm>=4.65.0",
"loguru>=0.7.0",
"pydantic>=2.0.0",
"wandb>=0.15.0",
"datasets>=2.14.0",
"zstandard>=0.21.0",
"pyyaml>=6.0",
"hydra-core>=1.3.0",
"omegaconf>=2.3.0",
"webdataset>=1.0.2",
"nnsight>=0.7.0",
"einops>=0.8.2",
"streamlit>=1.57.0",
"pandas>=2.3.3",
"anthropic>=0.104.1",
# CLIP / FID / LPIPS scoring backends. Required because every workflow
# YAML's `metrics:` block defaults them on — the paper's headline
# Figure 2 sweep reports CLIP / FID / LPIPS per cell, and the Streamlit
# Results page surfaces them as metric tiles. Heavier than the rest of
# the dependency set but unavoidable for a paper-faithful install.
"open-clip-torch>=2.24.0",
"lpips>=0.1.4",
"clean-fid>=0.1.35",
]
[project.optional-dependencies]
dev = [
"pytest>=7.4.0",
"pytest-cov>=4.1.0",
"ruff>=0.8.0",
"mypy>=1.5.0",
"pre-commit>=3.5.0",
# Needed by `make notebook` + nbconvert (notebook execution in tests/CI).
"jupyter>=1.0.0",
"nbconvert>=7.0.0",
"nbformat>=5.0.0",
"nbstripout>=0.7.0",
]
ray = [
"ray>=2.7.0",
]
notebook = [
"jupyter>=1.0.0",
"ipywidgets>=8.0.0",
"matplotlib>=3.7.0",
]
[project.scripts]
t2i = "t2i_interp.cli:main"
t2i-steer = "t2i_interp.scripts.run_steer:main"
t2i-stitch = "t2i_interp.scripts.run_stitch:main"
t2i-sae = "t2i_interp.scripts.run_sae:main"
t2i-localise = "t2i_interp.scripts.run_localisation:main"
t2i-migrate-sae = "t2i_interp.scripts.migrate_sae_ckpt:main"
[project.urls]
Homepage = "https://github.com/Social-AI-Studio/T2I_Interp_toolkit"
Repository = "https://github.com/Social-AI-Studio/T2I_Interp_toolkit"
Issues = "https://github.com/Social-AI-Studio/T2I_Interp_toolkit/issues"
[tool.hatch.build.targets.wheel]
packages = ["t2i_interp", "dictionary_learning"]
[tool.hatch.build.targets.wheel.force-include]
# Ensure __init__.py stubs are included in config subpackages
"t2i_interp/config/__init__.py" = "t2i_interp/config/__init__.py"
"t2i_interp/scripts/__init__.py" = "t2i_interp/scripts/__init__.py"
[tool.ruff]
line-length = 100
target-version = "py310"
# `dictionary_learning/` is a vendored third-party fork — upstream owns its
# style. `notebooks/` use exploratory conventions (top-level capitalized
# constants, unused fixtures) where strict linting fights the medium.
extend-exclude = ["dictionary_learning", "notebooks"]
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
"N", # pep8-naming
]
ignore = [
"E501", # line too long (handled by formatter)
"B008", # do not perform function calls in argument defaults
"C901", # too complex
"E741", # ambiguous variable name
# Universal PyTorch / torchvision aliases — `import torch.nn.functional as F`
# and `import torchvision.transforms as T` are the canonical idioms.
"N812",
# PyTorch hook control-flow signals (e.g. `StopForward`) are exceptions
# by mechanism, not errors by meaning — the `*Error` suffix is misleading.
"N818",
]
[tool.ruff.lint.per-file-ignores]
# N999 fires on every __init__.py because ruff resolves module names relative
# to the repo root (`T2I_Interp_toolkit`) which has caps; the actual Python
# package is the lowercase `t2i_interp`. Unfixable without renaming the repo.
"__init__.py" = ["N999"]
# N806 (uppercase locals) is allowed in tensor-shape-heavy modules where
# B/N/D/H/W/L/S/A/F/R/U/X are standard ML/PyTorch shape conventions
# (B=batch, N=batch dim, D=feature dim, H=height, W=width, X=design matrix).
# Lowercasing makes math-dense code harder to read for ML reviewers.
"t2i_interp/intervention.py" = ["N806"]
"t2i_interp/linear_steering.py" = ["N806", "N803"]
"t2i_interp/loreft.py" = ["N806"]
"t2i_interp/t2i.py" = ["N806"]
"t2i_interp/utils/T2I/attn_policy.py" = ["N806"]
"t2i_interp/utils/T2I/buffer.py" = ["N806"]
"t2i_interp/utils/T2I/collect_latents.py" = ["N806"]
"t2i_interp/utils/concept_detection.py" = ["N806"]
"t2i_interp/utils/generic.py" = ["N806"]
"t2i_interp/utils/nethook.py" = ["N806"]
"t2i_interp/utils/utils.py" = ["N806", "N803"]
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
[tool.mypy]
python_version = "3.10"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = false
disallow_incomplete_defs = false
check_untyped_defs = false
disallow_untyped_decorators = false
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_unreachable = true
strict_equality = true
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "dictionary_learning.*"
ignore_errors = true
[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py", "*_test.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = [
"--strict-markers",
"--tb=short",
"--cov=t2i_interp",
"--cov-report=term-missing",
"--cov-report=html",
]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"integration: marks tests as integration tests",
"unit: marks tests as unit tests",
]
[dependency-groups]
dev = [
"nbstripout>=0.9.1",
"playwright>=1.60.0",
]