poros-train 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.
Files changed (78) hide show
  1. poros_train-0.1.0/LICENSE +190 -0
  2. poros_train-0.1.0/PKG-INFO +225 -0
  3. poros_train-0.1.0/README.md +178 -0
  4. poros_train-0.1.0/poros/__init__.py +121 -0
  5. poros_train-0.1.0/poros/adapters/__init__.py +15 -0
  6. poros_train-0.1.0/poros/adapters/inspect.py +254 -0
  7. poros_train-0.1.0/poros/auto/__init__.py +30 -0
  8. poros_train-0.1.0/poros/auto/prepare.py +453 -0
  9. poros_train-0.1.0/poros/auto/printing.py +76 -0
  10. poros_train-0.1.0/poros/auto/reports.py +236 -0
  11. poros_train-0.1.0/poros/bench/__init__.py +34 -0
  12. poros_train-0.1.0/poros/bench/artifacts.py +226 -0
  13. poros_train-0.1.0/poros/bench/baselines/__init__.py +36 -0
  14. poros_train-0.1.0/poros/bench/baselines/_subprocess.py +206 -0
  15. poros_train-0.1.0/poros/bench/baselines/accelerate_offload.py +232 -0
  16. poros_train-0.1.0/poros/bench/baselines/peft.py +226 -0
  17. poros_train-0.1.0/poros/bench/baselines/poros.py +520 -0
  18. poros_train-0.1.0/poros/bench/baselines/resident.py +272 -0
  19. poros_train-0.1.0/poros/bench/baselines/unsloth.py +255 -0
  20. poros_train-0.1.0/poros/bench/device.py +208 -0
  21. poros_train-0.1.0/poros/bench/matrix.py +115 -0
  22. poros_train-0.1.0/poros/bench/metrics.py +163 -0
  23. poros_train-0.1.0/poros/bench/runner.py +457 -0
  24. poros_train-0.1.0/poros/bench/specs.py +184 -0
  25. poros_train-0.1.0/poros/cli/__init__.py +1 -0
  26. poros_train-0.1.0/poros/cli/main.py +1264 -0
  27. poros_train-0.1.0/poros/core/__init__.py +17 -0
  28. poros_train-0.1.0/poros/core/arch_registry.py +430 -0
  29. poros_train-0.1.0/poros/core/blockwise.py +641 -0
  30. poros_train-0.1.0/poros/core/config.py +192 -0
  31. poros_train-0.1.0/poros/core/determinism.py +100 -0
  32. poros_train-0.1.0/poros/core/env.py +93 -0
  33. poros_train-0.1.0/poros/core/errors.py +252 -0
  34. poros_train-0.1.0/poros/core/events.py +80 -0
  35. poros_train-0.1.0/poros/core/fused_lora.py +130 -0
  36. poros_train-0.1.0/poros/core/precision.py +139 -0
  37. poros_train-0.1.0/poros/core/residency.py +694 -0
  38. poros_train-0.1.0/poros/display/__init__.py +1 -0
  39. poros_train-0.1.0/poros/display/panels.py +455 -0
  40. poros_train-0.1.0/poros/display/sparkline.py +165 -0
  41. poros_train-0.1.0/poros/patch/__init__.py +1 -0
  42. poros_train-0.1.0/poros/patch/hf.py +1218 -0
  43. poros_train-0.1.0/poros/py.typed +0 -0
  44. poros_train-0.1.0/poros/report/__init__.py +35 -0
  45. poros_train-0.1.0/poros/report/assets/poros.css +744 -0
  46. poros_train-0.1.0/poros/report/html.py +894 -0
  47. poros_train-0.1.0/poros/report/leaderboard.py +304 -0
  48. poros_train-0.1.0/poros/report/markdown.py +556 -0
  49. poros_train-0.1.0/poros/train/__init__.py +10 -0
  50. poros_train-0.1.0/poros/train/adapters.py +456 -0
  51. poros_train-0.1.0/poros/train/config.py +7 -0
  52. poros_train-0.1.0/poros/train/model.py +475 -0
  53. poros_train-0.1.0/poros/train/projection.py +355 -0
  54. poros_train-0.1.0/poros/train/scheduler.py +150 -0
  55. poros_train-0.1.0/poros/train/streamed_load.py +298 -0
  56. poros_train-0.1.0/poros/train/trainer.py +2500 -0
  57. poros_train-0.1.0/poros_train.egg-info/PKG-INFO +225 -0
  58. poros_train-0.1.0/poros_train.egg-info/SOURCES.txt +76 -0
  59. poros_train-0.1.0/poros_train.egg-info/dependency_links.txt +1 -0
  60. poros_train-0.1.0/poros_train.egg-info/entry_points.txt +2 -0
  61. poros_train-0.1.0/poros_train.egg-info/requires.txt +24 -0
  62. poros_train-0.1.0/poros_train.egg-info/top_level.txt +1 -0
  63. poros_train-0.1.0/pyproject.toml +83 -0
  64. poros_train-0.1.0/setup.cfg +4 -0
  65. poros_train-0.1.0/tests/test_adapter_inspect.py +187 -0
  66. poros_train-0.1.0/tests/test_auto_prepare.py +212 -0
  67. poros_train-0.1.0/tests/test_auto_reports.py +68 -0
  68. poros_train-0.1.0/tests/test_checkpoint_weights_only.py +55 -0
  69. poros_train-0.1.0/tests/test_cpu_auto_prepare.py +282 -0
  70. poros_train-0.1.0/tests/test_gpu_auto_prepare.py +115 -0
  71. poros_train-0.1.0/tests/test_gpu_parity.py +97 -0
  72. poros_train-0.1.0/tests/test_hf_loader_masking.py +110 -0
  73. poros_train-0.1.0/tests/test_import.py +116 -0
  74. poros_train-0.1.0/tests/test_poros_integration.py +982 -0
  75. poros_train-0.1.0/tests/test_streamed_load.py +105 -0
  76. poros_train-0.1.0/tests/test_synthetic_dataset.py +73 -0
  77. poros_train-0.1.0/tests/test_train_loop_cpu.py +171 -0
  78. poros_train-0.1.0/tests/test_v11_hardening.py +580 -0
@@ -0,0 +1,190 @@
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 the 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 the 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 any 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
+ Copyright 2026 Caistro Labs
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,225 @@
1
+ Metadata-Version: 2.4
2
+ Name: poros-train
3
+ Version: 0.1.0
4
+ Summary: Blockwise residency for frozen-base QLoRA. Fine-tune 32B on 16GB, bitwise-identical.
5
+ Author-email: Jeffrey Tigres <contact@caistrolabs.com>
6
+ Maintainer-email: Caistro Labs <contact@caistrolabs.com>
7
+ License: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/Caistro-Labs/poros
9
+ Project-URL: Repository, https://github.com/Caistro-Labs/poros
10
+ Project-URL: Issues, https://github.com/Caistro-Labs/poros/issues
11
+ Project-URL: Documentation, https://github.com/Caistro-Labs/poros#readme
12
+ Keywords: qlora,lora,fine-tuning,transformers,gpu-memory
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.11
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: typer>=0.12
26
+ Requires-Dist: rich>=13.7
27
+ Requires-Dist: pydantic>=2.7
28
+ Requires-Dist: pyyaml>=6.0
29
+ Provides-Extra: ml
30
+ Requires-Dist: torch>=2.10; extra == "ml"
31
+ Requires-Dist: transformers<6,>=5.5; extra == "ml"
32
+ Requires-Dist: datasets>=2.16; extra == "ml"
33
+ Requires-Dist: peft>=0.13; extra == "ml"
34
+ Requires-Dist: accelerate>=0.34; extra == "ml"
35
+ Requires-Dist: bitsandbytes>=0.43; extra == "ml"
36
+ Requires-Dist: huggingface-hub>=0.25; extra == "ml"
37
+ Requires-Dist: safetensors>=0.4; extra == "ml"
38
+ Provides-Extra: bench
39
+ Requires-Dist: matplotlib>=3.8; extra == "bench"
40
+ Requires-Dist: jinja2>=3.1; extra == "bench"
41
+ Provides-Extra: dev
42
+ Requires-Dist: pytest>=8.0; extra == "dev"
43
+ Requires-Dist: ruff; extra == "dev"
44
+ Requires-Dist: jinja2>=3.1; extra == "dev"
45
+ Requires-Dist: matplotlib>=3.8; extra == "dev"
46
+ Dynamic: license-file
47
+
48
+ <div align="center">
49
+
50
+ <img src="https://raw.githubusercontent.com/Caistro-Labs/poros/main/docs/assets/poros-banner-dark.png" alt="Poros — bit-exact fine-tuning on consumer GPUs" width="100%">
51
+
52
+ <a href="https://pypi.org/project/poros-train/"><img src="https://raw.githubusercontent.com/Caistro-Labs/poros/main/docs/assets/badge-pypi.png" height="28" alt="pypi v0.1.0"></a>&nbsp;<a href="https://github.com/Caistro-Labs/poros/blob/main/pyproject.toml"><img src="https://raw.githubusercontent.com/Caistro-Labs/poros/main/docs/assets/badge-python.png" height="28" alt="python 3.11+"></a>&nbsp;<a href="https://github.com/Caistro-Labs/poros/blob/main/LICENSE"><img src="https://raw.githubusercontent.com/Caistro-Labs/poros/main/docs/assets/badge-license.png" height="28" alt="license apache-2.0"></a>&nbsp;<a href="https://github.com/Caistro-Labs/poros/tree/main/docs/validation"><img src="https://raw.githubusercontent.com/Caistro-Labs/poros/main/docs/assets/badge-parity.png" height="28" alt="parity 0.00e+00"></a>
53
+
54
+ <br>
55
+
56
+ <a href="#install"><kbd>&nbsp;Install&nbsp;</kbd></a>&nbsp;
57
+ <a href="#quickstart"><kbd>&nbsp;Quickstart&nbsp;</kbd></a>&nbsp;
58
+ <a href="#benchmarks"><kbd>&nbsp;Benchmarks&nbsp;</kbd></a>&nbsp;
59
+ <a href="#supported-models"><kbd>&nbsp;Models&nbsp;</kbd></a>&nbsp;
60
+ <a href="#how-it-works"><kbd>&nbsp;How&nbsp;it&nbsp;works&nbsp;</kbd></a>&nbsp;
61
+ <a href="https://github.com/Caistro-Labs/poros/blob/main/docs/index.md"><kbd>&nbsp;Docs&nbsp;</kbd></a>&nbsp;
62
+ <a href="https://github.com/Caistro-Labs/poros/blob/main/paper/poros.pdf"><kbd>&nbsp;Paper&nbsp;</kbd></a>
63
+
64
+ </div>
65
+
66
+ ---
67
+
68
+ Poros streams the frozen base of a QLoRA fine-tune through the GPU one block at a time, so only the adapters and a single block are ever resident. The adapter it produces is bit-for-bit identical to a fully resident run, verified with `torch.equal` (not `allclose`): all four surfaces — loss, adapter weights, gradient norms, and optimizer state — are gated directly at 7B and 32B; at 72B, loss and weights are gated directly and the other two are inferred from the bit-identical weight trajectory.
69
+
70
+ - **32B trains in 11.61 GB** peak VRAM (44.88 GB resident) — inside a 16 GB budget
71
+ - **72B trains end-to-end on a single RTX 5090** — 18.13 GB training peak on the 5090 (18.87 GB canonical; 81.57 GB resident)
72
+ - **Parity is 0.00e+00, not "close"** — gated over 200-step and 1000-step runs, with dropout, gradient accumulation, and `torch.compile`
73
+ - **One line** on top of your existing PEFT script
74
+
75
+ ## Install
76
+
77
+ ```bash
78
+ pip install poros-train # CLI + config, no GPU needed
79
+ pip install "poros-train[ml]" # + torch, transformers, peft, bitsandbytes
80
+ pip install "poros-train[ml,bench]" # + benchmark harness
81
+ ```
82
+
83
+ Python 3.11+, PyTorch 2.10+, Transformers 5.5+, Linux with CUDA. The base install runs `poros --help`, `poros check`, and `poros doctor` on CPU-only machines.
84
+
85
+ ## Quickstart
86
+
87
+ Already have a Hugging Face + PEFT script? Add one line and keep your loop:
88
+
89
+ ```python
90
+ import poros
91
+
92
+ model = poros.prepare(model) # your loop, your config, untouched
93
+ trainer.train()
94
+ ```
95
+
96
+ ```text
97
+ Poros prepared model
98
+ model Qwen/Qwen2.5-7B
99
+ model_type qwen2
100
+ architecture certified
101
+ adapter lora (certified)
102
+ precision NF4
103
+ stack certified
104
+ block_size 4
105
+ guarantee official bitwise path (NF4, deterministic)
106
+ ```
107
+
108
+ `prepare()` never touches your training setup — learning rate, LoRA config, optimizer, and data stay exactly as you wrote them. It detects the architecture, wraps the model in place, and reports which guarantee applies. Paths not gated at 0.00e+00 are labeled `experimental` or `target`. Reverse it any time with `poros.unprepare(model)`.
109
+
110
+ No script yet? `PorosTrainer` is the five-line path:
111
+
112
+ ```python
113
+ from poros import PorosTrainer
114
+
115
+ trainer = PorosTrainer.from_pretrained(
116
+ "Qwen/Qwen2.5-32B", quantization="nf4", lora_rank=16, lora_alpha=32,
117
+ )
118
+ trainer.train("OpenAssistant/oasst1", steps=200, seq_len=512)
119
+ trainer.save("./poros-qwen32b-lora")
120
+ ```
121
+
122
+ The saved adapter is a standard PEFT adapter — load it with `PeftModel.from_pretrained`, or merge for vLLM/TGI with `poros export ./poros-qwen32b-lora -o ./merged`. See [examples/inference.py](https://github.com/Caistro-Labs/poros/blob/main/examples/inference.py).
123
+
124
+ If a block doesn't fit your card, `PorosOOMError` suggests a smaller `block_size` to try. Details: [docs/quickstart.md](https://github.com/Caistro-Labs/poros/blob/main/docs/quickstart.md) · [docs/api.md](https://github.com/Caistro-Labs/poros/blob/main/docs/api.md).
125
+
126
+ ## Benchmarks
127
+
128
+ Consumer cards, measured. Every row has a raw artifact in [docs/validation/](https://github.com/Caistro-Labs/poros/tree/main/docs/validation); the datacenter matrices (A100, B300, RTX PRO 6000) live in [docs/official-a100-results.md](https://github.com/Caistro-Labs/poros/blob/main/docs/official-a100-results.md) and [docs/official-b300-results.md](https://github.com/Caistro-Labs/poros/blob/main/docs/official-b300-results.md).
129
+
130
+ **RTX 3090 (24 GB)** — Qwen2.5 QLoRA, all methods on identical data, seeds, and deterministic kernels (rank-16 LoRA, NF4, seq_len 512, 200 steps):
131
+
132
+ | Scale | Method | Peak VRAM | s/step |
133
+ |---|---|---|---|
134
+ | 7B | PEFT QLoRA | 16.37 GB | 0.51 |
135
+ | 7B | Accelerate CPU-offload | 9.71 GB | 0.73 |
136
+ | 7B | Unsloth QLoRA | 8.66 GB | 0.53 |
137
+ | 7B | **Poros** | **6.90 GB** | 0.87 |
138
+ | 32B | PEFT QLoRA | OOM | — |
139
+ | 32B | Accelerate CPU-offload | OOM | — |
140
+ | 32B | Unsloth QLoRA¹ | 22.29 GB | 2.07 |
141
+ | 32B | **Poros** | **11.61 GB** | 3.21 |
142
+
143
+ ¹ Unsloth at 32B fits only with its own `use_gradient_checkpointing="unsloth"` mode; without it, it OOMs at ~23 GB. Final losses match to ≤4×10⁻⁴ across methods (kernel dispatch); Poros is bit-identical to its resident reference on the primary platform.
144
+
145
+ **RTX 5090 (32 GB)** — official validation runs (PyTorch 2.11.0+cu128):
146
+
147
+ | Run | Steps | Peak VRAM | Result |
148
+ |---|---|---|---|
149
+ | Qwen2.5-32B, synthetic | 50 | **11.02 GB** | loss tracks the A100 trajectory to ~2×10⁻⁴ |
150
+ | Qwen2.5-32B, real data (oasst1) | 100 | **11.02 GB** | padding-masked CE, same 11.02 GB envelope |
151
+ | Qwen2.5-72B, end-to-end | 10 | **18.13 GB** train · 30.57 GB process peak | streamed load + training on one card; loss matches the PRO 6000 run to ~1×10⁻⁵ |
152
+
153
+ The 72B process peak is the startup self-check probe, not the loader — the streamed loader's own ceiling is 1.63 GB at 72B. The 5090 runs use the instrumented single-pass validation protocol, so step-time comparisons belong in the 3090 table above.
154
+
155
+ The cost, on consumer hardware: 0.87 vs 0.51 s/step at 7B on the 3090 (about 1.7×). At 32B and 72B there is no resident consumer baseline to be slower than — it OOMs. If your model fits comfortably resident, run it resident.
156
+
157
+ The streamed NF4 loader (default) keeps host RAM at 12.1 / 34.7 / 48.2 GB RSS for 7B / 32B / 72B (standard path: 15.3 / 62.0 / 136.5 GB).
158
+
159
+ Reproduce any row with the shipped configs, e.g. `poros bench run configs/bench/official_a100_qwen25_32b.yaml`. Consumer guidance: [docs/consumer-gpus.md](https://github.com/Caistro-Labs/poros/blob/main/docs/consumer-gpus.md).
160
+
161
+ ## Supported models
162
+
163
+ Every validated family is gated at exactly 0.00e+00 on real hardware — byte-identical load plus bitwise training parity. The four surfaces (loss, adapter weights, gradient norms, optimizer state) are gated directly at 7B and 32B; at 72B, loss and weights are gated directly and the other two are inferred from the bit-identical weights.
164
+
165
+ | Family | `model_type` | Coverage |
166
+ |---|---|---|
167
+ | Qwen2.5 | `qwen2` | 0.5B–72B, incl. DeepSeek-R1-Distill-Qwen |
168
+ | Qwen3 | `qwen3` | 32B |
169
+ | Qwen3.5 / Qwen3.6 dense | `qwen3_5` | 0.8B–27B |
170
+ | Gemma 3 | `gemma3` | 27B |
171
+ | Gemma 4 | `gemma4` | 31B |
172
+
173
+ Check any model without downloading it:
174
+
175
+ ```bash
176
+ poros check Qwen/Qwen3.5-27B # resolves model_type + status, no torch needed
177
+ ```
178
+
179
+ Unvalidated architectures fail loudly instead of training with an unverified guarantee. MoE models with fused expert layers (Qwen3-MoE, GLM-4.5+, gpt-oss) are not NF4-quantizable and are out of scope. Roadmap and the registry mechanism: [docs/architecture-support.md](https://github.com/Caistro-Labs/poros/blob/main/docs/architecture-support.md).
180
+
181
+ ## How it works
182
+
183
+ A frozen base receives no gradients — it sits in VRAM only because the forward pass reads it. Poros bounds residency to one block plus prefetch in both directions: the forward streams blocks through a small GPU window, the backward reloads each block and recomputes its forward before differentiating adapters and block inputs.
184
+
185
+ Exactness comes from RNG capture. Recomputing a block would normally redraw its dropout masks and silently change the gradients; Poros snapshots CPU and CUDA RNG state before each block's forward and restores it inside `torch.random.fork_rng` during recomputation, so the backward runs on the identical graph. Nothing about the learning problem changes — same kernels, same optimizer, same data order.
186
+
187
+ The formal statement and full audit matrix are in the [paper](https://github.com/Caistro-Labs/poros/blob/main/paper/poros.pdf). Configurations that would break parity silently (block-major gradient accumulation with dropout) raise instead of degrading.
188
+
189
+ ## Limitations
190
+
191
+ - **Slower than resident training** — 1.6–4.3× per step, hardware-dependent. That is the trade.
192
+ - **Single GPU** in v0.1; multi-GPU is v0.2 work.
193
+ - **Dense architectures only** — fused-expert MoE is not NF4-quantizable.
194
+ - **LoRA-family adapters on a frozen base** — full fine-tuning is out of scope.
195
+ - **Host RAM** holds the streamed base: provision to the measured RSS peaks above.
196
+ - The 72B end-to-end process peak is ~30.5 GB today (a 32 GB card) — the training step itself needs 18.87 GB.
197
+
198
+ The complete list: [docs/limitations.md](https://github.com/Caistro-Labs/poros/blob/main/docs/limitations.md).
199
+
200
+ ## Docs
201
+
202
+ | | |
203
+ |---|---|
204
+ | [Quickstart](https://github.com/Caistro-Labs/poros/blob/main/docs/quickstart.md) | `prepare()`, `PorosTrainer`, exporting adapters |
205
+ | [API](https://github.com/Caistro-Labs/poros/blob/main/docs/api.md) | every public surface, typed |
206
+ | [Architecture support](https://github.com/Caistro-Labs/poros/blob/main/docs/architecture-support.md) | validated registry, `poros check`, adding families |
207
+ | [Consumer GPUs](https://github.com/Caistro-Labs/poros/blob/main/docs/consumer-gpus.md) | 3090/4090/5090 guidance |
208
+ | [Parity modes](https://github.com/Caistro-Labs/poros/blob/main/docs/parity-modes.md) | what 0.00e+00 covers, mode sweep |
209
+ | [Benchmarks](https://github.com/Caistro-Labs/poros/blob/main/docs/bench.md) | running the harness, HTML reports |
210
+ | [Validation artifacts](https://github.com/Caistro-Labs/poros/tree/main/docs/validation) | raw gate JSONL for every claim |
211
+
212
+ ## Citation
213
+
214
+ ```bibtex
215
+ @article{tigres2026poros,
216
+ title = {Poros: Bit-Exact Large-Model Fine-Tuning on Consumer GPUs},
217
+ author = {Tigres, Jeffrey},
218
+ journal = {arXiv preprint arXiv:ARXIV_ID},
219
+ year = {2026}
220
+ }
221
+ ```
222
+
223
+ ## License
224
+
225
+ [Apache-2.0](https://github.com/Caistro-Labs/poros/blob/main/LICENSE). Built by [Caistro Labs](https://caistrolabs.com).
@@ -0,0 +1,178 @@
1
+ <div align="center">
2
+
3
+ <img src="https://raw.githubusercontent.com/Caistro-Labs/poros/main/docs/assets/poros-banner-dark.png" alt="Poros — bit-exact fine-tuning on consumer GPUs" width="100%">
4
+
5
+ <a href="https://pypi.org/project/poros-train/"><img src="https://raw.githubusercontent.com/Caistro-Labs/poros/main/docs/assets/badge-pypi.png" height="28" alt="pypi v0.1.0"></a>&nbsp;<a href="https://github.com/Caistro-Labs/poros/blob/main/pyproject.toml"><img src="https://raw.githubusercontent.com/Caistro-Labs/poros/main/docs/assets/badge-python.png" height="28" alt="python 3.11+"></a>&nbsp;<a href="https://github.com/Caistro-Labs/poros/blob/main/LICENSE"><img src="https://raw.githubusercontent.com/Caistro-Labs/poros/main/docs/assets/badge-license.png" height="28" alt="license apache-2.0"></a>&nbsp;<a href="https://github.com/Caistro-Labs/poros/tree/main/docs/validation"><img src="https://raw.githubusercontent.com/Caistro-Labs/poros/main/docs/assets/badge-parity.png" height="28" alt="parity 0.00e+00"></a>
6
+
7
+ <br>
8
+
9
+ <a href="#install"><kbd>&nbsp;Install&nbsp;</kbd></a>&nbsp;
10
+ <a href="#quickstart"><kbd>&nbsp;Quickstart&nbsp;</kbd></a>&nbsp;
11
+ <a href="#benchmarks"><kbd>&nbsp;Benchmarks&nbsp;</kbd></a>&nbsp;
12
+ <a href="#supported-models"><kbd>&nbsp;Models&nbsp;</kbd></a>&nbsp;
13
+ <a href="#how-it-works"><kbd>&nbsp;How&nbsp;it&nbsp;works&nbsp;</kbd></a>&nbsp;
14
+ <a href="https://github.com/Caistro-Labs/poros/blob/main/docs/index.md"><kbd>&nbsp;Docs&nbsp;</kbd></a>&nbsp;
15
+ <a href="https://github.com/Caistro-Labs/poros/blob/main/paper/poros.pdf"><kbd>&nbsp;Paper&nbsp;</kbd></a>
16
+
17
+ </div>
18
+
19
+ ---
20
+
21
+ Poros streams the frozen base of a QLoRA fine-tune through the GPU one block at a time, so only the adapters and a single block are ever resident. The adapter it produces is bit-for-bit identical to a fully resident run, verified with `torch.equal` (not `allclose`): all four surfaces — loss, adapter weights, gradient norms, and optimizer state — are gated directly at 7B and 32B; at 72B, loss and weights are gated directly and the other two are inferred from the bit-identical weight trajectory.
22
+
23
+ - **32B trains in 11.61 GB** peak VRAM (44.88 GB resident) — inside a 16 GB budget
24
+ - **72B trains end-to-end on a single RTX 5090** — 18.13 GB training peak on the 5090 (18.87 GB canonical; 81.57 GB resident)
25
+ - **Parity is 0.00e+00, not "close"** — gated over 200-step and 1000-step runs, with dropout, gradient accumulation, and `torch.compile`
26
+ - **One line** on top of your existing PEFT script
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ pip install poros-train # CLI + config, no GPU needed
32
+ pip install "poros-train[ml]" # + torch, transformers, peft, bitsandbytes
33
+ pip install "poros-train[ml,bench]" # + benchmark harness
34
+ ```
35
+
36
+ Python 3.11+, PyTorch 2.10+, Transformers 5.5+, Linux with CUDA. The base install runs `poros --help`, `poros check`, and `poros doctor` on CPU-only machines.
37
+
38
+ ## Quickstart
39
+
40
+ Already have a Hugging Face + PEFT script? Add one line and keep your loop:
41
+
42
+ ```python
43
+ import poros
44
+
45
+ model = poros.prepare(model) # your loop, your config, untouched
46
+ trainer.train()
47
+ ```
48
+
49
+ ```text
50
+ Poros prepared model
51
+ model Qwen/Qwen2.5-7B
52
+ model_type qwen2
53
+ architecture certified
54
+ adapter lora (certified)
55
+ precision NF4
56
+ stack certified
57
+ block_size 4
58
+ guarantee official bitwise path (NF4, deterministic)
59
+ ```
60
+
61
+ `prepare()` never touches your training setup — learning rate, LoRA config, optimizer, and data stay exactly as you wrote them. It detects the architecture, wraps the model in place, and reports which guarantee applies. Paths not gated at 0.00e+00 are labeled `experimental` or `target`. Reverse it any time with `poros.unprepare(model)`.
62
+
63
+ No script yet? `PorosTrainer` is the five-line path:
64
+
65
+ ```python
66
+ from poros import PorosTrainer
67
+
68
+ trainer = PorosTrainer.from_pretrained(
69
+ "Qwen/Qwen2.5-32B", quantization="nf4", lora_rank=16, lora_alpha=32,
70
+ )
71
+ trainer.train("OpenAssistant/oasst1", steps=200, seq_len=512)
72
+ trainer.save("./poros-qwen32b-lora")
73
+ ```
74
+
75
+ The saved adapter is a standard PEFT adapter — load it with `PeftModel.from_pretrained`, or merge for vLLM/TGI with `poros export ./poros-qwen32b-lora -o ./merged`. See [examples/inference.py](https://github.com/Caistro-Labs/poros/blob/main/examples/inference.py).
76
+
77
+ If a block doesn't fit your card, `PorosOOMError` suggests a smaller `block_size` to try. Details: [docs/quickstart.md](https://github.com/Caistro-Labs/poros/blob/main/docs/quickstart.md) · [docs/api.md](https://github.com/Caistro-Labs/poros/blob/main/docs/api.md).
78
+
79
+ ## Benchmarks
80
+
81
+ Consumer cards, measured. Every row has a raw artifact in [docs/validation/](https://github.com/Caistro-Labs/poros/tree/main/docs/validation); the datacenter matrices (A100, B300, RTX PRO 6000) live in [docs/official-a100-results.md](https://github.com/Caistro-Labs/poros/blob/main/docs/official-a100-results.md) and [docs/official-b300-results.md](https://github.com/Caistro-Labs/poros/blob/main/docs/official-b300-results.md).
82
+
83
+ **RTX 3090 (24 GB)** — Qwen2.5 QLoRA, all methods on identical data, seeds, and deterministic kernels (rank-16 LoRA, NF4, seq_len 512, 200 steps):
84
+
85
+ | Scale | Method | Peak VRAM | s/step |
86
+ |---|---|---|---|
87
+ | 7B | PEFT QLoRA | 16.37 GB | 0.51 |
88
+ | 7B | Accelerate CPU-offload | 9.71 GB | 0.73 |
89
+ | 7B | Unsloth QLoRA | 8.66 GB | 0.53 |
90
+ | 7B | **Poros** | **6.90 GB** | 0.87 |
91
+ | 32B | PEFT QLoRA | OOM | — |
92
+ | 32B | Accelerate CPU-offload | OOM | — |
93
+ | 32B | Unsloth QLoRA¹ | 22.29 GB | 2.07 |
94
+ | 32B | **Poros** | **11.61 GB** | 3.21 |
95
+
96
+ ¹ Unsloth at 32B fits only with its own `use_gradient_checkpointing="unsloth"` mode; without it, it OOMs at ~23 GB. Final losses match to ≤4×10⁻⁴ across methods (kernel dispatch); Poros is bit-identical to its resident reference on the primary platform.
97
+
98
+ **RTX 5090 (32 GB)** — official validation runs (PyTorch 2.11.0+cu128):
99
+
100
+ | Run | Steps | Peak VRAM | Result |
101
+ |---|---|---|---|
102
+ | Qwen2.5-32B, synthetic | 50 | **11.02 GB** | loss tracks the A100 trajectory to ~2×10⁻⁴ |
103
+ | Qwen2.5-32B, real data (oasst1) | 100 | **11.02 GB** | padding-masked CE, same 11.02 GB envelope |
104
+ | Qwen2.5-72B, end-to-end | 10 | **18.13 GB** train · 30.57 GB process peak | streamed load + training on one card; loss matches the PRO 6000 run to ~1×10⁻⁵ |
105
+
106
+ The 72B process peak is the startup self-check probe, not the loader — the streamed loader's own ceiling is 1.63 GB at 72B. The 5090 runs use the instrumented single-pass validation protocol, so step-time comparisons belong in the 3090 table above.
107
+
108
+ The cost, on consumer hardware: 0.87 vs 0.51 s/step at 7B on the 3090 (about 1.7×). At 32B and 72B there is no resident consumer baseline to be slower than — it OOMs. If your model fits comfortably resident, run it resident.
109
+
110
+ The streamed NF4 loader (default) keeps host RAM at 12.1 / 34.7 / 48.2 GB RSS for 7B / 32B / 72B (standard path: 15.3 / 62.0 / 136.5 GB).
111
+
112
+ Reproduce any row with the shipped configs, e.g. `poros bench run configs/bench/official_a100_qwen25_32b.yaml`. Consumer guidance: [docs/consumer-gpus.md](https://github.com/Caistro-Labs/poros/blob/main/docs/consumer-gpus.md).
113
+
114
+ ## Supported models
115
+
116
+ Every validated family is gated at exactly 0.00e+00 on real hardware — byte-identical load plus bitwise training parity. The four surfaces (loss, adapter weights, gradient norms, optimizer state) are gated directly at 7B and 32B; at 72B, loss and weights are gated directly and the other two are inferred from the bit-identical weights.
117
+
118
+ | Family | `model_type` | Coverage |
119
+ |---|---|---|
120
+ | Qwen2.5 | `qwen2` | 0.5B–72B, incl. DeepSeek-R1-Distill-Qwen |
121
+ | Qwen3 | `qwen3` | 32B |
122
+ | Qwen3.5 / Qwen3.6 dense | `qwen3_5` | 0.8B–27B |
123
+ | Gemma 3 | `gemma3` | 27B |
124
+ | Gemma 4 | `gemma4` | 31B |
125
+
126
+ Check any model without downloading it:
127
+
128
+ ```bash
129
+ poros check Qwen/Qwen3.5-27B # resolves model_type + status, no torch needed
130
+ ```
131
+
132
+ Unvalidated architectures fail loudly instead of training with an unverified guarantee. MoE models with fused expert layers (Qwen3-MoE, GLM-4.5+, gpt-oss) are not NF4-quantizable and are out of scope. Roadmap and the registry mechanism: [docs/architecture-support.md](https://github.com/Caistro-Labs/poros/blob/main/docs/architecture-support.md).
133
+
134
+ ## How it works
135
+
136
+ A frozen base receives no gradients — it sits in VRAM only because the forward pass reads it. Poros bounds residency to one block plus prefetch in both directions: the forward streams blocks through a small GPU window, the backward reloads each block and recomputes its forward before differentiating adapters and block inputs.
137
+
138
+ Exactness comes from RNG capture. Recomputing a block would normally redraw its dropout masks and silently change the gradients; Poros snapshots CPU and CUDA RNG state before each block's forward and restores it inside `torch.random.fork_rng` during recomputation, so the backward runs on the identical graph. Nothing about the learning problem changes — same kernels, same optimizer, same data order.
139
+
140
+ The formal statement and full audit matrix are in the [paper](https://github.com/Caistro-Labs/poros/blob/main/paper/poros.pdf). Configurations that would break parity silently (block-major gradient accumulation with dropout) raise instead of degrading.
141
+
142
+ ## Limitations
143
+
144
+ - **Slower than resident training** — 1.6–4.3× per step, hardware-dependent. That is the trade.
145
+ - **Single GPU** in v0.1; multi-GPU is v0.2 work.
146
+ - **Dense architectures only** — fused-expert MoE is not NF4-quantizable.
147
+ - **LoRA-family adapters on a frozen base** — full fine-tuning is out of scope.
148
+ - **Host RAM** holds the streamed base: provision to the measured RSS peaks above.
149
+ - The 72B end-to-end process peak is ~30.5 GB today (a 32 GB card) — the training step itself needs 18.87 GB.
150
+
151
+ The complete list: [docs/limitations.md](https://github.com/Caistro-Labs/poros/blob/main/docs/limitations.md).
152
+
153
+ ## Docs
154
+
155
+ | | |
156
+ |---|---|
157
+ | [Quickstart](https://github.com/Caistro-Labs/poros/blob/main/docs/quickstart.md) | `prepare()`, `PorosTrainer`, exporting adapters |
158
+ | [API](https://github.com/Caistro-Labs/poros/blob/main/docs/api.md) | every public surface, typed |
159
+ | [Architecture support](https://github.com/Caistro-Labs/poros/blob/main/docs/architecture-support.md) | validated registry, `poros check`, adding families |
160
+ | [Consumer GPUs](https://github.com/Caistro-Labs/poros/blob/main/docs/consumer-gpus.md) | 3090/4090/5090 guidance |
161
+ | [Parity modes](https://github.com/Caistro-Labs/poros/blob/main/docs/parity-modes.md) | what 0.00e+00 covers, mode sweep |
162
+ | [Benchmarks](https://github.com/Caistro-Labs/poros/blob/main/docs/bench.md) | running the harness, HTML reports |
163
+ | [Validation artifacts](https://github.com/Caistro-Labs/poros/tree/main/docs/validation) | raw gate JSONL for every claim |
164
+
165
+ ## Citation
166
+
167
+ ```bibtex
168
+ @article{tigres2026poros,
169
+ title = {Poros: Bit-Exact Large-Model Fine-Tuning on Consumer GPUs},
170
+ author = {Tigres, Jeffrey},
171
+ journal = {arXiv preprint arXiv:ARXIV_ID},
172
+ year = {2026}
173
+ }
174
+ ```
175
+
176
+ ## License
177
+
178
+ [Apache-2.0](https://github.com/Caistro-Labs/poros/blob/main/LICENSE). Built by [Caistro Labs](https://caistrolabs.com).