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

Should topk aux loss detach e before loss calculation? #57

Open
chanind opened this issue Feb 23, 2025 · 4 comments
Open

Should topk aux loss detach e before loss calculation? #57

chanind opened this issue Feb 23, 2025 · 4 comments

Comments

@chanind
Copy link

chanind commented Feb 23, 2025

In dictionary_learning's topk aux loss, the SAE error e is detached before the aux loss is calculated, but in sparsify it's not detached.

Intuitively, it feels more correct to detach since this means the aux loss can only be reduced by pulling dead latents towards the SAE error, not by pulling the SAE error closer to the dead latents.

Should Sparsify also detach the error before calculating aux loss, or is there a reason why it's not ideal to do this?

@norabelrose
Copy link
Member

norabelrose commented Feb 24, 2025

I will look at this later today, I'm not sure, but FWIW I haven't used AuxK loss in a very long time so it is sort of a neglected feature. I don't think it's really ever necessary. MultiTopK would be a better way to get rid of dead latents. Also, our new Signum optimizer seems to reduce dead latents significantly over Adam.

@chanind
Copy link
Author

chanind commented Feb 26, 2025

Is the signum optimizer whats in sign_sgd.py? Is there a paper describing the multi topk technique? It looks like it adds a loss that's equivalent to increasing k by 4, sort of like a matryoshka SAE?

@norabelrose
Copy link
Member

Yeah. MultiTopK was introduced in the original TopK paper from Gao et al.

@chanind
Copy link
Author

chanind commented Feb 26, 2025

Ah you are correct, I clearly didn't read the topk paper closely enough 😅. Thanks for the response and the great library!

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