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

fix: Ensure activation scaling factor set before initializing b_dec #440

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

keltin13
Copy link

@keltin13 keltin13 commented Mar 1, 2025

Description

Fixes #439

When b_dec_init_method is set to mean or geometric_median we require getting activations from the buffer, however set_norm_scaling_factor_if_needed was not being called prior to this, meaning if normalize_activations was set to expected_average_only_in it would throw an error.

I added a call to set_norm_scaling_factor_if_needed directly before accessing the activations buffer inside _init_sae_group_b_decs to ensure the scaling factor is set before initialization. I also added a condition to set_norm_scaling_factor_if_needed to check whether the scaling factor is already set to prevent it from being set twice.

An alternative solution would be to take this opportunity to resolve the TODO for _init_sae_group_b_decs and move that method to another class, which I'm happy to do as well.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes
  • I have not rewritten tests relating to key interfaces which would affect backward compatibility

You have tested formatting, typing and tests

  • I have run make check-ci to check format and linting. (you can run make format to format code if needed.)

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