gefen 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
gefen-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nadav Benedek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # Include CUDA/C++ sources in source distributions so PyTorch JIT can build kernels after install.
2
+ recursive-include kernels *.py *.cu *.cpp *.md
3
+ prune kernels/.build
gefen-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.4
2
+ Name: gefen
3
+ Version: 1.0.0
4
+ Summary: Gefen optimizer for memory-efficient PyTorch training
5
+ Author: Nadav Benedek
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Nadav Benedek
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Repository, https://github.com/ndvbd/Gefen
29
+ Project-URL: Issues, https://github.com/ndvbd/Gefen/issues
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: Programming Language :: Python :: 3 :: Only
32
+ Classifier: Programming Language :: Python :: 3.9
33
+ Classifier: Programming Language :: Python :: 3.10
34
+ Classifier: Programming Language :: Python :: 3.11
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: POSIX :: Linux
37
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
38
+ Requires-Python: >=3.9
39
+ Description-Content-Type: text/markdown
40
+ License-File: LICENSE
41
+ Requires-Dist: ninja
42
+ Requires-Dist: numpy
43
+ Requires-Dist: numba
44
+ Requires-Dist: torch
45
+ Dynamic: license-file
46
+
47
+ # [Gefen: Optimized Stochastic Optimizer](https://arxiv.org/pdf/2606.13894)
48
+
49
+ Gefen is a drop-in replacement for the AdamW optimizer for memory-efficient
50
+ training. It keeps the familiar AdamW training recipe while dramatically
51
+ reducing optimizer-state memory: an 8x reduction in AdamW memory footprint, or
52
+ about 6.5 GiB saved per billion parameters, while maintaining AdamW-level
53
+ performance. The reduced memory footprint lets you train larger models or use
54
+ larger batch sizes and, as a result, achieve higher training throughput.
55
+ All it takes is changing two lines of code: import Gefen and replace the AdamW
56
+ optimizer constructor.
57
+
58
+ ## Installation
59
+
60
+ Install from source:
61
+
62
+ ```bash
63
+ git clone https://github.com/ndvbd/Gefen
64
+ cd Gefen
65
+ pip install -e .
66
+ ```
67
+
68
+ On the first CUDA run, Gefen builds its fused CUDA kernels with PyTorch JIT and
69
+ `nvcc`. This can take a few minutes. Later runs reuse the cached build for the
70
+ same Python, PyTorch, CUDA version, and Gefen source checkout.
71
+
72
+ This keeps the source install lightweight, but it requires a CUDA toolkit and
73
+ host compiler compatible with your PyTorch installation. In the future, we plan
74
+ to make this smoother with prebuilt wheels for common PyTorch/CUDA combinations.
75
+
76
+ ## Quick Start
77
+
78
+ ```python
79
+ import torch
80
+ from gefen import Gefen
81
+
82
+ device = "cuda" if torch.cuda.is_available() else "cpu"
83
+ model = torch.nn.Linear(128, 10).to(device)
84
+
85
+ # optimizer = torch.optim.AdamW(
86
+ optimizer = Gefen( # Replace AdamW with Gefen:
87
+ model.parameters(),
88
+ lr=1e-3,
89
+ betas=(0.9, 0.999),
90
+ eps=1e-8,
91
+ weight_decay=0.0,
92
+ )
93
+
94
+ inputs = torch.randn(32, 128, device=device)
95
+ targets = torch.randint(0, 10, (32,), device=device)
96
+
97
+ logits = model(inputs)
98
+ loss = torch.nn.functional.cross_entropy(logits, targets)
99
+ loss.backward()
100
+
101
+ optimizer.step()
102
+ optimizer.zero_grad(set_to_none=True)
103
+
104
+ print('Finished successfully.')
105
+ ```
106
+
107
+
108
+ ## Citation
109
+
110
+ ```bibtex
111
+ @article{benedek2026gefen,
112
+ title={Gefen: Optimized Stochastic Optimizer},
113
+ author={Benedek, Nadav and Koren, Tomer and Fried, Ohad},
114
+ journal={arXiv preprint arXiv:2606.13894},
115
+ year={2026}
116
+ }
117
+ ```
gefen-1.0.0/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # [Gefen: Optimized Stochastic Optimizer](https://arxiv.org/pdf/2606.13894)
2
+
3
+ Gefen is a drop-in replacement for the AdamW optimizer for memory-efficient
4
+ training. It keeps the familiar AdamW training recipe while dramatically
5
+ reducing optimizer-state memory: an 8x reduction in AdamW memory footprint, or
6
+ about 6.5 GiB saved per billion parameters, while maintaining AdamW-level
7
+ performance. The reduced memory footprint lets you train larger models or use
8
+ larger batch sizes and, as a result, achieve higher training throughput.
9
+ All it takes is changing two lines of code: import Gefen and replace the AdamW
10
+ optimizer constructor.
11
+
12
+ ## Installation
13
+
14
+ Install from source:
15
+
16
+ ```bash
17
+ git clone https://github.com/ndvbd/Gefen
18
+ cd Gefen
19
+ pip install -e .
20
+ ```
21
+
22
+ On the first CUDA run, Gefen builds its fused CUDA kernels with PyTorch JIT and
23
+ `nvcc`. This can take a few minutes. Later runs reuse the cached build for the
24
+ same Python, PyTorch, CUDA version, and Gefen source checkout.
25
+
26
+ This keeps the source install lightweight, but it requires a CUDA toolkit and
27
+ host compiler compatible with your PyTorch installation. In the future, we plan
28
+ to make this smoother with prebuilt wheels for common PyTorch/CUDA combinations.
29
+
30
+ ## Quick Start
31
+
32
+ ```python
33
+ import torch
34
+ from gefen import Gefen
35
+
36
+ device = "cuda" if torch.cuda.is_available() else "cpu"
37
+ model = torch.nn.Linear(128, 10).to(device)
38
+
39
+ # optimizer = torch.optim.AdamW(
40
+ optimizer = Gefen( # Replace AdamW with Gefen:
41
+ model.parameters(),
42
+ lr=1e-3,
43
+ betas=(0.9, 0.999),
44
+ eps=1e-8,
45
+ weight_decay=0.0,
46
+ )
47
+
48
+ inputs = torch.randn(32, 128, device=device)
49
+ targets = torch.randint(0, 10, (32,), device=device)
50
+
51
+ logits = model(inputs)
52
+ loss = torch.nn.functional.cross_entropy(logits, targets)
53
+ loss.backward()
54
+
55
+ optimizer.step()
56
+ optimizer.zero_grad(set_to_none=True)
57
+
58
+ print('Finished successfully.')
59
+ ```
60
+
61
+
62
+ ## Citation
63
+
64
+ ```bibtex
65
+ @article{benedek2026gefen,
66
+ title={Gefen: Optimized Stochastic Optimizer},
67
+ author={Benedek, Nadav and Koren, Tomer and Fried, Ohad},
68
+ journal={arXiv preprint arXiv:2606.13894},
69
+ year={2026}
70
+ }
71
+ ```
@@ -0,0 +1,9 @@
1
+ __all__ = ["Gefen", "kernels"]
2
+
3
+
4
+ def __getattr__(name):
5
+ if name == "Gefen":
6
+ from .gefen import Gefen
7
+
8
+ return Gefen
9
+ raise AttributeError("module {!r} has no attribute {!r}".format(__name__, name))
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.4
2
+ Name: gefen
3
+ Version: 1.0.0
4
+ Summary: Gefen optimizer for memory-efficient PyTorch training
5
+ Author: Nadav Benedek
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Nadav Benedek
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Repository, https://github.com/ndvbd/Gefen
29
+ Project-URL: Issues, https://github.com/ndvbd/Gefen/issues
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: Programming Language :: Python :: 3 :: Only
32
+ Classifier: Programming Language :: Python :: 3.9
33
+ Classifier: Programming Language :: Python :: 3.10
34
+ Classifier: Programming Language :: Python :: 3.11
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: POSIX :: Linux
37
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
38
+ Requires-Python: >=3.9
39
+ Description-Content-Type: text/markdown
40
+ License-File: LICENSE
41
+ Requires-Dist: ninja
42
+ Requires-Dist: numpy
43
+ Requires-Dist: numba
44
+ Requires-Dist: torch
45
+ Dynamic: license-file
46
+
47
+ # [Gefen: Optimized Stochastic Optimizer](https://arxiv.org/pdf/2606.13894)
48
+
49
+ Gefen is a drop-in replacement for the AdamW optimizer for memory-efficient
50
+ training. It keeps the familiar AdamW training recipe while dramatically
51
+ reducing optimizer-state memory: an 8x reduction in AdamW memory footprint, or
52
+ about 6.5 GiB saved per billion parameters, while maintaining AdamW-level
53
+ performance. The reduced memory footprint lets you train larger models or use
54
+ larger batch sizes and, as a result, achieve higher training throughput.
55
+ All it takes is changing two lines of code: import Gefen and replace the AdamW
56
+ optimizer constructor.
57
+
58
+ ## Installation
59
+
60
+ Install from source:
61
+
62
+ ```bash
63
+ git clone https://github.com/ndvbd/Gefen
64
+ cd Gefen
65
+ pip install -e .
66
+ ```
67
+
68
+ On the first CUDA run, Gefen builds its fused CUDA kernels with PyTorch JIT and
69
+ `nvcc`. This can take a few minutes. Later runs reuse the cached build for the
70
+ same Python, PyTorch, CUDA version, and Gefen source checkout.
71
+
72
+ This keeps the source install lightweight, but it requires a CUDA toolkit and
73
+ host compiler compatible with your PyTorch installation. In the future, we plan
74
+ to make this smoother with prebuilt wheels for common PyTorch/CUDA combinations.
75
+
76
+ ## Quick Start
77
+
78
+ ```python
79
+ import torch
80
+ from gefen import Gefen
81
+
82
+ device = "cuda" if torch.cuda.is_available() else "cpu"
83
+ model = torch.nn.Linear(128, 10).to(device)
84
+
85
+ # optimizer = torch.optim.AdamW(
86
+ optimizer = Gefen( # Replace AdamW with Gefen:
87
+ model.parameters(),
88
+ lr=1e-3,
89
+ betas=(0.9, 0.999),
90
+ eps=1e-8,
91
+ weight_decay=0.0,
92
+ )
93
+
94
+ inputs = torch.randn(32, 128, device=device)
95
+ targets = torch.randint(0, 10, (32,), device=device)
96
+
97
+ logits = model(inputs)
98
+ loss = torch.nn.functional.cross_entropy(logits, targets)
99
+ loss.backward()
100
+
101
+ optimizer.step()
102
+ optimizer.zero_grad(set_to_none=True)
103
+
104
+ print('Finished successfully.')
105
+ ```
106
+
107
+
108
+ ## Citation
109
+
110
+ ```bibtex
111
+ @article{benedek2026gefen,
112
+ title={Gefen: Optimized Stochastic Optimizer},
113
+ author={Benedek, Nadav and Koren, Tomer and Fried, Ohad},
114
+ journal={arXiv preprint arXiv:2606.13894},
115
+ year={2026}
116
+ }
117
+ ```
@@ -0,0 +1,33 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ __init__.py
5
+ gefen.py
6
+ partitioning.py
7
+ pyproject.toml
8
+ quantization.py
9
+ setup.py
10
+ ./__init__.py
11
+ ./gefen.py
12
+ ./partitioning.py
13
+ ./quantization.py
14
+ ./setup.py
15
+ gefen.egg-info/PKG-INFO
16
+ gefen.egg-info/SOURCES.txt
17
+ gefen.egg-info/dependency_links.txt
18
+ gefen.egg-info/requires.txt
19
+ gefen.egg-info/top_level.txt
20
+ kernels/__init__.py
21
+ kernels/_build_notice.py
22
+ kernels/automatic_gefen_fused.py
23
+ kernels/automatic_gefen_fused_binding.cpp
24
+ kernels/automatic_gefen_fused_kernel.cu
25
+ kernels/automatic_vmean.py
26
+ kernels/automatic_vmean_binding.cpp
27
+ kernels/automatic_vmean_kernel.cu
28
+ kernels/exact_histogram_fused.py
29
+ kernels/exact_histogram_fused_binding.cpp
30
+ kernels/exact_histogram_fused_kernel.cu
31
+ kernels/period_variance.py
32
+ kernels/period_variance_binding.cpp
33
+ kernels/period_variance_kernel.cu
@@ -0,0 +1,4 @@
1
+ ninja
2
+ numpy
3
+ numba
4
+ torch
@@ -0,0 +1 @@
1
+ gefen