hyper-connections 0.0.2__tar.gz → 0.0.3__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.
- {hyper_connections-0.0.2 → hyper_connections-0.0.3}/PKG-INFO +5 -5
- {hyper_connections-0.0.2 → hyper_connections-0.0.3}/README.md +4 -4
- {hyper_connections-0.0.2 → hyper_connections-0.0.3}/hyper_connections/hyper_connections.py +6 -1
- {hyper_connections-0.0.2 → hyper_connections-0.0.3}/pyproject.toml +1 -1
- {hyper_connections-0.0.2 → hyper_connections-0.0.3}/.github/workflows/python-publish.yml +0 -0
- {hyper_connections-0.0.2 → hyper_connections-0.0.3}/.gitignore +0 -0
- {hyper_connections-0.0.2 → hyper_connections-0.0.3}/LICENSE +0 -0
- {hyper_connections-0.0.2 → hyper_connections-0.0.3}/hyper-connections.png +0 -0
- {hyper_connections-0.0.2 → hyper_connections-0.0.3}/hyper_connections/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hyper-connections
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: Hyper-Connections
|
|
5
5
|
Project-URL: Homepage, https://pypi.org/project/hyper-connections/
|
|
6
6
|
Project-URL: Repository, https://github.com/lucidrains/hyper-connections
|
|
@@ -45,7 +45,7 @@ Description-Content-Type: text/markdown
|
|
|
45
45
|
|
|
46
46
|
## Hyper Connections
|
|
47
47
|
|
|
48
|
-
Attempt to make
|
|
48
|
+
Attempt to make multiple residual streams, proposed in [Hyper-Connections paper](https://arxiv.org/abs/2409.19606) out of Bytedance AI lab, accessible as an easy to use library, as well as for following any new research in this direction.
|
|
49
49
|
|
|
50
50
|
## Install
|
|
51
51
|
|
|
@@ -114,7 +114,7 @@ from hyper_connections import HyperConnections
|
|
|
114
114
|
|
|
115
115
|
expand_stream, reduce_stream = HyperConnections.get_expand_reduce_stream_functions(4)
|
|
116
116
|
|
|
117
|
-
# 1.
|
|
117
|
+
# 1. instantiate hyper connection with correct number of streams (4 in this case)
|
|
118
118
|
|
|
119
119
|
hyper_conn = HyperConnections(4, dim = 512)
|
|
120
120
|
|
|
@@ -124,11 +124,11 @@ residual = expand_stream(residual)
|
|
|
124
124
|
|
|
125
125
|
# 3. forward your residual into hyper connection for the branch input + add residual function (learned betas)
|
|
126
126
|
|
|
127
|
-
branch_input,
|
|
127
|
+
branch_input, add_residual = hyper_conn(residual)
|
|
128
128
|
|
|
129
129
|
branch_output = branch(branch_input)
|
|
130
130
|
|
|
131
|
-
residual =
|
|
131
|
+
residual = add_residual(branch_output)
|
|
132
132
|
|
|
133
133
|
# 4. reduce 4 streams with a summation, this has to be done after your for loop trunk
|
|
134
134
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Hyper Connections
|
|
4
4
|
|
|
5
|
-
Attempt to make
|
|
5
|
+
Attempt to make multiple residual streams, proposed in [Hyper-Connections paper](https://arxiv.org/abs/2409.19606) out of Bytedance AI lab, accessible as an easy to use library, as well as for following any new research in this direction.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -71,7 +71,7 @@ from hyper_connections import HyperConnections
|
|
|
71
71
|
|
|
72
72
|
expand_stream, reduce_stream = HyperConnections.get_expand_reduce_stream_functions(4)
|
|
73
73
|
|
|
74
|
-
# 1.
|
|
74
|
+
# 1. instantiate hyper connection with correct number of streams (4 in this case)
|
|
75
75
|
|
|
76
76
|
hyper_conn = HyperConnections(4, dim = 512)
|
|
77
77
|
|
|
@@ -81,11 +81,11 @@ residual = expand_stream(residual)
|
|
|
81
81
|
|
|
82
82
|
# 3. forward your residual into hyper connection for the branch input + add residual function (learned betas)
|
|
83
83
|
|
|
84
|
-
branch_input,
|
|
84
|
+
branch_input, add_residual = hyper_conn(residual)
|
|
85
85
|
|
|
86
86
|
branch_output = branch(branch_input)
|
|
87
87
|
|
|
88
|
-
residual =
|
|
88
|
+
residual = add_residual(branch_output)
|
|
89
89
|
|
|
90
90
|
# 4. reduce 4 streams with a summation, this has to be done after your for loop trunk
|
|
91
91
|
|
|
@@ -6,6 +6,7 @@ import torch
|
|
|
6
6
|
from torch import nn
|
|
7
7
|
from torch.nn import Module
|
|
8
8
|
import torch.nn.functional as F
|
|
9
|
+
from torch.utils._pytree import tree_flatten, tree_unflatten
|
|
9
10
|
|
|
10
11
|
from einops import rearrange, repeat, reduce, einsum
|
|
11
12
|
|
|
@@ -125,4 +126,8 @@ class HyperConnections(Module):
|
|
|
125
126
|
|
|
126
127
|
branch_output = self.branch(branch_input, **branch_kwargs)
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
(branch_output, *rest), tree_spec = tree_flatten(branch_output)
|
|
130
|
+
|
|
131
|
+
branch_output = add_residual_fn(branch_output)
|
|
132
|
+
|
|
133
|
+
return tree_unflatten((branch_output, *rest), tree_spec)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|