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

Faster geometric median. #22

Merged
merged 5 commits into from
Mar 19, 2024

Conversation

themachinefan
Copy link
Contributor

The 'torch' version of the geometric median code uses lists and numpy arrays a bunch, here's a true torch version

Test it by running sae_training/geometric_median.py

It's about a 5x speedup on cpu and 1000x speedup on gpu :D

(please double check my changes to train_sae_on_language_model.py, I'm running stuff on my own code base and haven't actually set up this environment to try the training! Also consider increasing max iter since it's faster.)

@chanind
Copy link
Collaborator

chanind commented Mar 16, 2024

This is awesome! I wanted to use this in my work as well, so I packaged this as a pypi module as torch-geometric-median, repo is here: https://github.com/chanind/torch-geometric-median. @themachinefan I can transfer ownership of this repo to you if you want, or I can delete it if you'd rather this not be in a pypi module.

@themachinefan
Copy link
Contributor Author

This is awesome! I wanted to use this in my work as well, so I packaged this as a pypi module as torch-geometric-median, repo is here: https://github.com/chanind/torch-geometric-median. @themachinefan I can transfer ownership of this repo to you if you want, or I can delete it if you'd rather this not be in a pypi module.

Cool, thanks! Go ahead and transfer it

@chanind
Copy link
Collaborator

chanind commented Mar 16, 2024

Just sent the transfer request to you

@chanind
Copy link
Collaborator

chanind commented Mar 17, 2024

@themachinefan let me know if you have any questions about how the repo is structured or how to do development work on it (my email is in my github profile) . It's set up to autodeploy using semantic-release, so if your commit message to main starts with feat: it will do a minor version bump, fix: will do a patch version bump, and adding BREAKING CHANGE: to the commit body will do a major version bump. The library has CI set up to run all linting/type checking/tests automatically, and should currently have close to 100% test coverage (since it's a pretty simple library).

@jbloomAus jbloomAus merged commit 341c49a into jbloomAus:main Mar 19, 2024
2 checks passed
@jbloomAus
Copy link
Owner

Thanks @themachinefan and @chanind . I had to make some changes for the formatter but all good now.

tom-pollak pushed a commit to tom-pollak/SAELens that referenced this pull request Oct 22, 2024
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

Successfully merging this pull request may close these issues.

3 participants