latentport 0.2.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.
- latentport-0.2.0/.dockerignore +11 -0
- latentport-0.2.0/CONTRIBUTING.md +26 -0
- latentport-0.2.0/LICENSE +201 -0
- latentport-0.2.0/MANIFEST.in +12 -0
- latentport-0.2.0/PKG-INFO +247 -0
- latentport-0.2.0/README.md +212 -0
- latentport-0.2.0/docker/Dockerfile +46 -0
- latentport-0.2.0/docker/constraints.txt +9 -0
- latentport-0.2.0/docs/api.md +65 -0
- latentport-0.2.0/docs/assets/README.md +3 -0
- latentport-0.2.0/docs/assets/latentport-ascii.gif +0 -0
- latentport-0.2.0/docs/benchmarks.md +56 -0
- latentport-0.2.0/docs/build-status.json +41 -0
- latentport-0.2.0/docs/cached-handoff-validation.json +113 -0
- latentport-0.2.0/docs/clean-install-validation.json +129 -0
- latentport-0.2.0/docs/compaction-validation.json +97 -0
- latentport-0.2.0/docs/compaction.md +91 -0
- latentport-0.2.0/docs/composite-results.json +111 -0
- latentport-0.2.0/docs/cookbook.md +142 -0
- latentport-0.2.0/docs/documentation-checks.json +12 -0
- latentport-0.2.0/docs/huggingface-launch.json +23 -0
- latentport-0.2.0/docs/installation.md +144 -0
- latentport-0.2.0/docs/memory-transplant-validation.json +100 -0
- latentport-0.2.0/docs/model-cards/LPCompact-Qwen3.8-27B/README.md +85 -0
- latentport-0.2.0/docs/model-cards/latentport-4-27b-research-preview/COMPOSITE_RESULTS.json +111 -0
- latentport-0.2.0/docs/model-cards/latentport-4-27b-research-preview/LICENSE_STATUS.md +3 -0
- latentport-0.2.0/docs/model-cards/latentport-4-27b-research-preview/README.md +122 -0
- latentport-0.2.0/docs/model-cards/latentport-4-27b-research-preview/SHA256SUMS.json +89 -0
- latentport-0.2.0/docs/model-cards/latentport-4-27b-research-preview/latentport.json +110 -0
- latentport-0.2.0/docs/model-cards/latentport-4-27b-research-preview-GGUF/COMPOSITE_RESULTS.json +111 -0
- latentport-0.2.0/docs/model-cards/latentport-4-27b-research-preview-GGUF/LICENSE_STATUS.md +3 -0
- latentport-0.2.0/docs/model-cards/latentport-4-27b-research-preview-GGUF/README.md +127 -0
- latentport-0.2.0/docs/model-cards/latentport-4-27b-research-preview-GGUF/RUNTIME_ASSETS.json +32 -0
- latentport-0.2.0/docs/model-cards/latentport-4-27b-research-preview-GGUF/SHA256SUMS.json +73 -0
- latentport-0.2.0/docs/model-cards/latentport-4-27b-research-preview-GGUF/latentport.json +108 -0
- latentport-0.2.0/docs/native-abi.md +181 -0
- latentport-0.2.0/docs/readme-references.md +12 -0
- latentport-0.2.0/docs/releasing.md +74 -0
- latentport-0.2.0/docs/results-section.md +33 -0
- latentport-0.2.0/docs/runtime-validation.json +507 -0
- latentport-0.2.0/docs/state-demo-validation.json +38 -0
- latentport-0.2.0/docs/state-demos.md +73 -0
- latentport-0.2.0/docs/ttft-demo.md +88 -0
- latentport-0.2.0/docs/upstream-gguf-candidate.json +16 -0
- latentport-0.2.0/examples/chat.py +32 -0
- latentport-0.2.0/examples/compact.py +19 -0
- latentport-0.2.0/examples/memory_transplant/server.py +5 -0
- latentport-0.2.0/examples/state_demo.py +279 -0
- latentport-0.2.0/examples/ttft_demo.py +386 -0
- latentport-0.2.0/native/CMakeLists.txt +28 -0
- latentport-0.2.0/native/LICENSE.llama.cpp +21 -0
- latentport-0.2.0/native/latentport.cpp +430 -0
- latentport-0.2.0/native/latentport.h +64 -0
- latentport-0.2.0/native/layout.cu +52 -0
- latentport-0.2.0/native/layout.h +41 -0
- latentport-0.2.0/native/patch_llama.py +33 -0
- latentport-0.2.0/native/speculation.h +15 -0
- latentport-0.2.0/native/test_layout.cpp +35 -0
- latentport-0.2.0/pyproject.toml +41 -0
- latentport-0.2.0/scripts/build_native.ps1 +47 -0
- latentport-0.2.0/scripts/check_bridge_gguf.py +20 -0
- latentport-0.2.0/scripts/check_distribution.py +28 -0
- latentport-0.2.0/scripts/check_long_chat.py +103 -0
- latentport-0.2.0/scripts/check_native_abi.py +12 -0
- latentport-0.2.0/scripts/check_native_state.py +50 -0
- latentport-0.2.0/scripts/pin_gguf_profile.py +34 -0
- latentport-0.2.0/scripts/smoke_gguf.py +246 -0
- latentport-0.2.0/scripts/smoke_runtime.py +102 -0
- latentport-0.2.0/setup.cfg +4 -0
- latentport-0.2.0/src/latentport/__init__.py +14 -0
- latentport-0.2.0/src/latentport/__main__.py +143 -0
- latentport-0.2.0/src/latentport/_compact/__init__.py +58 -0
- latentport-0.2.0/src/latentport/_compact/policy.py +49 -0
- latentport-0.2.0/src/latentport/_compact/weights.py +43 -0
- latentport-0.2.0/src/latentport/_demo/__init__.py +1 -0
- latentport-0.2.0/src/latentport/_demo/fixture.py +293 -0
- latentport-0.2.0/src/latentport/_demo/logging.py +53 -0
- latentport-0.2.0/src/latentport/_demo/server.py +315 -0
- latentport-0.2.0/src/latentport/_demo/web/app.js +70 -0
- latentport-0.2.0/src/latentport/_demo/web/index.html +25 -0
- latentport-0.2.0/src/latentport/_demo/web/logo.png +0 -0
- latentport-0.2.0/src/latentport/_demo/web/style.css +43 -0
- latentport-0.2.0/src/latentport/_dependencies.py +25 -0
- latentport-0.2.0/src/latentport/_downloads.py +66 -0
- latentport-0.2.0/src/latentport/_native/__init__.py +4 -0
- latentport-0.2.0/src/latentport/_native/bridge.py +27 -0
- latentport-0.2.0/src/latentport/_native/engine.py +471 -0
- latentport-0.2.0/src/latentport/_native/gguf_reader.py +92 -0
- latentport-0.2.0/src/latentport/_positions.py +36 -0
- latentport-0.2.0/src/latentport/_reference/__init__.py +1 -0
- latentport-0.2.0/src/latentport/_reference/architecture.py +809 -0
- latentport-0.2.0/src/latentport/_reference/bf16.py +100 -0
- latentport-0.2.0/src/latentport/_reference/bridge.py +106 -0
- latentport-0.2.0/src/latentport/_reference/cache_abi.py +61 -0
- latentport-0.2.0/src/latentport/_reference/native.py +312 -0
- latentport-0.2.0/src/latentport/backend.py +46 -0
- latentport-0.2.0/src/latentport/bridge.py +137 -0
- latentport-0.2.0/src/latentport/codec.py +145 -0
- latentport-0.2.0/src/latentport/composite.py +149 -0
- latentport-0.2.0/src/latentport/configs/architecture_v2.json +32 -0
- latentport-0.2.0/src/latentport/configs/calibration.json +1443 -0
- latentport-0.2.0/src/latentport/configs/cuda-windows.json +17 -0
- latentport-0.2.0/src/latentport/configs/geometry.json +144 -0
- latentport-0.2.0/src/latentport/configs/gguf-models.json +20 -0
- latentport-0.2.0/src/latentport/configs/lpcompact.json +25 -0
- latentport-0.2.0/src/latentport/configs/native-release.json +24 -0
- latentport-0.2.0/src/latentport/diagnostics.py +76 -0
- latentport-0.2.0/src/latentport/errors.py +25 -0
- latentport-0.2.0/src/latentport/gguf.py +223 -0
- latentport-0.2.0/src/latentport/hub.py +152 -0
- latentport-0.2.0/src/latentport/identity.py +103 -0
- latentport-0.2.0/src/latentport/model.py +90 -0
- latentport-0.2.0/src/latentport/port.py +115 -0
- latentport-0.2.0/src/latentport/session.py +230 -0
- latentport-0.2.0/src/latentport/single.py +76 -0
- latentport-0.2.0/src/latentport/state.py +220 -0
- latentport-0.2.0/src/latentport.egg-info/PKG-INFO +247 -0
- latentport-0.2.0/src/latentport.egg-info/SOURCES.txt +125 -0
- latentport-0.2.0/src/latentport.egg-info/dependency_links.txt +1 -0
- latentport-0.2.0/src/latentport.egg-info/entry_points.txt +2 -0
- latentport-0.2.0/src/latentport.egg-info/requires.txt +26 -0
- latentport-0.2.0/src/latentport.egg-info/top_level.txt +1 -0
- latentport-0.2.0/tests/test_compact.py +174 -0
- latentport-0.2.0/tests/test_distribution.py +116 -0
- latentport-0.2.0/tests/test_install.py +107 -0
- latentport-0.2.0/tests/test_native.py +142 -0
- latentport-0.2.0/tests/test_runtime.py +335 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Start with a focused issue or a small patch. Include a runnable reproduction for fixes.
|
|
4
|
+
|
|
5
|
+
```powershell
|
|
6
|
+
python -m pip install torch==2.11.0 --index-url https://download.pytorch.org/whl/cpu
|
|
7
|
+
python -m pip install -e ".[gguf,dev]"
|
|
8
|
+
python -m pytest -q
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Lightweight packaging checks also run without inference extras:
|
|
12
|
+
`python -m unittest discover -s tests -p test_distribution.py`.
|
|
13
|
+
|
|
14
|
+
GPU checks are separate and require an idle supported GPU. Use `scripts/smoke_gguf.py`
|
|
15
|
+
for state/MTP correctness and `scripts/check_long_chat.py --policy cached_handoff`
|
|
16
|
+
for the bounded long-context conversation check. Both accept explicit model paths and
|
|
17
|
+
require `--gpu-is-free`. Keep large weights, captured states and build output outside
|
|
18
|
+
this repository. Never submit credentials or private conversation snapshots.
|
|
19
|
+
|
|
20
|
+
Behavioral contracts matter: no silent target replay; exact compatibility checks;
|
|
21
|
+
immutable published states; independent branches; rollback before publishing a speculative
|
|
22
|
+
state; and honest timing including source and translation work.
|
|
23
|
+
|
|
24
|
+
Native changes must preserve the pinned ABI or explicitly version it. Follow
|
|
25
|
+
[the native guide](docs/native-abi.md). New platforms and bridges need their own
|
|
26
|
+
qualification; passing CPU mocks does not establish real-model correctness.
|
latentport-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
include LICENSE README.md
|
|
2
|
+
recursive-include native *.h *.cpp *.cu *.py CMakeLists.txt
|
|
3
|
+
recursive-include native LICENSE*
|
|
4
|
+
recursive-include scripts *.py *.ps1
|
|
5
|
+
recursive-include docs *.md
|
|
6
|
+
recursive-include docs *.json
|
|
7
|
+
recursive-include tests *.py
|
|
8
|
+
recursive-include examples *.py
|
|
9
|
+
recursive-include docs/assets *.gif
|
|
10
|
+
include CONTRIBUTING.md
|
|
11
|
+
recursive-include docker Dockerfile *.txt
|
|
12
|
+
include .dockerignore
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: latentport
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Programmable full-state transfer between hybrid language models
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://latentport.com
|
|
7
|
+
Project-URL: Repository, https://github.com/LatentPort/latentport
|
|
8
|
+
Project-URL: Documentation, https://github.com/LatentPort/latentport/tree/main/docs
|
|
9
|
+
Project-URL: Models, https://huggingface.co/latentport
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Provides-Extra: gguf
|
|
14
|
+
Requires-Dist: huggingface_hub<2,>=1.33; extra == "gguf"
|
|
15
|
+
Requires-Dist: safetensors<1,>=0.8; extra == "gguf"
|
|
16
|
+
Requires-Dist: numpy<3,>=2.3; extra == "gguf"
|
|
17
|
+
Requires-Dist: torch<3,>=2.11; extra == "gguf"
|
|
18
|
+
Requires-Dist: transformers==5.17.0; extra == "gguf"
|
|
19
|
+
Provides-Extra: bf16
|
|
20
|
+
Requires-Dist: latentport[gguf]; extra == "bf16"
|
|
21
|
+
Requires-Dist: accelerate<2,>=1.15; extra == "bf16"
|
|
22
|
+
Requires-Dist: fla-core==0.6.0; extra == "bf16"
|
|
23
|
+
Requires-Dist: causal-conv1d==1.7.0; extra == "bf16"
|
|
24
|
+
Provides-Extra: reference
|
|
25
|
+
Requires-Dist: latentport[gguf]; extra == "reference"
|
|
26
|
+
Requires-Dist: accelerate<2,>=1.15; extra == "reference"
|
|
27
|
+
Requires-Dist: bitsandbytes<0.51,>=0.50.2; extra == "reference"
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
30
|
+
Requires-Dist: build>=1; extra == "dev"
|
|
31
|
+
Requires-Dist: twine>=6; extra == "dev"
|
|
32
|
+
Provides-Extra: compact
|
|
33
|
+
Requires-Dist: latentport[bf16]; extra == "compact"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# LatentPort
|
|
37
|
+
|
|
38
|
+
**LatentPort makes LLM internal states programmable.**
|
|
39
|
+
|
|
40
|
+
We're building a library of learned state transformations that enable models and
|
|
41
|
+
agents to transfer, compact, optimise and combine their internal states during
|
|
42
|
+
inference.
|
|
43
|
+
|
|
44
|
+
This allows developers to improve model performance, reduce inference costs and
|
|
45
|
+
build longer-running agents without repeatedly processing the same context.
|
|
46
|
+
|
|
47
|
+
<p align="center">
|
|
48
|
+
<img src="https://raw.githubusercontent.com/LatentPort/latentport/main/docs/assets/latentport-ascii.gif" alt="LatentPort: programmable model state" width="640">
|
|
49
|
+
</p>
|
|
50
|
+
|
|
51
|
+
[Website](https://latentport.com) | [Get started](#get-started) | [Models](https://huggingface.co/latentport) | [Cookbook](https://github.com/LatentPort/latentport/blob/main/docs/cookbook.md) | [API](https://github.com/LatentPort/latentport/blob/main/docs/api.md)
|
|
52
|
+
|
|
53
|
+

|
|
54
|
+
[](https://github.com/LatentPort/latentport/releases/tag/lpcompact-v0.1)
|
|
55
|
+
|
|
56
|
+
## A library of state operations
|
|
57
|
+
|
|
58
|
+
A model's internal state carries what it has already processed. LatentPort exposes
|
|
59
|
+
that state as an object developers can transform, persist, reuse and branch.
|
|
60
|
+
Learned operators work directly on state tensors, allowing inference to continue
|
|
61
|
+
from the transformed state.
|
|
62
|
+
|
|
63
|
+
| Operation | Purpose | Available today |
|
|
64
|
+
| --- | --- | --- |
|
|
65
|
+
| **Transfer** | Move working context into another model's state space. | Learned Qwen3.5-4B to Qwen3.8-27B bridge via `bridge.translate(state)`. |
|
|
66
|
+
| **Compact** | Reduce attention memory while retaining the model's recurrent and convolutional state. | LPCompact 0.1 for Qwen3.8-27B via `state.compact()`. |
|
|
67
|
+
| **Optimise** | Improve a state for the task or inference objective ahead. | Part of the roadmap. |
|
|
68
|
+
| **Combine** | Bring information from multiple states into a shared working state. | Part of the roadmap. |
|
|
69
|
+
|
|
70
|
+
The shared runtime also provides capture, append, save, load and fork operations.
|
|
71
|
+
Snapshots are immutable, so branches can share a starting context while advancing
|
|
72
|
+
independently. Each learned transformation is trained for its supported model
|
|
73
|
+
architecture or model pair.
|
|
74
|
+
|
|
75
|
+
## Get started
|
|
76
|
+
|
|
77
|
+
Install the lightweight Python package with Python 3.11 or later:
|
|
78
|
+
|
|
79
|
+
```shell
|
|
80
|
+
python -m pip install latentport
|
|
81
|
+
latentport doctor
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The base package includes the API, diagnostics and demo interface. Inference
|
|
85
|
+
dependencies are optional: see [installation](https://github.com/LatentPort/latentport/blob/main/docs/installation.md) for
|
|
86
|
+
`latentport[gguf]`, `latentport[bf16]` and CUDA PyTorch setup.
|
|
87
|
+
|
|
88
|
+
### Try the browser demo
|
|
89
|
+
|
|
90
|
+
On a qualified NVIDIA GPU host with Docker GPU access configured:
|
|
91
|
+
|
|
92
|
+
```shell
|
|
93
|
+
docker run --rm --gpus all -p 127.0.0.1:8768:8768 -v latentport-cache:/cache ghcr.io/latentport/latentport:0.2.0-gguf-cu128-sm120
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Open **http://localhost:8768**. The demo prepares the models, transfers context,
|
|
97
|
+
forks specialist sessions, and checks a generated repair with executable tests.
|
|
98
|
+
The initial transfer profile requires an SM120 GPU with at least 32 GB VRAM and
|
|
99
|
+
approximately 22.10 GB of model downloads; subsequent runs reuse the volume.
|
|
100
|
+
Windows Docker GPU execution requires the WSL 2 backend.
|
|
101
|
+
|
|
102
|
+
**Release status:** the Python package is available on [PyPI](https://pypi.org/project/latentport/).
|
|
103
|
+
The GHCR images are pending GPU qualification and publication; until then, use
|
|
104
|
+
the [local image build](https://github.com/LatentPort/latentport/blob/main/docs/installation.md).
|
|
105
|
+
|
|
106
|
+
Choose the setup for your operation:
|
|
107
|
+
|
|
108
|
+
- **Compaction:** [BF16 and GGUF setup](https://github.com/LatentPort/latentport/blob/main/docs/compaction.md), including the BF16 kernel dependencies and native GGUF runtime.
|
|
109
|
+
- **Model transfer:** [Windows GGUF setup](https://github.com/LatentPort/latentport/blob/main/docs/installation.md) and [conversation recipes](https://github.com/LatentPort/latentport/blob/main/docs/cookbook.md).
|
|
110
|
+
|
|
111
|
+
Set `LATENTPORT_HOME` to a directory with enough space for downloaded models and
|
|
112
|
+
caches. The runtime downloads transformation weights when needed; base models are
|
|
113
|
+
separate artifacts. Prebuilt GGUF runtimes are available for Windows x64 / CUDA 13
|
|
114
|
+
and Linux x64 / CUDA 12.8 on Blackwell SM120.
|
|
115
|
+
|
|
116
|
+
## Compact a running model's state
|
|
117
|
+
|
|
118
|
+
[LPCompact-Qwen3.8-27B](https://huggingface.co/latentport/LPCompact-Qwen3.8-27B)
|
|
119
|
+
provides a learned selector through a single operation:
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
state = state.compact()
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Given an agent's accumulated `history`, continue from its compacted state:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
import latentport as lp
|
|
129
|
+
|
|
130
|
+
with lp.load_model(backend="bf16") as model:
|
|
131
|
+
state = model.prefill(history)
|
|
132
|
+
state = state.compact()
|
|
133
|
+
answer = model.session(state).ask("Continue the task.")
|
|
134
|
+
print(answer.text)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The default policy retains one eighth of attention KV positions on histories with
|
|
138
|
+
at least 65,536 retained positions. A 4x setting is available with
|
|
139
|
+
`state.compact(ratio=4)`. Recurrent state, convolution state and the original
|
|
140
|
+
logical positions are preserved. Compaction uses no text summary or historical
|
|
141
|
+
token replay.
|
|
142
|
+
|
|
143
|
+
One selector checkpoint serves Qwen3.8-27B BF16 and GGUF weight quantizations.
|
|
144
|
+
For GGUF, use `backend="gguf"` and supply `model_path` with your chosen base-model
|
|
145
|
+
file. See the [compaction guide](https://github.com/LatentPort/latentport/blob/main/docs/compaction.md) for context sizing, policy
|
|
146
|
+
details and the `state.compaction` receipt.
|
|
147
|
+
|
|
148
|
+
## Transfer context between models
|
|
149
|
+
|
|
150
|
+
The current transfer bridge lets Qwen3.5-4B read a context and Qwen3.8-27B continue
|
|
151
|
+
from the translated state. It transfers attention K/V, recurrent memory,
|
|
152
|
+
convolution history and the terminal hidden state.
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
import latentport as lp
|
|
156
|
+
|
|
157
|
+
with lp.load(backend="gguf") as port:
|
|
158
|
+
port.warm()
|
|
159
|
+
context = port.source.capture([("user", "Repository context: ...")])
|
|
160
|
+
transferred = port.bridge.translate(context)
|
|
161
|
+
answer = port.target.session(transferred).ask("Explain the repository.")
|
|
162
|
+
print(answer.text)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
For a complete conversation, `port.composite.session()` handles the initial
|
|
166
|
+
handoff and retains the target's state across turns. The default `cached_handoff`
|
|
167
|
+
policy translates once, then processes new input on the target. An explicit
|
|
168
|
+
`strict` policy keeps the source model responsible for new user prompts.
|
|
169
|
+
|
|
170
|
+
The [cookbook](https://github.com/LatentPort/latentport/blob/main/docs/cookbook.md) covers both policies, answer continuation,
|
|
171
|
+
streaming and MTP. Existing local GGUF files can be supplied through `source_path`
|
|
172
|
+
and `target_path`.
|
|
173
|
+
|
|
174
|
+
## Reuse, branch and resume
|
|
175
|
+
|
|
176
|
+
The same state abstraction supports persistence and independent continuations:
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
review_state, planning_state = state.fork(2)
|
|
180
|
+
state.save("saved-state")
|
|
181
|
+
restored = lp.State.load("saved-state")
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Prepare a repository once, let different agents work from the same snapshot, or
|
|
185
|
+
save a long-running session and resume it later. Restoring a state reuses the
|
|
186
|
+
captured context. Appending new tool results processes the new input.
|
|
187
|
+
|
|
188
|
+
Each snapshot records its exact model identity and runtime compatibility. Forks
|
|
189
|
+
share immutable storage; execution uses the selected backend's scheduling.
|
|
190
|
+
|
|
191
|
+
## Measured results
|
|
192
|
+
|
|
193
|
+
| Transformation | Measurement | Validation |
|
|
194
|
+
| --- | --- | --- |
|
|
195
|
+
| LPCompact, 128K history at 8x | Attention KV tensors reduced from **8 GiB to 1 GiB**. | BF16, Q4_K_M and Q8_0 tested at 64K and 128K on RTX PRO 6000; continued generation, save/load, forks and repeated compaction passed. |
|
|
196
|
+
| 4B to 27B transfer, approximately 16K prompts | **2.19x paired time-to-first-token speedup**; native median 24.663 s, composite median 11.087 s. | E120 resident NF4/BF16 research runtime on RTX 5090; paired 95% interval 2.15-2.23x. |
|
|
197
|
+
|
|
198
|
+
These measurements describe their stated workloads and configurations. Compaction
|
|
199
|
+
reduces attention-state storage; model weights and recurrent state retain their
|
|
200
|
+
existing representation. The transfer timing includes prefill, translation,
|
|
201
|
+
installation and the first emitted token, excluding cold model loading.
|
|
202
|
+
|
|
203
|
+
See [compaction validation](https://github.com/LatentPort/latentport/blob/main/docs/compaction-validation.json),
|
|
204
|
+
[transfer results](https://github.com/LatentPort/latentport/blob/main/docs/composite-results.json) and
|
|
205
|
+
[benchmark methodology](https://github.com/LatentPort/latentport/blob/main/docs/benchmarks.md) for the full records.
|
|
206
|
+
|
|
207
|
+
## A state operating layer for inference
|
|
208
|
+
|
|
209
|
+
The long-term direction is a state operating layer for AI inference:
|
|
210
|
+
|
|
211
|
+
- **Model-specific translators** connect the internal state spaces of compatible models.
|
|
212
|
+
- **Reusable operators** transfer, compact, optimise and combine state through a shared interface.
|
|
213
|
+
- **A policy engine** selects transformations automatically according to the application's capability, latency and memory requirements.
|
|
214
|
+
|
|
215
|
+
The current release provides explicit transfer and compaction operations, plus
|
|
216
|
+
the state lifecycle primitives. Learned optimisation, state combination and
|
|
217
|
+
automatic policy selection are the next layers of that vision.
|
|
218
|
+
|
|
219
|
+
## One runtime, separate transformation models
|
|
220
|
+
|
|
221
|
+
The shared Python runtime lives in this GitHub repository. Each trained state
|
|
222
|
+
transformation has its own Hugging Face repository, with model compatibility,
|
|
223
|
+
weights, versions and a model card.
|
|
224
|
+
|
|
225
|
+
- [LPCompact-Qwen3.8-27B](https://huggingface.co/latentport/LPCompact-Qwen3.8-27B): the compaction selector shared across BF16 and GGUF.
|
|
226
|
+
- [4B to 27B transfer bridge](https://huggingface.co/latentport/latentport-4-27b-research-preview): the current directional translator; [GGUF artifacts](https://huggingface.co/latentport/latentport-4-27b-research-preview-GGUF) are also available.
|
|
227
|
+
|
|
228
|
+
Transformation repositories contain their own learned artifacts. Base-model
|
|
229
|
+
weights are obtained separately.
|
|
230
|
+
|
|
231
|
+
## Demos and documentation
|
|
232
|
+
|
|
233
|
+
- [Memory transplant demo](https://github.com/LatentPort/latentport/blob/main/examples/memory_transplant/README.md): live state transfer, specialist branches and a repair checked by executable tests.
|
|
234
|
+
- [State demos](https://github.com/LatentPort/latentport/blob/main/docs/state-demos.md): cached conversations, branching, save/resume and fresh context updates.
|
|
235
|
+
- [Time-to-first-token demo](https://github.com/LatentPort/latentport/blob/main/docs/ttft-demo.md): compare native 27B and composite inference on a fresh 16K prompt.
|
|
236
|
+
- [Compaction guide](https://github.com/LatentPort/latentport/blob/main/docs/compaction.md), [cookbook](https://github.com/LatentPort/latentport/blob/main/docs/cookbook.md) and [API contracts](https://github.com/LatentPort/latentport/blob/main/docs/api.md).
|
|
237
|
+
- [Native integration](https://github.com/LatentPort/latentport/blob/main/docs/native-abi.md) and [contributing](CONTRIBUTING.md).
|
|
238
|
+
|
|
239
|
+
Report reproducible issues at [GitHub Issues](https://github.com/LatentPort/latentport/issues).
|
|
240
|
+
Include the output of `python -m latentport doctor`, model identities and a minimal
|
|
241
|
+
example, with private prompts and credentials removed.
|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
The LatentPort runtime and transformation weights are Apache-2.0. Qwen base models
|
|
246
|
+
retain their upstream licenses, and llama.cpp retains its MIT license. See
|
|
247
|
+
[LICENSE](LICENSE) and the notices supplied with the model and native downloads.
|