Skip to content

fix minor issues with lm_decomposition.py pipeline - #5

Open
mivanit wants to merge 2 commits into
ApolloResearch:feature/unifyfrom
mivanit:feature/unify
Open

fix minor issues with lm_decomposition.py pipeline#5
mivanit wants to merge 2 commits into
ApolloResearch:feature/unifyfrom
mivanit:feature/unify

Conversation

@mivanit

Copy link
Copy Markdown

Description

  1. bump torch dependency to require >2.4.1
  2. add weights_only: bool kwarg to lm_decomposition.py:main()

Motivation and Context

  1. because pytorch <=2.4.1 does not have nn.Module.set_submodule(), running lm_decomposition.py gives the error:
 File "~/apd/spd/experiments/lm/lm_decomposition.py", line 146, in main
optimize(
File "/home/miv/projects/MATS/apd/spd/run_spd.py", line 242, in optimize
layerwise_random_recon_loss = calc_layerwise_recon_loss(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/apd/spd/losses.py", line 135, in calc_layerwise_recon_loss
modified_out = model.forward_with_component(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/apd/spd/models/component_model.py", line 141, in forward_with_component
self.model.set_submodule(module_name, component)
^^^^^^^^^^^^^^^^^^^^^^^^
File "~/apd/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1729, in __getattr__
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'GPTNeoForCausalLM' object has no attribute 'set_submodule'
  1. due to pytorch vuln https://nvd.nist.gov/vuln/detail/CVE-2025-32434 huggingface transformers library doesn't allow loading with weights_only=True, adding a kwarg for this in lm_decomposition.py:main() which is passed on to load_pretrained()

Does this PR introduce a breaking change?

Probably not. Most likely to cause issues is the bumping of the pytorch dep.

change the pytorch dependency to be '>2.4.1'
because pytorch 2.4.1 does not have `nn.Module.set_submodule()`, running `lm_decomposition.py` gives the error:
```
File "~/apd/spd/experiments/lm/lm_decomposition.py", line 146, in main
optimize(
File "/home/miv/projects/MATS/apd/spd/run_spd.py", line 242, in optimize
layerwise_random_recon_loss = calc_layerwise_recon_loss(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/apd/spd/losses.py", line 135, in calc_layerwise_recon_loss
modified_out = model.forward_with_component(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/apd/spd/models/component_model.py", line 141, in forward_with_component
self.model.set_submodule(module_name, component)
^^^^^^^^^^^^^^^^^^^^^^^^
File "~/apd/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1729, in __getattr__
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'GPTNeoForCausalLM' object has no attribute 'set_submodule'
```
due to pytorch vuln https://nvd.nist.gov/vuln/detail/CVE-2025-32434
huggingface transformers library doesn't allow loading with weights_only=True
so, we add to `lm_decomposition.py:main()` a kwarg `weights_only` passed on to `load_pretrained()`
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@mivanit