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

Sparse grad sampler for embeddings #350

Open
ffuuugor opened this issue Feb 4, 2022 · 1 comment
Open

Sparse grad sampler for embeddings #350

ffuuugor opened this issue Feb 4, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@ffuuugor
Copy link
Contributor

ffuuugor commented Feb 4, 2022

Embedding updates are typically very sparse, however our naive implementation treats them as dense and spends a lot of time and memory storing and multiplying zeros. Additionally, I'm not sure if we support nn.Embedding(sparse=True) modules.

We can rewrite grad sampler with sparse computations instead

@ffuuugor ffuuugor added the enhancement New feature or request label Feb 4, 2022
@elichienxD
Copy link

elichienxD commented Mar 28, 2023

Hi @ffuuugor ,

I'm currently also using torch sparse tensor (coo layout) with opacus DPSGD in our project. We find that opacus is presently not compatible with sparse tensor as the MLP input. I just found this enhancement issue to be relevent and I wonder if there is any update or follow-up?

(below is the code for grad_sample_module.py)
image

I have tried to change L62 from = grad_sample to += grad_sample in order to avoid errors. However, the model cannot be trained well compared to the dense input. I wonder if there is any suggestion on where else should I modify the code?

Thanks,
Eli

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

No branches or pull requests

2 participants