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

Error loading SAE with SAElens library #65

Open
thdai2000 opened this issue Dec 12, 2024 · 3 comments
Open

Error loading SAE with SAElens library #65

thdai2000 opened this issue Dec 12, 2024 · 3 comments

Comments

@thdai2000
Copy link

thdai2000 commented Dec 12, 2024

Hello LLAMASCOPE team, thank you for your work! I'm having trouble with loading the SAE using the SAElens library, I keep getting the error below:

File "/anaconda3/envs/mechinterp/lib/python3.12/site-packages/sae_lens/sae.py", line 616, in from_pretrained
    cfg_dict, state_dict, log_sparsities = conversion_loader(
                                           ^^^^^^^^^^^^^^^^^^
  File "/anaconda3/envs/mechinterp/lib/python3.12/site-packages/sae_lens/toolkit/pretrained_sae_loaders.py", line 503, in llama_scope_sae_loader
    state_dict_loaded = load_file(sae_path, device=device)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/anaconda3/envs/mechinterp/lib/python3.12/site-packages/safetensors/torch.py", line 313, in load_file
    with safe_open(filename, framework="pt", device=device) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
safetensors_rust.SafetensorError: device cuda is invalid

The loading script I use is

from sae_lens import SAE
sae, cfg_dict, sparsity = SAE.from_pretrained(release="llama_scope_lxm_8x", sae_id="l16m_8x", device=device)

where device is cuda.

Such problem doesn't appear with the GemmaScope SAE. Do you have any clue about this problem? Thanks in advance!

@Hzfinfdu
Copy link
Member

Hzfinfdu commented Dec 13, 2024 via email

@Hzfinfdu
Copy link
Member

I have replicated your code script in two different environments I have at hand and fail to reproduce this error. Could you please provide more details?

running pip list gives me:

sae-lens                   4.4.5
safetensors                0.4.5
torch                      2.5.1
... (Other packages omitted)

@thdai2000
Copy link
Author

Hi, my environment is:

sae-lens                   5.1.0
safetensors                0.4.5
torch                      2.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants