Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[P0] Saving and reloading a ReftModel throws an error #51

Closed
PinetreePantry opened this issue Apr 14, 2024 · 13 comments
Closed

[P0] Saving and reloading a ReftModel throws an error #51

PinetreePantry opened this issue Apr 14, 2024 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@PinetreePantry
Copy link
Collaborator

PinetreePantry commented Apr 14, 2024

I was saving and reloading a ReftModel. While loading, the model throws this error at pyvene/models/configuration_intervenable_model.py:51:

ValueError: RepresentationConfig(layer=4, component='block_output', unit='pos', max_number_of_units=1, low_rank_dimension=8, intervention_type=None, intervention=None, subspace_partition=None, group_key=None, intervention_link_key=None, moe_key=None, source_representation=None, hidden_source_representation=None) format in our representation list is not supported.

Issue seems to be that the RepresentationConfig loaded saved "RepresentationConfig(layer=4, component='block_output', unit='pos', max_number_of_units=1, low_rank_dimension=8, intervention_type=None, intervention=None, subspace_partition=None, group_key=None, intervention_link_key=None, moe_key=None, source_representation=None, hidden_source_representation=None)" as a class of type str instead of type RepresentationConfig.

This issue is different from #45.

@PinetreePantry PinetreePantry added the bug Something isn't working label Apr 14, 2024
@frankaging frankaging changed the title Saving and reloading a ReftModel throws an error [P0] Saving and reloading a ReftModel throws an error Apr 15, 2024
@frankaging
Copy link
Collaborator

Assigning P0 - i am fixing this.

frankaging added a commit that referenced this issue Apr 15, 2024
@frankaging
Copy link
Collaborator

it should be fixed. will close this once the branch is merged.

@chris-aeviator
Copy link

chris-aeviator commented Apr 30, 2024

@frankaging I'm still running into this. I just ran

pip uninstall -y pyvene pyreft
pip install --upgrade git+https://github.com/stanfordnlp/pyreft

Successfully built pyreft
Installing collected packages: pyvene, pyreft
Successfully installed pyreft-0.0.5 pyvene-0.1.1

EDIT: turns out the changes in cf3f734 are reverted??

I'm seeing this error with pyvene/models/configuration_intervenable_model.py:55

@frankaging
Copy link
Collaborator

@chris-aeviator are you using the HuggingFace trainer? If so, please set report_to="none". It is likely due to the tensorboard integration. #70

@chris-aeviator
Copy link

chris-aeviator commented Apr 30, 2024 via email

@frankaging
Copy link
Collaborator

@chris-aeviator thanks!

could you share your saved config.json? - it might be that the saved config.json contains a bad format due to our previous bugs.

@chris-aeviator
Copy link

@frankaging thanks and yes

{
  "intervention_constant_sources": [
    true
  ],
  "intervention_dimensions": [
    4096
  ],
  "intervention_types": [
    "<class 'transforms.autobrew.trft.raft.subspace.SubloreftIntervention'>"
  ],
  "mode": "parallel",
  "representations": [
    "RepresentationConfig(layer=15, component='block_output', unit='pos', max_number_of_units=1, low_rank_dimension=8, intervention_type=None, intervention=None, subspace_partition=None, group_key=None, intervention_link_key=None, moe_key=None, source_representation=None, hidden_source_representation=None)"
  ],
  "sorted_keys": [
    "layer.15.comp.block_output.unit.pos.nunit.1#0"
  ],
  "transformers_version": "4.39.3"
}
´

@frankaging
Copy link
Collaborator

@chris-aeviator thanks for your reply! unfortunately, it seems like this json is error formatted due to one of our previous bug. One way to fix this is to manually change to the correct format. You can follow this:

https://huggingface.co/pyvene/reft_goody2/blob/main/config.json

This is for the field representations.

@frankaging
Copy link
Collaborator

I think it will be something like this:

  "representations": [
    [
      15,
      "block_output",
      "pos",
      1,
      8,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null
    ]
  ],

@chris-aeviator
Copy link

chris-aeviator commented May 3, 2024

@frankaging thanks - changing the config to this format makes the model loadable again. However, it seems that upon training a new model, I will get a config file containing again the representationConfig entry in my config.json. Could you point out to me when (in which pr) the bugfixes for saving the model have been merged? I'm running this in a distributed computing environment and don't want to waste your time with back and forth debugging.

@frankaging
Copy link
Collaborator

@chris-aeviator i think if you install from the top of the tree (main), this should go away.

@chris-aeviator
Copy link

@frankaging thanks & confirmed, installing via git+https://github.com/stanfordnlp/pyreft@main now works. If you ever discuss to move to a more expressive config format (given it's a json file) to persist RepresentationConfig, there's a +1 from my side - so far all good & thanks again.

@frankaging
Copy link
Collaborator

@chris-aeviator ty! yep, the config.json is somewhat broken right now, will fix it once we have more time (after conf ddl).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants