helix-lm 0.1.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.
- helix_lm-0.1.0/.gitignore +188 -0
- helix_lm-0.1.0/LICENSE +203 -0
- helix_lm-0.1.0/NOTICE +23 -0
- helix_lm-0.1.0/PKG-INFO +189 -0
- helix_lm-0.1.0/README.md +157 -0
- helix_lm-0.1.0/pyproject.toml +68 -0
- helix_lm-0.1.0/src/helix_lm/__init__.py +45 -0
- helix_lm-0.1.0/src/helix_lm/cache.py +121 -0
- helix_lm-0.1.0/src/helix_lm/cli.py +202 -0
- helix_lm-0.1.0/src/helix_lm/config.py +206 -0
- helix_lm-0.1.0/src/helix_lm/model.py +1311 -0
- helix_lm-0.1.0/src/helix_lm/recall.py +137 -0
- helix_lm-0.1.0/tests/test_helix_lm.py +247 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Initially taken from Github's Python gitignore file
|
|
2
|
+
|
|
3
|
+
# Byte-compiled / optimized / DLL files
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[cod]
|
|
6
|
+
*$py.class
|
|
7
|
+
|
|
8
|
+
# C extensions
|
|
9
|
+
*.so
|
|
10
|
+
|
|
11
|
+
# tests and logs
|
|
12
|
+
tests/fixtures/cached_*_text.txt
|
|
13
|
+
logs/
|
|
14
|
+
lightning_logs/
|
|
15
|
+
lang_code_data/
|
|
16
|
+
reports/
|
|
17
|
+
|
|
18
|
+
# Distribution / packaging
|
|
19
|
+
.Python
|
|
20
|
+
build/
|
|
21
|
+
develop-eggs/
|
|
22
|
+
dist/
|
|
23
|
+
downloads/
|
|
24
|
+
eggs/
|
|
25
|
+
.eggs/
|
|
26
|
+
lib/
|
|
27
|
+
lib64/
|
|
28
|
+
parts/
|
|
29
|
+
sdist/
|
|
30
|
+
var/
|
|
31
|
+
wheels/
|
|
32
|
+
*.egg-info/
|
|
33
|
+
.installed.cfg
|
|
34
|
+
*.egg
|
|
35
|
+
MANIFEST
|
|
36
|
+
|
|
37
|
+
# PyInstaller
|
|
38
|
+
# Usually these files are written by a python script from a template
|
|
39
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
40
|
+
*.manifest
|
|
41
|
+
*.spec
|
|
42
|
+
|
|
43
|
+
# Installer logs
|
|
44
|
+
pip-log.txt
|
|
45
|
+
pip-delete-this-directory.txt
|
|
46
|
+
|
|
47
|
+
# Unit test / coverage reports
|
|
48
|
+
htmlcov/
|
|
49
|
+
.tox/
|
|
50
|
+
.nox/
|
|
51
|
+
.coverage
|
|
52
|
+
.coverage.*
|
|
53
|
+
.cache
|
|
54
|
+
nosetests.xml
|
|
55
|
+
coverage.xml
|
|
56
|
+
*.cover
|
|
57
|
+
.hypothesis/
|
|
58
|
+
.pytest_cache/
|
|
59
|
+
|
|
60
|
+
# Translations
|
|
61
|
+
*.mo
|
|
62
|
+
*.pot
|
|
63
|
+
|
|
64
|
+
# Django stuff:
|
|
65
|
+
*.log
|
|
66
|
+
local_settings.py
|
|
67
|
+
db.sqlite3
|
|
68
|
+
|
|
69
|
+
# Flask stuff:
|
|
70
|
+
instance/
|
|
71
|
+
.webassets-cache
|
|
72
|
+
|
|
73
|
+
# Scrapy stuff:
|
|
74
|
+
.scrapy
|
|
75
|
+
|
|
76
|
+
# Sphinx documentation
|
|
77
|
+
docs/_build/
|
|
78
|
+
|
|
79
|
+
# PyBuilder
|
|
80
|
+
target/
|
|
81
|
+
|
|
82
|
+
# Jupyter Notebook
|
|
83
|
+
.ipynb_checkpoints
|
|
84
|
+
|
|
85
|
+
# IPython
|
|
86
|
+
profile_default/
|
|
87
|
+
ipython_config.py
|
|
88
|
+
|
|
89
|
+
# pyenv
|
|
90
|
+
.python-version
|
|
91
|
+
|
|
92
|
+
# celery beat schedule file
|
|
93
|
+
celerybeat-schedule
|
|
94
|
+
|
|
95
|
+
# SageMath parsed files
|
|
96
|
+
*.sage.py
|
|
97
|
+
|
|
98
|
+
# Environments
|
|
99
|
+
.env
|
|
100
|
+
.venv
|
|
101
|
+
.venv*
|
|
102
|
+
env/
|
|
103
|
+
venv/
|
|
104
|
+
ENV/
|
|
105
|
+
env.bak/
|
|
106
|
+
venv.bak/
|
|
107
|
+
|
|
108
|
+
# Spyder project settings
|
|
109
|
+
.spyderproject
|
|
110
|
+
.spyproject
|
|
111
|
+
|
|
112
|
+
# Rope project settings
|
|
113
|
+
.ropeproject
|
|
114
|
+
|
|
115
|
+
# mkdocs documentation
|
|
116
|
+
/site
|
|
117
|
+
|
|
118
|
+
# mypy
|
|
119
|
+
.mypy_cache/
|
|
120
|
+
.dmypy.json
|
|
121
|
+
dmypy.json
|
|
122
|
+
|
|
123
|
+
# Pyre type checker
|
|
124
|
+
.pyre/
|
|
125
|
+
|
|
126
|
+
# vscode
|
|
127
|
+
.vs
|
|
128
|
+
.vscode
|
|
129
|
+
|
|
130
|
+
# Pycharm
|
|
131
|
+
.idea
|
|
132
|
+
|
|
133
|
+
# TF code
|
|
134
|
+
tensorflow_code
|
|
135
|
+
|
|
136
|
+
# Models
|
|
137
|
+
proc_data
|
|
138
|
+
|
|
139
|
+
# examples
|
|
140
|
+
runs
|
|
141
|
+
/runs_old
|
|
142
|
+
/wandb
|
|
143
|
+
/examples/runs
|
|
144
|
+
/examples/**/*.args
|
|
145
|
+
/examples/rag/sweep
|
|
146
|
+
|
|
147
|
+
# data
|
|
148
|
+
/data
|
|
149
|
+
serialization_dir
|
|
150
|
+
|
|
151
|
+
# emacs
|
|
152
|
+
*.*~
|
|
153
|
+
debug.env
|
|
154
|
+
|
|
155
|
+
# vim
|
|
156
|
+
.*.swp
|
|
157
|
+
|
|
158
|
+
#ctags
|
|
159
|
+
tags
|
|
160
|
+
|
|
161
|
+
# pre-commit
|
|
162
|
+
.pre-commit*
|
|
163
|
+
|
|
164
|
+
# .lock
|
|
165
|
+
*.lock
|
|
166
|
+
|
|
167
|
+
# DS_Store (MacOS)
|
|
168
|
+
.DS_Store
|
|
169
|
+
|
|
170
|
+
# ruff
|
|
171
|
+
.ruff_cache
|
|
172
|
+
|
|
173
|
+
# checkers cache
|
|
174
|
+
utils/.checkers_cache.json
|
|
175
|
+
utils/.checkers_requirements.json
|
|
176
|
+
utils/.noisy_comments_cache.json
|
|
177
|
+
mlinter-findings.json
|
|
178
|
+
|
|
179
|
+
# modular conversion
|
|
180
|
+
*.modular_backup
|
|
181
|
+
|
|
182
|
+
# Cursor IDE files
|
|
183
|
+
.cursor/
|
|
184
|
+
test-results/
|
|
185
|
+
|
|
186
|
+
# AI agent local setup artifacts
|
|
187
|
+
/.agents/skills
|
|
188
|
+
/.claude/skills
|
helix_lm-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Copyright 2018- The Hugging Face team. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Apache License
|
|
4
|
+
Version 2.0, January 2004
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
15
|
+
the copyright owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
18
|
+
other entities that control, are controlled by, or are under common
|
|
19
|
+
control with that entity. For the purposes of this definition,
|
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
21
|
+
direction or management of such entity, whether by contract or
|
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
26
|
+
exercising permissions granted by this License.
|
|
27
|
+
|
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
29
|
+
including but not limited to software source code, documentation
|
|
30
|
+
source, and configuration files.
|
|
31
|
+
|
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
|
33
|
+
transformation or translation of a Source form, including but
|
|
34
|
+
not limited to compiled object code, generated documentation,
|
|
35
|
+
and conversions to other media types.
|
|
36
|
+
|
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
38
|
+
Object form, made available under the License, as indicated by a
|
|
39
|
+
copyright notice that is included in or attached to the work
|
|
40
|
+
(an example is provided in the Appendix below).
|
|
41
|
+
|
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
48
|
+
the Work and Derivative Works thereof.
|
|
49
|
+
|
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
|
51
|
+
the original version of the Work and any modifications or additions
|
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
53
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
63
|
+
|
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
66
|
+
subsequently incorporated within the Work.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
|
74
|
+
|
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
80
|
+
where such license applies only to those patent claims licensable
|
|
81
|
+
by such Contributor that are necessarily infringed by their
|
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
84
|
+
institute patent litigation against any entity (including a
|
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
87
|
+
or contributory patent infringement, then any patent licenses
|
|
88
|
+
granted to You under this License for that Work shall terminate
|
|
89
|
+
as of the date such litigation is filed.
|
|
90
|
+
|
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
93
|
+
modifications, and in Source or Object form, provided that You
|
|
94
|
+
meet the following conditions:
|
|
95
|
+
|
|
96
|
+
(a) You must give any other recipients of the Work or
|
|
97
|
+
Derivative Works a copy of this License; and
|
|
98
|
+
|
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
|
100
|
+
stating that You changed the files; and
|
|
101
|
+
|
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
|
104
|
+
attribution notices from the Source form of the Work,
|
|
105
|
+
excluding those notices that do not pertain to any part of
|
|
106
|
+
the Derivative Works; and
|
|
107
|
+
|
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
|
110
|
+
include a readable copy of the attribution notices contained
|
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
|
113
|
+
of the following places: within a NOTICE text file distributed
|
|
114
|
+
as part of the Derivative Works; within the Source form or
|
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
|
116
|
+
within a display generated by the Derivative Works, if and
|
|
117
|
+
wherever such third-party notices normally appear. The contents
|
|
118
|
+
of the NOTICE file are for informational purposes only and
|
|
119
|
+
do not modify the License. You may add Your own attribution
|
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
122
|
+
that such additional attribution notices cannot be construed
|
|
123
|
+
as modifying the License.
|
|
124
|
+
|
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
|
126
|
+
may provide additional or different license terms and conditions
|
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
130
|
+
the conditions stated in this License.
|
|
131
|
+
|
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
135
|
+
this License, without any additional terms or conditions.
|
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
137
|
+
the terms of any separate license agreement you may have executed
|
|
138
|
+
with Licensor regarding such Contributions.
|
|
139
|
+
|
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
142
|
+
except as required for reasonable and customary use in describing the
|
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
144
|
+
|
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
|
154
|
+
|
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
|
160
|
+
incidental, or consequential damages of any character arising as a
|
|
161
|
+
result of this License or out of the use or inability to use the
|
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
164
|
+
other commercial damages or losses), even if such Contributor
|
|
165
|
+
has been advised of the possibility of such damages.
|
|
166
|
+
|
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
170
|
+
or other liability obligations and/or rights consistent with this
|
|
171
|
+
License. However, in accepting such obligations, You may act only
|
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
176
|
+
of your accepting any such warranty or additional liability.
|
|
177
|
+
|
|
178
|
+
END OF TERMS AND CONDITIONS
|
|
179
|
+
|
|
180
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
181
|
+
|
|
182
|
+
To apply the Apache License to your work, attach the following
|
|
183
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
184
|
+
replaced with your own identifying information. (Don't include
|
|
185
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
186
|
+
comment syntax for the file format. We also recommend that a
|
|
187
|
+
file or class name and description of purpose be included on the
|
|
188
|
+
same "printed page" as the copyright notice for easier
|
|
189
|
+
identification within third-party archives.
|
|
190
|
+
|
|
191
|
+
Copyright [yyyy] [name of copyright owner]
|
|
192
|
+
|
|
193
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
194
|
+
you may not use this file except in compliance with the License.
|
|
195
|
+
You may obtain a copy of the License at
|
|
196
|
+
|
|
197
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
198
|
+
|
|
199
|
+
Unless required by applicable law or agreed to in writing, software
|
|
200
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
201
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
202
|
+
See the License for the specific language governing permissions and
|
|
203
|
+
limitations under the License.
|
helix_lm-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
helix-lm
|
|
2
|
+
Copyright 2026 Nathan
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
5
|
+
these files except in compliance with the License. A copy of the License is in
|
|
6
|
+
the LICENSE file.
|
|
7
|
+
|
|
8
|
+
--------------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
This product includes software developed at Hugging Face, Inc.
|
|
11
|
+
|
|
12
|
+
Portions of `helix_lm/model.py` are derived from HuggingFace Transformers
|
|
13
|
+
(https://github.com/huggingface/transformers), which is licensed under the
|
|
14
|
+
Apache License, Version 2.0. In particular, the chunkwise-parallel and
|
|
15
|
+
single-step gated delta-rule routines (`torch_chunk_gated_delta_rule`,
|
|
16
|
+
`torch_recurrent_gated_delta_rule`), the depthwise causal convolution helper
|
|
17
|
+
(`causal_conv1d_fn`), the rotary-embedding helpers (`rotate_half`,
|
|
18
|
+
`apply_rotary_pos_emb`), `repeat_kv`, and the RMS normalization layers follow
|
|
19
|
+
that project's reference implementations.
|
|
20
|
+
|
|
21
|
+
The HELIX architecture itself -- the three-strand braid, the hierarchical
|
|
22
|
+
landmark index and its causal beam descent, the multi-scale local staircase,
|
|
23
|
+
surprise-gated writes, and the strand fusion -- is original to this project.
|
helix_lm-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: helix-lm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: HELIX: a linear-scaling sequence architecture that keeps exact long-range recall
|
|
5
|
+
Project-URL: Homepage, https://github.com/Wisk-inc/transformers/tree/main/helix-lm
|
|
6
|
+
Project-URL: Source, https://github.com/Wisk-inc/transformers/tree/main/helix-lm
|
|
7
|
+
Project-URL: Issues, https://github.com/Wisk-inc/transformers/issues
|
|
8
|
+
Author: Nathan
|
|
9
|
+
Maintainer: Nathan
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: NOTICE
|
|
13
|
+
Keywords: associative-recall,attention,delta-rule,linear-attention,long-context,pytorch,sparse-attention,state-space-model,transformer
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: torch>=2.5
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# HELIX
|
|
34
|
+
|
|
35
|
+
**H**ierarchical **E**pisodic **L**inear **I**nde**X** — a sequence architecture that keeps what attention
|
|
36
|
+
is good at while dropping the quadratic bill.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install helix-lm
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import torch
|
|
44
|
+
from helix_lm import HelixConfig, HelixForCausalLM
|
|
45
|
+
|
|
46
|
+
model = HelixForCausalLM(HelixConfig(vocab_size=32000, hidden_size=1024, num_hidden_layers=12))
|
|
47
|
+
logits = model(torch.randint(0, 32000, (1, 8192))).logits
|
|
48
|
+
text = model.generate(torch.randint(0, 32000, (1, 64)), max_new_tokens=32, temperature=0.8)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
helix info # what it is and what it costs
|
|
53
|
+
helix demo # build a model, generate, verify the decode state
|
|
54
|
+
helix bench # cost against context length
|
|
55
|
+
helix recall # train with and without the index strand, and compare
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## The idea
|
|
61
|
+
|
|
62
|
+
A transformer compares every token to every other token. Ten thousand tokens is fifty million
|
|
63
|
+
comparisons; double the input and you quadruple the work. Linear-time alternatives fix that by squeezing
|
|
64
|
+
the past into a fixed-size state — and then they cannot quote you a name they saw once, because a state of
|
|
65
|
+
`S` bits cannot tell apart more than `2^S` histories. That is a counting argument, not an engineering gap.
|
|
66
|
+
|
|
67
|
+
HELIX does not try to compress its way around it. It **separates memory capacity from memory bandwidth**.
|
|
68
|
+
Every block braids three mixers over the same residual stream:
|
|
69
|
+
|
|
70
|
+
| strand | reads | training cost | held at decode |
|
|
71
|
+
| --- | --- | --- | --- |
|
|
72
|
+
| **L** local | the last `local_blocks × block_size` tokens, exactly, with a different window per head | `O(N · span)` | a window-sized ring buffer |
|
|
73
|
+
| **R** recurrent | everything, compressed into a matrix-valued delta-rule state | `O(N · d_k · d_v)` | one matrix + two conv states per head |
|
|
74
|
+
| **I** index | `index_topk` blocks chosen anywhere in the past by a beam descent over a landmark tree | `O(N · topk · block_size)` + `O(N log N)` routing | the key/value history and a landmark tree, of which a step reads `O(topk · block_size + branching · log N)` |
|
|
75
|
+
|
|
76
|
+
Storage is `O(N)`, append-only, never rewritten, and can live in cold memory. What a single token *touches*
|
|
77
|
+
is bounded. So the claim is **`O(1)` hot state and `O(log N)` probes** — not `O(1)` total memory, which is
|
|
78
|
+
impossible for anything that can quote an exact name from a million tokens back.
|
|
79
|
+
|
|
80
|
+
## How the index works
|
|
81
|
+
|
|
82
|
+
The past is cut into blocks of `block_size` tokens. Each closed block gets a **landmark** — a learned pooled
|
|
83
|
+
summary that mixes a plain mean with an attention pool, because a mean alone erases the rare token a later
|
|
84
|
+
query will be hunting for. Landmarks are pooled again, `index_branching` at a time, into a tree, using one
|
|
85
|
+
weight-shared pooler at every internal level.
|
|
86
|
+
|
|
87
|
+
Two rules keep it causal *and* parallel:
|
|
88
|
+
|
|
89
|
+
1. **A node is eligible for query block `J` only if the whole span it summarizes ends at or before `J`.** A
|
|
90
|
+
summary is never consulted by a query it partly describes, so a landmark is computed once and reused by
|
|
91
|
+
every query.
|
|
92
|
+
2. **Routing for block `J` comes from the hidden state at the end of block `J − 1`.** Strictly past for
|
|
93
|
+
every token of block `J`, so one gather serves `block_size` queries. Anything routing could not
|
|
94
|
+
anticipate inside that block is covered exactly by strand L.
|
|
95
|
+
|
|
96
|
+
The descent keeps `index_beam_width` nodes per level. Candidates at each level are the beam's children
|
|
97
|
+
**plus** that level's *frontier* — eligible nodes whose parent is not eligible. At most `branching − 1` per
|
|
98
|
+
level, and the frontiers across all levels tile `[0, J)` exactly, so nothing reachable is cut off by a beam
|
|
99
|
+
that descended elsewhere. Selection scores are fed back as additive attention logits, accumulated along the
|
|
100
|
+
descent path, which is what lets gradient reach every level of the tree rather than just the leaves.
|
|
101
|
+
|
|
102
|
+
## What has been measured
|
|
103
|
+
|
|
104
|
+
On small models, 4 CPU cores. Reproduce with `helix bench` and `helix recall`.
|
|
105
|
+
|
|
106
|
+
**Cost against context length.** Attention pairs are exact — the query/key products the forward pass
|
|
107
|
+
actually forms, counted by instrumenting the attention call.
|
|
108
|
+
|
|
109
|
+
| tokens | HELIX pairs/token | full attention pairs/token | HELIX | full attention |
|
|
110
|
+
| ---: | ---: | ---: | ---: | ---: |
|
|
111
|
+
| 4 096 | 8 192 | 32 776 | 0.4 s | 0.2 s |
|
|
112
|
+
| 8 192 | 8 192 | 65 544 | 0.9 s | 0.6 s |
|
|
113
|
+
| 16 384 | 8 192 | 131 080 | 1.7 s | 1.9 s |
|
|
114
|
+
| 32 768 | 8 192 | 262 152 | 4.3 s | 6.7 s |
|
|
115
|
+
|
|
116
|
+
HELIX fits `N^1.00` in attention pairs; full attention fits `N^2.00`. By 32k tokens HELIX forms **32×
|
|
117
|
+
fewer** and runs **1.6× faster** — as unfused reference PyTorch against a fused SDPA kernel.
|
|
118
|
+
|
|
119
|
+
**Recall from far back.** Multi-query associative recall: bindings written near the start, queried ~200
|
|
120
|
+
tokens later, well outside the local window.
|
|
121
|
+
|
|
122
|
+
| model | recall | 95% CI |
|
|
123
|
+
| --- | ---: | :---: |
|
|
124
|
+
| HELIX (L+R+I) | **30.8%** | [28.5%, 33.1%] |
|
|
125
|
+
| HELIX no index (L+R) | 6.0% | [4.8%, 7.2%] |
|
|
126
|
+
| full attention | 32.0% | [29.7%, 34.3%] |
|
|
127
|
+
| *chance* | *6.2%* | |
|
|
128
|
+
|
|
129
|
+
Read the two gaps separately. **HELIX against its own ablation is the result**: strip the index strand and
|
|
130
|
+
the same model, same width, same depth, sits at chance — its window cannot see the bindings and its
|
|
131
|
+
recurrent state cannot hold them. That gap is ~21 standard errors. **HELIX against full attention is a
|
|
132
|
+
tie**, not a win or a loss: 1.2 points with a 1.7-point standard error, z = 0.72.
|
|
133
|
+
|
|
134
|
+
## Correctness
|
|
135
|
+
|
|
136
|
+
`pytest` covers the properties you can check without training anything:
|
|
137
|
+
|
|
138
|
+
- **strictly causal** — editing token `t` leaves every earlier logit bitwise unchanged;
|
|
139
|
+
- **decode == prefill** — token-by-token generation from the fixed-size state reproduces the one-shot
|
|
140
|
+
forward, as does unaligned chunked prefill;
|
|
141
|
+
- **right padding is exactly invariant**;
|
|
142
|
+
- **constant work per token** — each query reads the same number of keys at any context length;
|
|
143
|
+
- **the cache is what the architecture claims** — fixed-size recurrent and convolution states everywhere,
|
|
144
|
+
a window-capped key/value cache on non-indexing layers;
|
|
145
|
+
- **tiling is bitwise inert** — `attention_tile_blocks` caps peak activation memory and changes nothing;
|
|
146
|
+
- **every parameter gets gradient**, landmark poolers included.
|
|
147
|
+
|
|
148
|
+
## What this is not
|
|
149
|
+
|
|
150
|
+
**There are no trained checkpoints.** Nobody has trained HELIX on real text. Everything above is about
|
|
151
|
+
complexity, causality and recall mechanics — properties provable on an untrained model or a synthetic
|
|
152
|
+
probe — not about perplexity or language quality. The inductive-bias arguments (multi-scale windows, short
|
|
153
|
+
convolutions, surprise-gated writes) are untested hypotheses.
|
|
154
|
+
|
|
155
|
+
Treat this as an architecture proposal with a working, tested reference implementation, not a better model.
|
|
156
|
+
Finding out whether it is actually better needs real training runs on real hardware.
|
|
157
|
+
|
|
158
|
+
Known design limits, stated plainly:
|
|
159
|
+
|
|
160
|
+
- One retrieval serves a whole query block, so `index_topk` must cover the diversity a `block_size` span
|
|
161
|
+
asks for.
|
|
162
|
+
- Routing is one block stale — the index cannot react to the token currently being generated.
|
|
163
|
+
- Landmarks are pooled from keys that already carry their rotary phase, so routing is not purely
|
|
164
|
+
content-addressed.
|
|
165
|
+
- Left padding shifts the block grid, so it is not bit-identical to an unpadded run. Right padding is.
|
|
166
|
+
- No fused kernel for the gathered attention yet; the scaling is right, the constant factor is not.
|
|
167
|
+
|
|
168
|
+
## Configuration
|
|
169
|
+
|
|
170
|
+
Every knob is on `HelixConfig`, documented in its docstring. The ones that matter most:
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
HelixConfig(
|
|
174
|
+
block_size=64, # memory-block granularity
|
|
175
|
+
local_blocks=4, # strand L sees 4 previous blocks plus its own
|
|
176
|
+
num_window_scales=4, # head groups get geometrically different windows
|
|
177
|
+
index_topk=8, # blocks strand I retrieves per query block
|
|
178
|
+
index_layer_stride=3, # ...on every third layer; the rest keep an O(1) KV cache
|
|
179
|
+
index_branching=8, # landmark tree fan-out
|
|
180
|
+
attention_tile_blocks=64, # caps peak activation memory; no effect on the result
|
|
181
|
+
)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
Apache-2.0. Portions of the delta-rule and rotary helpers derive from
|
|
187
|
+
[HuggingFace Transformers](https://github.com/huggingface/transformers) (Apache-2.0); see `NOTICE`.
|
|
188
|
+
|
|
189
|
+
**Made by Nathan.**
|