deprecate remaining hooked entry points - #1592
Conversation
| **kwargs: Any, | ||
| ): | ||
| super().__init__() | ||
| warnings.warn( |
There was a problem hiding this comment.
HookedEncoder.from_pretrained("bert-base-cased") still surfaces no deprecation notices because stacklevel=2 attributes the warning to HookedEncoder.py itself and Python's default ignore::DeprecationWarning filter then drops it. Can the warning also fire at the from_pretrained entry point, the way the sibling loaders do?
| assert "4.0" in str(caught[0].message) | ||
|
|
||
|
|
||
| def test_importing_transformer_lens_emits_no_deprecation_warning(): |
There was a problem hiding this comment.
By the time this body runs, transformer_lens is already in sys.modules, so the import is a no-op that records nothing. I appended a real import-time DeprecationWarning to __init__.py and this test still passed. Is there a way to check import-time cleanliness that would fail?
| "execution_count": 56, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "outputs": [ |
There was a problem hiding this comment.
Grokking_Demo.ipynb and No_Position_Experiment.ipynb also construct HookedTransformer(cfg) in cells with empty stored outputs, and both run under make notebook-test. Can their outputs be re-recorded as well?
|
thanks for the thorough review. addressed all three items:
verified with |
| **from_pretrained_kwargs: Any, | ||
| ) -> HookedEncoder: | ||
| """Loads in the pretrained weights from huggingface. Currently supports loading weight from HuggingFace BertForMaskedLM. Unlike HookedTransformer, this does not yet do any preprocessing on the model.""" | ||
| warnings.warn( |
There was a problem hiding this comment.
Outside pytest from_pretrained sits one frame below its caller, so stacklevel=4 overshoots and CPython attributes the warning to <sys>:0 — a plain script still sees nothing, while the sibling using stacklevel=2 does surface (HookedEncoderDecoder.py:555). The depth and the filename assertion at test_deprecation_warnings.py:91 have to move together.
Summary
DeprecationWarningfrom the remaining silent legacy entry points.HookedRootModulewarning to direct construction, avoiding duplicate warnings from subclasses.Why
Users who instantiate these legacy classes directly otherwise receive no migration notice ahead of the 4.0 removal. Each warning points to
TransformerBridge.boot_transformers(...).Closes #1590
Validation
pytest tests/unit/test_deprecation_warnings.py -q— 5 passedmypy .— 385 source files, no issuespycln,isort, andblackchecks passed on changed files