neuratensor 1.0.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.
- neuratensor-1.0.0/LICENSE +17 -0
- neuratensor-1.0.0/MANIFEST.in +33 -0
- neuratensor-1.0.0/PATENT_NOTICE.txt +38 -0
- neuratensor-1.0.0/PKG-INFO +91 -0
- neuratensor-1.0.0/README.md +55 -0
- neuratensor-1.0.0/lib/neuratensor_core.sha256 +1 -0
- neuratensor-1.0.0/lib/neuratensor_core.so +0 -0
- neuratensor-1.0.0/neuratensor.egg-info/PKG-INFO +91 -0
- neuratensor-1.0.0/neuratensor.egg-info/SOURCES.txt +29 -0
- neuratensor-1.0.0/neuratensor.egg-info/dependency_links.txt +1 -0
- neuratensor-1.0.0/neuratensor.egg-info/entry_points.txt +2 -0
- neuratensor-1.0.0/neuratensor.egg-info/not-zip-safe +1 -0
- neuratensor-1.0.0/neuratensor.egg-info/requires.txt +10 -0
- neuratensor-1.0.0/neuratensor.egg-info/top_level.txt +1 -0
- neuratensor-1.0.0/sdk/__init__.py +116 -0
- neuratensor-1.0.0/sdk/backends.py +228 -0
- neuratensor-1.0.0/sdk/cli.py +247 -0
- neuratensor-1.0.0/sdk/config.py +224 -0
- neuratensor-1.0.0/sdk/demo_sdk_public.py +94 -0
- neuratensor-1.0.0/sdk/examples.py +213 -0
- neuratensor-1.0.0/sdk/inference.py +322 -0
- neuratensor-1.0.0/sdk/model_loader.py +179 -0
- neuratensor-1.0.0/sdk/secure_runtime.py +98 -0
- neuratensor-1.0.0/sdk/setup.py +61 -0
- neuratensor-1.0.0/sdk/tests/__init__.py +6 -0
- neuratensor-1.0.0/sdk/tests/test_inference.py +90 -0
- neuratensor-1.0.0/sdk/tests/test_model_loader.py +61 -0
- neuratensor-1.0.0/setup.cfg +4 -0
- neuratensor-1.0.0/setup.py +103 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Proprietary License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 Neuramorphic, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are provided
|
|
6
|
+
under a proprietary license. The Software includes compiled binary components
|
|
7
|
+
that are protected by patent-pending technology.
|
|
8
|
+
|
|
9
|
+
RESTRICTIONS:
|
|
10
|
+
1. You may use the Software for evaluation and non-commercial purposes.
|
|
11
|
+
2. Commercial use requires a separate license agreement.
|
|
12
|
+
3. Reverse engineering, decompilation, or disassembly is strictly prohibited.
|
|
13
|
+
4. You may not redistribute or sublicense the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
|
16
|
+
|
|
17
|
+
For licensing inquiries: licensing@neuramorphic.ai
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# NeuraTensor SDK - Distribution Manifest
|
|
2
|
+
# Specifies which files to include in PyPI package
|
|
3
|
+
|
|
4
|
+
# Include binary library
|
|
5
|
+
include lib/*.so
|
|
6
|
+
include lib/*.sha256
|
|
7
|
+
|
|
8
|
+
# Include configuration and metadata
|
|
9
|
+
include LICENSE
|
|
10
|
+
include README.md
|
|
11
|
+
include PATENT_NOTICE.txt
|
|
12
|
+
include pyproject.toml
|
|
13
|
+
|
|
14
|
+
# Include SDK Python files (sdk/ becomes neuratensor/ in package)
|
|
15
|
+
recursive-include sdk *.py
|
|
16
|
+
|
|
17
|
+
# Exclude development and internal files
|
|
18
|
+
exclude build_secure_core.py
|
|
19
|
+
exclude test_*.py
|
|
20
|
+
exclude *.sh
|
|
21
|
+
|
|
22
|
+
# Exclude proprietary source code
|
|
23
|
+
recursive-exclude core *
|
|
24
|
+
recursive-exclude config *
|
|
25
|
+
recursive-exclude kernels *.cu
|
|
26
|
+
recursive-exclude build_secure *
|
|
27
|
+
recursive-exclude __pycache__ *
|
|
28
|
+
recursive-exclude *.pyc
|
|
29
|
+
|
|
30
|
+
# Exclude docs and examples (distributed separately)
|
|
31
|
+
recursive-exclude docs *
|
|
32
|
+
recursive-exclude examples *
|
|
33
|
+
exclude DISTRIBUTION_GUIDE.md
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
PATENT NOTICE
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
NeuraTensor™ Fused SNN-SSM Architecture
|
|
5
|
+
Copyright © 2024-2025 Neuramorphic, Inc.
|
|
6
|
+
All rights reserved.
|
|
7
|
+
|
|
8
|
+
PATENT PENDING
|
|
9
|
+
|
|
10
|
+
This software contains proprietary algorithms and implementations related to:
|
|
11
|
+
|
|
12
|
+
1. Fused Spiking Neural Network (SNN) and State Space Model (SSM) architecture
|
|
13
|
+
2. Single-pass CUDA kernel implementation for hybrid neuromorphic inference
|
|
14
|
+
3. Hardware-accelerated neuromorphic computing on NVIDIA GPU architectures
|
|
15
|
+
4. Novel spike-driven state space computation methods
|
|
16
|
+
|
|
17
|
+
Patent applications have been filed covering the core algorithms, architecture,
|
|
18
|
+
and implementation methods contained in this software.
|
|
19
|
+
|
|
20
|
+
The compiled binary (neuratensor_core.so) is provided under a limited use license.
|
|
21
|
+
Reverse engineering, decompilation, or disassembly is strictly prohibited.
|
|
22
|
+
|
|
23
|
+
TRADEMARK
|
|
24
|
+
|
|
25
|
+
NeuraTensor™ is a trademark of Neuramorphic, Inc.
|
|
26
|
+
|
|
27
|
+
LICENSING
|
|
28
|
+
|
|
29
|
+
For commercial licensing inquiries, custom implementations, or OEM partnerships,
|
|
30
|
+
please contact:
|
|
31
|
+
|
|
32
|
+
Neuramorphic, Inc.
|
|
33
|
+
licensing@neuramorphic.ai
|
|
34
|
+
San Francisco, CA
|
|
35
|
+
|
|
36
|
+
For source code licensing or patent licensing inquiries:
|
|
37
|
+
|
|
38
|
+
ip@neuramorphic.ai
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: neuratensor
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Production neuromorphic inference SDK with CUDA acceleration
|
|
5
|
+
Home-page: https://neuramorphic.ai
|
|
6
|
+
Author: Neuramorphic, Inc.
|
|
7
|
+
Author-email: info@neuramorphic.ai
|
|
8
|
+
License: Proprietary
|
|
9
|
+
Project-URL: Documentation, https://docs.neuramorphic.ai
|
|
10
|
+
Project-URL: Source, https://github.com/neuramorphic/neuratensor-sdk
|
|
11
|
+
Project-URL: Bug Reports, https://github.com/neuramorphic/neuratensor-sdk/issues
|
|
12
|
+
Keywords: neuromorphic,snn,ssm,cuda,inference,deep-learning,ai
|
|
13
|
+
Platform: Linux
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Classifier: License :: Other/Proprietary License
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
24
|
+
Classifier: Environment :: GPU :: NVIDIA CUDA
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: torch>=2.0.0
|
|
29
|
+
Requires-Dist: numpy>=1.19.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: flake8>=4.0.0; extra == "dev"
|
|
34
|
+
Provides-Extra: cli
|
|
35
|
+
Requires-Dist: click>=8.0.0; extra == "cli"
|
|
36
|
+
|
|
37
|
+
# NeuraTensor SDK
|
|
38
|
+
|
|
39
|
+
**Production neuromorphic inference at 8ms latency**
|
|
40
|
+
|
|
41
|
+
NeuraTensor is a high-performance neuromorphic inference SDK featuring a proprietary fused SNN-SSM architecture with CUDA acceleration.
|
|
42
|
+
|
|
43
|
+
## ⚡ Performance
|
|
44
|
+
|
|
45
|
+
- **8.13ms latency** (64M model, Jetson AGX Orin)
|
|
46
|
+
- **123 seq/s throughput**
|
|
47
|
+
- **120x faster** than PyTorch baseline
|
|
48
|
+
- Sub-10ms real-time inference
|
|
49
|
+
|
|
50
|
+
## �� Quick Start
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install neuratensor
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from neuratensor import NeuraTensor, NeuraTensorConfig
|
|
58
|
+
|
|
59
|
+
# Load model
|
|
60
|
+
config = NeuraTensorConfig.preset("64m")
|
|
61
|
+
model = NeuraTensor(config).cuda().half()
|
|
62
|
+
|
|
63
|
+
# Inference
|
|
64
|
+
output = model(input_ids)
|
|
65
|
+
# ✅ 8ms latency, 64M params, 123 seq/s
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 📊 Models
|
|
69
|
+
|
|
70
|
+
| Model | Parameters | Latency | Use Case |
|
|
71
|
+
|-------|-----------|---------|----------|
|
|
72
|
+
| 64M | 64M | 8ms | Edge, real-time |
|
|
73
|
+
| 256M | 256M | ~15ms | Balanced |
|
|
74
|
+
| 1B | 1B | ~35ms | Quality |
|
|
75
|
+
|
|
76
|
+
## 🔧 Requirements
|
|
77
|
+
|
|
78
|
+
- NVIDIA GPU (CUDA 11.4+, SM 7.0+)
|
|
79
|
+
- Python 3.8+
|
|
80
|
+
- PyTorch 2.0+
|
|
81
|
+
|
|
82
|
+
## 📚 Documentation
|
|
83
|
+
|
|
84
|
+
- [Distribution Guide](DISTRIBUTION_GUIDE.md)
|
|
85
|
+
- [Patent Notice](PATENT_NOTICE.txt)
|
|
86
|
+
|
|
87
|
+
## 📄 License
|
|
88
|
+
|
|
89
|
+
Proprietary. Binary distribution only.
|
|
90
|
+
|
|
91
|
+
**© 2024-2025 Neuramorphic, Inc.**
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# NeuraTensor SDK
|
|
2
|
+
|
|
3
|
+
**Production neuromorphic inference at 8ms latency**
|
|
4
|
+
|
|
5
|
+
NeuraTensor is a high-performance neuromorphic inference SDK featuring a proprietary fused SNN-SSM architecture with CUDA acceleration.
|
|
6
|
+
|
|
7
|
+
## ⚡ Performance
|
|
8
|
+
|
|
9
|
+
- **8.13ms latency** (64M model, Jetson AGX Orin)
|
|
10
|
+
- **123 seq/s throughput**
|
|
11
|
+
- **120x faster** than PyTorch baseline
|
|
12
|
+
- Sub-10ms real-time inference
|
|
13
|
+
|
|
14
|
+
## �� Quick Start
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install neuratensor
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from neuratensor import NeuraTensor, NeuraTensorConfig
|
|
22
|
+
|
|
23
|
+
# Load model
|
|
24
|
+
config = NeuraTensorConfig.preset("64m")
|
|
25
|
+
model = NeuraTensor(config).cuda().half()
|
|
26
|
+
|
|
27
|
+
# Inference
|
|
28
|
+
output = model(input_ids)
|
|
29
|
+
# ✅ 8ms latency, 64M params, 123 seq/s
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 📊 Models
|
|
33
|
+
|
|
34
|
+
| Model | Parameters | Latency | Use Case |
|
|
35
|
+
|-------|-----------|---------|----------|
|
|
36
|
+
| 64M | 64M | 8ms | Edge, real-time |
|
|
37
|
+
| 256M | 256M | ~15ms | Balanced |
|
|
38
|
+
| 1B | 1B | ~35ms | Quality |
|
|
39
|
+
|
|
40
|
+
## 🔧 Requirements
|
|
41
|
+
|
|
42
|
+
- NVIDIA GPU (CUDA 11.4+, SM 7.0+)
|
|
43
|
+
- Python 3.8+
|
|
44
|
+
- PyTorch 2.0+
|
|
45
|
+
|
|
46
|
+
## 📚 Documentation
|
|
47
|
+
|
|
48
|
+
- [Distribution Guide](DISTRIBUTION_GUIDE.md)
|
|
49
|
+
- [Patent Notice](PATENT_NOTICE.txt)
|
|
50
|
+
|
|
51
|
+
## 📄 License
|
|
52
|
+
|
|
53
|
+
Proprietary. Binary distribution only.
|
|
54
|
+
|
|
55
|
+
**© 2024-2025 Neuramorphic, Inc.**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a95c77b71fff85e9ebab3d7cb5852628de008e8581564fd2f3b19256225f7908 lib/neuratensor_core.so
|
|
Binary file
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: neuratensor
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Production neuromorphic inference SDK with CUDA acceleration
|
|
5
|
+
Home-page: https://neuramorphic.ai
|
|
6
|
+
Author: Neuramorphic, Inc.
|
|
7
|
+
Author-email: info@neuramorphic.ai
|
|
8
|
+
License: Proprietary
|
|
9
|
+
Project-URL: Documentation, https://docs.neuramorphic.ai
|
|
10
|
+
Project-URL: Source, https://github.com/neuramorphic/neuratensor-sdk
|
|
11
|
+
Project-URL: Bug Reports, https://github.com/neuramorphic/neuratensor-sdk/issues
|
|
12
|
+
Keywords: neuromorphic,snn,ssm,cuda,inference,deep-learning,ai
|
|
13
|
+
Platform: Linux
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Classifier: License :: Other/Proprietary License
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
24
|
+
Classifier: Environment :: GPU :: NVIDIA CUDA
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: torch>=2.0.0
|
|
29
|
+
Requires-Dist: numpy>=1.19.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: flake8>=4.0.0; extra == "dev"
|
|
34
|
+
Provides-Extra: cli
|
|
35
|
+
Requires-Dist: click>=8.0.0; extra == "cli"
|
|
36
|
+
|
|
37
|
+
# NeuraTensor SDK
|
|
38
|
+
|
|
39
|
+
**Production neuromorphic inference at 8ms latency**
|
|
40
|
+
|
|
41
|
+
NeuraTensor is a high-performance neuromorphic inference SDK featuring a proprietary fused SNN-SSM architecture with CUDA acceleration.
|
|
42
|
+
|
|
43
|
+
## ⚡ Performance
|
|
44
|
+
|
|
45
|
+
- **8.13ms latency** (64M model, Jetson AGX Orin)
|
|
46
|
+
- **123 seq/s throughput**
|
|
47
|
+
- **120x faster** than PyTorch baseline
|
|
48
|
+
- Sub-10ms real-time inference
|
|
49
|
+
|
|
50
|
+
## �� Quick Start
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install neuratensor
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from neuratensor import NeuraTensor, NeuraTensorConfig
|
|
58
|
+
|
|
59
|
+
# Load model
|
|
60
|
+
config = NeuraTensorConfig.preset("64m")
|
|
61
|
+
model = NeuraTensor(config).cuda().half()
|
|
62
|
+
|
|
63
|
+
# Inference
|
|
64
|
+
output = model(input_ids)
|
|
65
|
+
# ✅ 8ms latency, 64M params, 123 seq/s
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 📊 Models
|
|
69
|
+
|
|
70
|
+
| Model | Parameters | Latency | Use Case |
|
|
71
|
+
|-------|-----------|---------|----------|
|
|
72
|
+
| 64M | 64M | 8ms | Edge, real-time |
|
|
73
|
+
| 256M | 256M | ~15ms | Balanced |
|
|
74
|
+
| 1B | 1B | ~35ms | Quality |
|
|
75
|
+
|
|
76
|
+
## 🔧 Requirements
|
|
77
|
+
|
|
78
|
+
- NVIDIA GPU (CUDA 11.4+, SM 7.0+)
|
|
79
|
+
- Python 3.8+
|
|
80
|
+
- PyTorch 2.0+
|
|
81
|
+
|
|
82
|
+
## 📚 Documentation
|
|
83
|
+
|
|
84
|
+
- [Distribution Guide](DISTRIBUTION_GUIDE.md)
|
|
85
|
+
- [Patent Notice](PATENT_NOTICE.txt)
|
|
86
|
+
|
|
87
|
+
## 📄 License
|
|
88
|
+
|
|
89
|
+
Proprietary. Binary distribution only.
|
|
90
|
+
|
|
91
|
+
**© 2024-2025 Neuramorphic, Inc.**
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
PATENT_NOTICE.txt
|
|
4
|
+
README.md
|
|
5
|
+
setup.py
|
|
6
|
+
lib/neuratensor_core.sha256
|
|
7
|
+
lib/neuratensor_core.so
|
|
8
|
+
neuratensor.egg-info/PKG-INFO
|
|
9
|
+
neuratensor.egg-info/SOURCES.txt
|
|
10
|
+
neuratensor.egg-info/dependency_links.txt
|
|
11
|
+
neuratensor.egg-info/entry_points.txt
|
|
12
|
+
neuratensor.egg-info/not-zip-safe
|
|
13
|
+
neuratensor.egg-info/requires.txt
|
|
14
|
+
neuratensor.egg-info/top_level.txt
|
|
15
|
+
sdk/__init__.py
|
|
16
|
+
sdk/backends.py
|
|
17
|
+
sdk/cli.py
|
|
18
|
+
sdk/config.py
|
|
19
|
+
sdk/demo_sdk_public.py
|
|
20
|
+
sdk/examples.py
|
|
21
|
+
sdk/inference.py
|
|
22
|
+
sdk/model_loader.py
|
|
23
|
+
sdk/secure_runtime.py
|
|
24
|
+
sdk/setup.py
|
|
25
|
+
sdk/../lib/neuratensor_core.sha256
|
|
26
|
+
sdk/../lib/neuratensor_core.so
|
|
27
|
+
sdk/tests/__init__.py
|
|
28
|
+
sdk/tests/test_inference.py
|
|
29
|
+
sdk/tests/test_model_loader.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
neuratensor
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""
|
|
2
|
+
NeuraTensor SDK - Public API
|
|
3
|
+
=============================
|
|
4
|
+
|
|
5
|
+
Production-ready neuromorphic inference SDK with universal hardware support.
|
|
6
|
+
|
|
7
|
+
Public API for NeuraTensor models. The core CUDA kernels are proprietary
|
|
8
|
+
and distributed as compiled binaries.
|
|
9
|
+
|
|
10
|
+
Neuramorphic, Inc. - San Francisco, CA
|
|
11
|
+
Version: 1.0.0
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
__version__ = "1.0.0"
|
|
15
|
+
__author__ = "Neuramorphic, Inc."
|
|
16
|
+
__license__ = "Apache 2.0"
|
|
17
|
+
|
|
18
|
+
from .model_loader import ModelLoader
|
|
19
|
+
from .config import SDKConfig, NeuraTensorConfig, ModelSize
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class NeuraTensor:
|
|
23
|
+
"""
|
|
24
|
+
NeuraTensor neuromorphic model (Public API).
|
|
25
|
+
|
|
26
|
+
Example:
|
|
27
|
+
>>> config = NeuraTensorConfig.preset("64m")
|
|
28
|
+
>>> model = NeuraTensor(config).cuda()
|
|
29
|
+
"""
|
|
30
|
+
def __init__(self, config: NeuraTensorConfig):
|
|
31
|
+
import sys
|
|
32
|
+
import os
|
|
33
|
+
from pathlib import Path
|
|
34
|
+
|
|
35
|
+
# Enable internal imports (SDK is authorized)
|
|
36
|
+
os.environ["NEURATENSOR_INTERNAL"] = "1"
|
|
37
|
+
|
|
38
|
+
# Add neuratensor to path
|
|
39
|
+
sdk_dir = Path(__file__).parent
|
|
40
|
+
neuratensor_dir = sdk_dir.parent
|
|
41
|
+
sys.path.insert(0, str(neuratensor_dir))
|
|
42
|
+
|
|
43
|
+
# Import from core (internal only - SDK authorized)
|
|
44
|
+
from core.model import NeuraTensorModel
|
|
45
|
+
from config.presets import create_64m_config, create_256m_config, create_1b_config
|
|
46
|
+
|
|
47
|
+
# Map SDK config to internal config
|
|
48
|
+
preset_map = {
|
|
49
|
+
"64m": create_64m_config,
|
|
50
|
+
"256m": create_256m_config,
|
|
51
|
+
"1b": create_1b_config,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
model_size = config.model_size.value if hasattr(config.model_size, 'value') else config.model_size
|
|
55
|
+
|
|
56
|
+
if model_size not in preset_map:
|
|
57
|
+
raise ValueError(f"Unknown model size: {model_size}")
|
|
58
|
+
|
|
59
|
+
internal_config = preset_map[model_size]()
|
|
60
|
+
self._model = NeuraTensorModel(internal_config)
|
|
61
|
+
self.config = config
|
|
62
|
+
|
|
63
|
+
# Update SDK config with internal values
|
|
64
|
+
self.config.vocab_size = internal_config.vocab_size
|
|
65
|
+
self.config.hidden_size = internal_config.hidden_size
|
|
66
|
+
|
|
67
|
+
def cuda(self):
|
|
68
|
+
"""Move model to CUDA"""
|
|
69
|
+
self._model = self._model.cuda()
|
|
70
|
+
return self
|
|
71
|
+
|
|
72
|
+
def half(self):
|
|
73
|
+
"""Convert model to FP16"""
|
|
74
|
+
self._model = self._model.half()
|
|
75
|
+
return self
|
|
76
|
+
|
|
77
|
+
def __call__(self, input_ids):
|
|
78
|
+
"""Forward pass"""
|
|
79
|
+
return self._model(input_ids)
|
|
80
|
+
|
|
81
|
+
def count_parameters(self):
|
|
82
|
+
"""Count model parameters"""
|
|
83
|
+
return self._model.count_parameters()
|
|
84
|
+
|
|
85
|
+
__all__ = [
|
|
86
|
+
'NeuraTensor',
|
|
87
|
+
'NeuraTensorConfig',
|
|
88
|
+
'ModelLoader',
|
|
89
|
+
'SDKConfig',
|
|
90
|
+
'ModelSize',
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# Quick start example
|
|
95
|
+
def quick_start():
|
|
96
|
+
"""
|
|
97
|
+
Quick start example for NeuraTensor SDK.
|
|
98
|
+
|
|
99
|
+
Usage:
|
|
100
|
+
>>> from neuratensor.sdk import quick_start
|
|
101
|
+
>>> quick_start()
|
|
102
|
+
"""
|
|
103
|
+
print("=" * 70)
|
|
104
|
+
print("NeuraTensor SDK - Quick Start")
|
|
105
|
+
print("=" * 70)
|
|
106
|
+
print()
|
|
107
|
+
print("from neuratensor.sdk import NeuraTensor")
|
|
108
|
+
print()
|
|
109
|
+
print("# Load model")
|
|
110
|
+
print('model = NeuraTensor.from_pretrained("64m")')
|
|
111
|
+
print()
|
|
112
|
+
print("# Run inference")
|
|
113
|
+
print("output = model(input_ids)")
|
|
114
|
+
print()
|
|
115
|
+
print("# Available models: 64m, 256m, 1b")
|
|
116
|
+
print("=" * 70)
|