Conversation
|
FYI, you can update the branch with latest main. I should resolve the CI issues! |
|
@gabrielfruet I'll try to help a bit in the next few days so that we can merge this. Pushed a few cleanups and a context variable for taking care of that ugly global tensor. Feel free to also reach out on Discord for slightly faster interaction. |
…uet/lightly into feat/1462-spark-implementation
| raise ValueError(f"Invalid tuple length: {len(t)}; expected 1 or 2.") | ||
|
|
||
|
|
||
| _cur_active: torch.Tensor | None = ( |
There was a problem hiding this comment.
Honestly, i don't like the way SparK's author did this using globals.
An alternative would be to reuse the masks_per_level object that was already created and assign it to each Sparse converted layer.
We have two options here
- Assign a new list container on each new forward pass with the new masks.
- Would require to traverse the
nn.Moduleeach and every single time that the forward pass starts, identify sparse layers and assign the mask.
- Would require to traverse the
- Have a "global" list that is assigned at construction time to the sparse layers with the len equals to the number of downsamples. (initially starting with null for example)
- I think this wouldn't conflict with DDP and neither would need to traverse the module tree each time.
- We should only make sure that the list is ONLY modified in-place, always.
masks_per_level[level] = new_mask, such that the others can reuse it. The underlying memory address of the list would be the same for the lifetime of that module.
In any way both would work better as a design pattern.
Before i took any action here tell me WDYT. I think this could be a follow-up PR when this got merged. Or if you prefer, i can do this right away, just let me know your thoughts.
There was a problem hiding this comment.
I created a context variable now, which I think is a decent enough solution (minimal changes to the original code necessary, but a clear context instead of a global variable). I saw that you already picked it up and are using it, great! 👍
I can do another review probably tomorrow (Friday, 06.03.)
| @@ -0,0 +1,808 @@ | |||
| # Copyright (c) 2023 Keyu Tian | |||
There was a problem hiding this comment.
https://github.com/keyu-tian/SparK
This is the original repo. I joined some files into this single file and after that i started refactoring the classes and functions to adhere to the Lightly philosophy of providing the modules, not the full implementation.
|
Hi @liopeer, sorry for the delay. I got really sick recently. I made some comments and reviews, but i forgot to submit them. I submitted them now. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1892 +/- ##
==========================================
- Coverage 86.10% 84.00% -2.10%
==========================================
Files 168 171 +3
Lines 6979 7352 +373
==========================================
+ Hits 6009 6176 +167
- Misses 970 1176 +206 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@liopeer If you wish i could increase test coverage. If not necessary let me know. |
|
I'll take a look into these type errors (Check 3.7) |
Addresses #1462
Continues #1750
Inspired by: https://github.com/keyu-tian/SparK
https://arxiv.org/pdf/2301.03580