USN 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 (91) hide show
  1. usn-0.1.0/CHANGELOG.md +24 -0
  2. usn-0.1.0/LICENSE +21 -0
  3. usn-0.1.0/MANIFEST.in +6 -0
  4. usn-0.1.0/PKG-INFO +96 -0
  5. usn-0.1.0/README.md +55 -0
  6. usn-0.1.0/USN.egg-info/PKG-INFO +96 -0
  7. usn-0.1.0/USN.egg-info/SOURCES.txt +89 -0
  8. usn-0.1.0/USN.egg-info/dependency_links.txt +1 -0
  9. usn-0.1.0/USN.egg-info/entry_points.txt +2 -0
  10. usn-0.1.0/USN.egg-info/requires.txt +23 -0
  11. usn-0.1.0/USN.egg-info/top_level.txt +1 -0
  12. usn-0.1.0/docs/DOCUMENTATION.md +630 -0
  13. usn-0.1.0/examples/quick_start.py +120 -0
  14. usn-0.1.0/pyproject.toml +89 -0
  15. usn-0.1.0/setup.cfg +4 -0
  16. usn-0.1.0/setup.py +5 -0
  17. usn-0.1.0/tests/test_backends.py +175 -0
  18. usn-0.1.0/tests/test_beam_search_repetition.py +376 -0
  19. usn-0.1.0/tests/test_generator_streaming.py +227 -0
  20. usn-0.1.0/tests/test_optim_factory.py +191 -0
  21. usn-0.1.0/tests/test_trainer_eval_checkpoint.py +356 -0
  22. usn-0.1.0/usn/__init__.py +145 -0
  23. usn-0.1.0/usn/__init__.pyi +39 -0
  24. usn-0.1.0/usn/backends/__init__.py +25 -0
  25. usn-0.1.0/usn/backends/acceleration.py +236 -0
  26. usn-0.1.0/usn/backends/detection.py +92 -0
  27. usn-0.1.0/usn/backends/fallbacks.py +102 -0
  28. usn-0.1.0/usn/backends/triton_kernels.py +421 -0
  29. usn-0.1.0/usn/cli/__init__.py +5 -0
  30. usn-0.1.0/usn/cli/main.py +212 -0
  31. usn-0.1.0/usn/config/__init__.py +11 -0
  32. usn-0.1.0/usn/config/generation_config.py +53 -0
  33. usn-0.1.0/usn/config/model_config.py +296 -0
  34. usn-0.1.0/usn/config/training_config.py +106 -0
  35. usn-0.1.0/usn/core/__init__.py +31 -0
  36. usn-0.1.0/usn/core/activations.py +94 -0
  37. usn-0.1.0/usn/core/base.py +52 -0
  38. usn-0.1.0/usn/core/interfaces.py +94 -0
  39. usn-0.1.0/usn/core/types.py +83 -0
  40. usn-0.1.0/usn/datasets/__init__.py +7 -0
  41. usn-0.1.0/usn/datasets/collate.py +48 -0
  42. usn-0.1.0/usn/datasets/math_dataset.py +102 -0
  43. usn-0.1.0/usn/datasets/usn_dataset.py +145 -0
  44. usn-0.1.0/usn/exceptions.py +131 -0
  45. usn-0.1.0/usn/inference/__init__.py +5 -0
  46. usn-0.1.0/usn/inference/generator.py +587 -0
  47. usn-0.1.0/usn/layers/__init__.py +28 -0
  48. usn-0.1.0/usn/layers/block.py +224 -0
  49. usn-0.1.0/usn/layers/chunked_scan.py +133 -0
  50. usn-0.1.0/usn/layers/norm.py +98 -0
  51. usn-0.1.0/usn/layers/parallel_scan.py +147 -0
  52. usn-0.1.0/usn/losses/__init__.py +5 -0
  53. usn-0.1.0/usn/losses/cross_entropy.py +72 -0
  54. usn-0.1.0/usn/models/__init__.py +87 -0
  55. usn-0.1.0/usn/models/embedding.py +124 -0
  56. usn-0.1.0/usn/models/usn_model.py +253 -0
  57. usn-0.1.0/usn/modules/__init__.py +31 -0
  58. usn-0.1.0/usn/modules/channel_mixing.py +84 -0
  59. usn-0.1.0/usn/modules/exponential_gating.py +111 -0
  60. usn-0.1.0/usn/modules/input_projection.py +66 -0
  61. usn-0.1.0/usn/modules/selective_writing.py +146 -0
  62. usn-0.1.0/usn/modules/state_readout.py +107 -0
  63. usn-0.1.0/usn/modules/state_update.py +211 -0
  64. usn-0.1.0/usn/modules/temporal_mixing.py +100 -0
  65. usn-0.1.0/usn/optim/__init__.py +21 -0
  66. usn-0.1.0/usn/optim/factory.py +154 -0
  67. usn-0.1.0/usn/optim/schedulers.py +254 -0
  68. usn-0.1.0/usn/py.typed +0 -0
  69. usn-0.1.0/usn/serialization/__init__.py +33 -0
  70. usn-0.1.0/usn/serialization/export.py +126 -0
  71. usn-0.1.0/usn/serialization/format_spec.py +129 -0
  72. usn-0.1.0/usn/serialization/migration.py +145 -0
  73. usn-0.1.0/usn/serialization/reader.py +461 -0
  74. usn-0.1.0/usn/serialization/validator.py +187 -0
  75. usn-0.1.0/usn/serialization/writer.py +405 -0
  76. usn-0.1.0/usn/tokenizers/__init__.py +14 -0
  77. usn-0.1.0/usn/tokenizers/bpe_tokenizer.py +241 -0
  78. usn-0.1.0/usn/tokenizers/char_tokenizer.py +150 -0
  79. usn-0.1.0/usn/tokenizers/word_tokenizer.py +158 -0
  80. usn-0.1.0/usn/training/__init__.py +7 -0
  81. usn-0.1.0/usn/training/curriculum.py +91 -0
  82. usn-0.1.0/usn/training/distributed.py +99 -0
  83. usn-0.1.0/usn/training/stability.py +113 -0
  84. usn-0.1.0/usn/training/trainer.py +566 -0
  85. usn-0.1.0/usn/utils/__init__.py +52 -0
  86. usn-0.1.0/usn/utils/counting.py +206 -0
  87. usn-0.1.0/usn/utils/diagnostics.py +373 -0
  88. usn-0.1.0/usn/utils/profiling.py +249 -0
  89. usn-0.1.0/usn/utils/seed.py +60 -0
  90. usn-0.1.0/usn/utils/timing.py +144 -0
  91. usn-0.1.0/usn/utils/visualization.py +207 -0
usn-0.1.0/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2024-01-01
9
+
10
+ ### Added
11
+
12
+ - Initial project structure and packaging
13
+ - Core type definitions (UnifiedState, ModelState, BlockOutput, etc.)
14
+ - USN modules: InputProjection, TemporalMixing, ExponentialGating, SelectiveWriting, StateUpdate, StateReadout, ChannelMixing
15
+ - USNBlock layer with pre-norm residual architecture
16
+ - Parallel scan and chunked parallel scan implementations
17
+ - USNModel with embedding, blocks, and output head
18
+ - Configuration system with presets (tiny through xxl)
19
+ - Training system with mixed precision, curriculum, and distributed support
20
+ - Inference system with greedy, top-k, top-p, and beam search decoding
21
+ - `.usn` single-file serialization format
22
+ - Triton fused kernels with PyTorch fallbacks
23
+ - CLI interface (train, generate, benchmark, info, export, validate)
24
+ - Comprehensive test suite with property-based tests
usn-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BUEORM
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
usn-0.1.0/MANIFEST.in ADDED
@@ -0,0 +1,6 @@
1
+ include LICENSE
2
+ include README.md
3
+ include CHANGELOG.md
4
+ recursive-include docs *
5
+ recursive-include examples *
6
+ recursive-include usn py.typed *.pyi
usn-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.4
2
+ Name: USN
3
+ Version: 0.1.0
4
+ Summary: Unified State Network (USN) Architecture Library - A production-grade autoregressive sequence modeling architecture with O(n) training and O(1) inference.
5
+ Author: BUEORM
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/BUEORM/USN
8
+ Project-URL: Documentation, https://github.com/BUEORM/USN/docs
9
+ Project-URL: Repository, https://github.com/BUEORM/USN
10
+ Keywords: deep-learning,sequence-modeling,state-space,autoregressive,parallel-scan
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: torch>=2.0.0
22
+ Requires-Dist: numpy>=1.24.0
23
+ Requires-Dist: tokenizers>=0.15.0
24
+ Requires-Dist: pyyaml>=6.0
25
+ Requires-Dist: tqdm>=4.60.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0; extra == "dev"
28
+ Requires-Dist: pytest-cov; extra == "dev"
29
+ Requires-Dist: mypy; extra == "dev"
30
+ Requires-Dist: ruff; extra == "dev"
31
+ Requires-Dist: pre-commit; extra == "dev"
32
+ Requires-Dist: hypothesis>=6.0; extra == "dev"
33
+ Provides-Extra: docs
34
+ Requires-Dist: sphinx; extra == "docs"
35
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
36
+ Provides-Extra: cuda
37
+ Requires-Dist: triton>=2.1.0; extra == "cuda"
38
+ Provides-Extra: all
39
+ Requires-Dist: USN[cuda,dev,docs]; extra == "all"
40
+ Dynamic: license-file
41
+
42
+ # USN - Unified State Network Architecture Library
43
+
44
+ A production-grade Python package implementing the Unified State Network (USN) architecture for autoregressive sequence modeling.
45
+
46
+ USN replaces attention mechanisms with a unified persistent state partitioned into semantic (vector) and relational (matrix) subspaces, achieving **O(n) training complexity** via associative parallel scan and **O(1) inference memory** via constant-size state.
47
+
48
+ ## Features
49
+
50
+ - Novel state-space architecture with no attention mechanism
51
+ - O(n) training via parallel associative scan
52
+ - O(1) inference memory via constant-size persistent state
53
+ - 4-level acceleration hierarchy (Triton → torch.compile → custom autograd → eager)
54
+ - Single-file `.usn` serialization format
55
+ - CLI interface for training, generation, and benchmarking
56
+
57
+ ## Installation
58
+
59
+ ```bash
60
+ pip install USN
61
+ ```
62
+
63
+ For development:
64
+
65
+ ```bash
66
+ pip install USN[dev]
67
+ ```
68
+
69
+ For CUDA acceleration:
70
+
71
+ ```bash
72
+ pip install USN[cuda]
73
+ ```
74
+
75
+ For all optional dependencies:
76
+
77
+ ```bash
78
+ pip install USN[all]
79
+ ```
80
+
81
+ ## Quick Start
82
+
83
+ ```python
84
+ import usn
85
+
86
+ # Create a model from a preset configuration
87
+ config = usn.USNConfig.tiny()
88
+ model = usn.create_model(config)
89
+
90
+ # Print model summary
91
+ print(model.summary())
92
+ ```
93
+
94
+ ## License
95
+
96
+ MIT License - Copyright (c) 2024 BUEORM
usn-0.1.0/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # USN - Unified State Network Architecture Library
2
+
3
+ A production-grade Python package implementing the Unified State Network (USN) architecture for autoregressive sequence modeling.
4
+
5
+ USN replaces attention mechanisms with a unified persistent state partitioned into semantic (vector) and relational (matrix) subspaces, achieving **O(n) training complexity** via associative parallel scan and **O(1) inference memory** via constant-size state.
6
+
7
+ ## Features
8
+
9
+ - Novel state-space architecture with no attention mechanism
10
+ - O(n) training via parallel associative scan
11
+ - O(1) inference memory via constant-size persistent state
12
+ - 4-level acceleration hierarchy (Triton → torch.compile → custom autograd → eager)
13
+ - Single-file `.usn` serialization format
14
+ - CLI interface for training, generation, and benchmarking
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install USN
20
+ ```
21
+
22
+ For development:
23
+
24
+ ```bash
25
+ pip install USN[dev]
26
+ ```
27
+
28
+ For CUDA acceleration:
29
+
30
+ ```bash
31
+ pip install USN[cuda]
32
+ ```
33
+
34
+ For all optional dependencies:
35
+
36
+ ```bash
37
+ pip install USN[all]
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ```python
43
+ import usn
44
+
45
+ # Create a model from a preset configuration
46
+ config = usn.USNConfig.tiny()
47
+ model = usn.create_model(config)
48
+
49
+ # Print model summary
50
+ print(model.summary())
51
+ ```
52
+
53
+ ## License
54
+
55
+ MIT License - Copyright (c) 2024 BUEORM
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.4
2
+ Name: USN
3
+ Version: 0.1.0
4
+ Summary: Unified State Network (USN) Architecture Library - A production-grade autoregressive sequence modeling architecture with O(n) training and O(1) inference.
5
+ Author: BUEORM
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/BUEORM/USN
8
+ Project-URL: Documentation, https://github.com/BUEORM/USN/docs
9
+ Project-URL: Repository, https://github.com/BUEORM/USN
10
+ Keywords: deep-learning,sequence-modeling,state-space,autoregressive,parallel-scan
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: torch>=2.0.0
22
+ Requires-Dist: numpy>=1.24.0
23
+ Requires-Dist: tokenizers>=0.15.0
24
+ Requires-Dist: pyyaml>=6.0
25
+ Requires-Dist: tqdm>=4.60.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0; extra == "dev"
28
+ Requires-Dist: pytest-cov; extra == "dev"
29
+ Requires-Dist: mypy; extra == "dev"
30
+ Requires-Dist: ruff; extra == "dev"
31
+ Requires-Dist: pre-commit; extra == "dev"
32
+ Requires-Dist: hypothesis>=6.0; extra == "dev"
33
+ Provides-Extra: docs
34
+ Requires-Dist: sphinx; extra == "docs"
35
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
36
+ Provides-Extra: cuda
37
+ Requires-Dist: triton>=2.1.0; extra == "cuda"
38
+ Provides-Extra: all
39
+ Requires-Dist: USN[cuda,dev,docs]; extra == "all"
40
+ Dynamic: license-file
41
+
42
+ # USN - Unified State Network Architecture Library
43
+
44
+ A production-grade Python package implementing the Unified State Network (USN) architecture for autoregressive sequence modeling.
45
+
46
+ USN replaces attention mechanisms with a unified persistent state partitioned into semantic (vector) and relational (matrix) subspaces, achieving **O(n) training complexity** via associative parallel scan and **O(1) inference memory** via constant-size state.
47
+
48
+ ## Features
49
+
50
+ - Novel state-space architecture with no attention mechanism
51
+ - O(n) training via parallel associative scan
52
+ - O(1) inference memory via constant-size persistent state
53
+ - 4-level acceleration hierarchy (Triton → torch.compile → custom autograd → eager)
54
+ - Single-file `.usn` serialization format
55
+ - CLI interface for training, generation, and benchmarking
56
+
57
+ ## Installation
58
+
59
+ ```bash
60
+ pip install USN
61
+ ```
62
+
63
+ For development:
64
+
65
+ ```bash
66
+ pip install USN[dev]
67
+ ```
68
+
69
+ For CUDA acceleration:
70
+
71
+ ```bash
72
+ pip install USN[cuda]
73
+ ```
74
+
75
+ For all optional dependencies:
76
+
77
+ ```bash
78
+ pip install USN[all]
79
+ ```
80
+
81
+ ## Quick Start
82
+
83
+ ```python
84
+ import usn
85
+
86
+ # Create a model from a preset configuration
87
+ config = usn.USNConfig.tiny()
88
+ model = usn.create_model(config)
89
+
90
+ # Print model summary
91
+ print(model.summary())
92
+ ```
93
+
94
+ ## License
95
+
96
+ MIT License - Copyright (c) 2024 BUEORM
@@ -0,0 +1,89 @@
1
+ CHANGELOG.md
2
+ LICENSE
3
+ MANIFEST.in
4
+ README.md
5
+ pyproject.toml
6
+ setup.py
7
+ USN.egg-info/PKG-INFO
8
+ USN.egg-info/SOURCES.txt
9
+ USN.egg-info/dependency_links.txt
10
+ USN.egg-info/entry_points.txt
11
+ USN.egg-info/requires.txt
12
+ USN.egg-info/top_level.txt
13
+ docs/DOCUMENTATION.md
14
+ examples/quick_start.py
15
+ tests/test_backends.py
16
+ tests/test_beam_search_repetition.py
17
+ tests/test_generator_streaming.py
18
+ tests/test_optim_factory.py
19
+ tests/test_trainer_eval_checkpoint.py
20
+ usn/__init__.py
21
+ usn/__init__.pyi
22
+ usn/exceptions.py
23
+ usn/py.typed
24
+ usn/backends/__init__.py
25
+ usn/backends/acceleration.py
26
+ usn/backends/detection.py
27
+ usn/backends/fallbacks.py
28
+ usn/backends/triton_kernels.py
29
+ usn/cli/__init__.py
30
+ usn/cli/main.py
31
+ usn/config/__init__.py
32
+ usn/config/generation_config.py
33
+ usn/config/model_config.py
34
+ usn/config/training_config.py
35
+ usn/core/__init__.py
36
+ usn/core/activations.py
37
+ usn/core/base.py
38
+ usn/core/interfaces.py
39
+ usn/core/types.py
40
+ usn/datasets/__init__.py
41
+ usn/datasets/collate.py
42
+ usn/datasets/math_dataset.py
43
+ usn/datasets/usn_dataset.py
44
+ usn/inference/__init__.py
45
+ usn/inference/generator.py
46
+ usn/layers/__init__.py
47
+ usn/layers/block.py
48
+ usn/layers/chunked_scan.py
49
+ usn/layers/norm.py
50
+ usn/layers/parallel_scan.py
51
+ usn/losses/__init__.py
52
+ usn/losses/cross_entropy.py
53
+ usn/models/__init__.py
54
+ usn/models/embedding.py
55
+ usn/models/usn_model.py
56
+ usn/modules/__init__.py
57
+ usn/modules/channel_mixing.py
58
+ usn/modules/exponential_gating.py
59
+ usn/modules/input_projection.py
60
+ usn/modules/selective_writing.py
61
+ usn/modules/state_readout.py
62
+ usn/modules/state_update.py
63
+ usn/modules/temporal_mixing.py
64
+ usn/optim/__init__.py
65
+ usn/optim/factory.py
66
+ usn/optim/schedulers.py
67
+ usn/serialization/__init__.py
68
+ usn/serialization/export.py
69
+ usn/serialization/format_spec.py
70
+ usn/serialization/migration.py
71
+ usn/serialization/reader.py
72
+ usn/serialization/validator.py
73
+ usn/serialization/writer.py
74
+ usn/tokenizers/__init__.py
75
+ usn/tokenizers/bpe_tokenizer.py
76
+ usn/tokenizers/char_tokenizer.py
77
+ usn/tokenizers/word_tokenizer.py
78
+ usn/training/__init__.py
79
+ usn/training/curriculum.py
80
+ usn/training/distributed.py
81
+ usn/training/stability.py
82
+ usn/training/trainer.py
83
+ usn/utils/__init__.py
84
+ usn/utils/counting.py
85
+ usn/utils/diagnostics.py
86
+ usn/utils/profiling.py
87
+ usn/utils/seed.py
88
+ usn/utils/timing.py
89
+ usn/utils/visualization.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ usn = usn.cli.main:cli
@@ -0,0 +1,23 @@
1
+ torch>=2.0.0
2
+ numpy>=1.24.0
3
+ tokenizers>=0.15.0
4
+ pyyaml>=6.0
5
+ tqdm>=4.60.0
6
+
7
+ [all]
8
+ USN[cuda,dev,docs]
9
+
10
+ [cuda]
11
+ triton>=2.1.0
12
+
13
+ [dev]
14
+ pytest>=7.0
15
+ pytest-cov
16
+ mypy
17
+ ruff
18
+ pre-commit
19
+ hypothesis>=6.0
20
+
21
+ [docs]
22
+ sphinx
23
+ sphinx-rtd-theme
@@ -0,0 +1 @@
1
+ usn