pytensorforge 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.
- pytensorforge-0.1.0/PKG-INFO +103 -0
- pytensorforge-0.1.0/README.md +91 -0
- pytensorforge-0.1.0/cli.py +604 -0
- pytensorforge-0.1.0/pyproject.toml +37 -0
- pytensorforge-0.1.0/pytensorforge.egg-info/PKG-INFO +103 -0
- pytensorforge-0.1.0/pytensorforge.egg-info/SOURCES.txt +149 -0
- pytensorforge-0.1.0/pytensorforge.egg-info/dependency_links.txt +1 -0
- pytensorforge-0.1.0/pytensorforge.egg-info/entry_points.txt +2 -0
- pytensorforge-0.1.0/pytensorforge.egg-info/requires.txt +2 -0
- pytensorforge-0.1.0/pytensorforge.egg-info/top_level.txt +2 -0
- pytensorforge-0.1.0/setup.cfg +4 -0
- pytensorforge-0.1.0/src/__init__.py +0 -0
- pytensorforge-0.1.0/src/activations/Activation.py +4 -0
- pytensorforge-0.1.0/src/activations/ELU.py +11 -0
- pytensorforge-0.1.0/src/activations/GELU.py +6 -0
- pytensorforge-0.1.0/src/activations/ReLU.py +27 -0
- pytensorforge-0.1.0/src/activations/SELU.py +14 -0
- pytensorforge-0.1.0/src/activations/Sigmoid.py +27 -0
- pytensorforge-0.1.0/src/activations/Softmax.py +84 -0
- pytensorforge-0.1.0/src/activations/Tanh.py +29 -0
- pytensorforge-0.1.0/src/activations/__init__.py +17 -0
- pytensorforge-0.1.0/src/config.py +120 -0
- pytensorforge-0.1.0/src/core/Matrix.py +3 -0
- pytensorforge-0.1.0/src/core/Scalar.py +18 -0
- pytensorforge-0.1.0/src/core/Tensor.py +866 -0
- pytensorforge-0.1.0/src/core/Vector.py +31 -0
- pytensorforge-0.1.0/src/core/__init__.py +0 -0
- pytensorforge-0.1.0/src/data/__init__.py +0 -0
- pytensorforge-0.1.0/src/data/chat_dataset.py +188 -0
- pytensorforge-0.1.0/src/data/corpus.py +104 -0
- pytensorforge-0.1.0/src/data/document_stream.py +178 -0
- pytensorforge-0.1.0/src/data/parallel_encode.py +86 -0
- pytensorforge-0.1.0/src/data/prefetch.py +62 -0
- pytensorforge-0.1.0/src/data/shard_builder.py +119 -0
- pytensorforge-0.1.0/src/data/shard_writer.py +81 -0
- pytensorforge-0.1.0/src/data/sharded_dataset.py +112 -0
- pytensorforge-0.1.0/src/data/streaming_dataset.py +132 -0
- pytensorforge-0.1.0/src/data/validation.py +212 -0
- pytensorforge-0.1.0/src/inference/__init__.py +0 -0
- pytensorforge-0.1.0/src/inference/chat_template.py +384 -0
- pytensorforge-0.1.0/src/inference/config.py +48 -0
- pytensorforge-0.1.0/src/inference/engine.py +241 -0
- pytensorforge-0.1.0/src/inference/export.py +133 -0
- pytensorforge-0.1.0/src/inference/kv_cache.py +65 -0
- pytensorforge-0.1.0/src/inference/runtime.py +161 -0
- pytensorforge-0.1.0/src/inference/sampling.py +42 -0
- pytensorforge-0.1.0/src/inference/scheduler.py +473 -0
- pytensorforge-0.1.0/src/inference/text.py +67 -0
- pytensorforge-0.1.0/src/initializers/Constant.py +9 -0
- pytensorforge-0.1.0/src/initializers/GlorotNormal.py +15 -0
- pytensorforge-0.1.0/src/initializers/GlorotUniform.py +26 -0
- pytensorforge-0.1.0/src/initializers/HeNormal.py +15 -0
- pytensorforge-0.1.0/src/initializers/HeUniform.py +14 -0
- pytensorforge-0.1.0/src/initializers/Initializer.py +4 -0
- pytensorforge-0.1.0/src/initializers/LecunNormal.py +16 -0
- pytensorforge-0.1.0/src/initializers/LecunUniform.py +14 -0
- pytensorforge-0.1.0/src/initializers/Ones.py +6 -0
- pytensorforge-0.1.0/src/initializers/Orthogonal.py +14 -0
- pytensorforge-0.1.0/src/initializers/RandomNormal.py +14 -0
- pytensorforge-0.1.0/src/initializers/RandomUniform.py +14 -0
- pytensorforge-0.1.0/src/initializers/Zeros.py +8 -0
- pytensorforge-0.1.0/src/initializers/__init__.py +17 -0
- pytensorforge-0.1.0/src/loss/CategoricalCrossEntropy.py +9 -0
- pytensorforge-0.1.0/src/loss/CrossEntropyLoss.py +34 -0
- pytensorforge-0.1.0/src/loss/CrossEntropyWithLogitsLoss.py +59 -0
- pytensorforge-0.1.0/src/loss/Hinge.py +5 -0
- pytensorforge-0.1.0/src/loss/Huber.py +22 -0
- pytensorforge-0.1.0/src/loss/Loss.py +6 -0
- pytensorforge-0.1.0/src/loss/MSE.py +7 -0
- pytensorforge-0.1.0/src/loss/MSELoss.py +10 -0
- pytensorforge-0.1.0/src/loss/SparseCategoricalCrossEntropy.py +15 -0
- pytensorforge-0.1.0/src/loss/__init__.py +18 -0
- pytensorforge-0.1.0/src/loss/bce.py +34 -0
- pytensorforge-0.1.0/src/loss/mae.py +16 -0
- pytensorforge-0.1.0/src/math/__init__.py +0 -0
- pytensorforge-0.1.0/src/math/clip.py +37 -0
- pytensorforge-0.1.0/src/math/exp.py +27 -0
- pytensorforge-0.1.0/src/math/log.py +25 -0
- pytensorforge-0.1.0/src/math/sigmoid.py +5 -0
- pytensorforge-0.1.0/src/models/__init__.py +0 -0
- pytensorforge-0.1.0/src/models/embedding/Embedding.py +65 -0
- pytensorforge-0.1.0/src/models/embedding/__init__.py +0 -0
- pytensorforge-0.1.0/src/models/gpt/__init__.py +0 -0
- pytensorforge-0.1.0/src/models/gpt/attention.py +158 -0
- pytensorforge-0.1.0/src/models/gpt/block.py +74 -0
- pytensorforge-0.1.0/src/models/gpt/config.py +103 -0
- pytensorforge-0.1.0/src/models/gpt/context.py +44 -0
- pytensorforge-0.1.0/src/models/gpt/model.py +165 -0
- pytensorforge-0.1.0/src/models/gpt/recompute.py +35 -0
- pytensorforge-0.1.0/src/models/gpt/rope.py +84 -0
- pytensorforge-0.1.0/src/models/regression/Linear.py +51 -0
- pytensorforge-0.1.0/src/models/regression/Logistic.py +36 -0
- pytensorforge-0.1.0/src/models/regression/__init__.py +0 -0
- pytensorforge-0.1.0/src/models/seq/Sequential.py +297 -0
- pytensorforge-0.1.0/src/models/seq/__init__.py +0 -0
- pytensorforge-0.1.0/src/models/svm/__init__.py +0 -0
- pytensorforge-0.1.0/src/models/tokenizer/BPETokenizer.py +228 -0
- pytensorforge-0.1.0/src/models/tokenizer/__init__.py +0 -0
- pytensorforge-0.1.0/src/models/transformers/Dropout.py +35 -0
- pytensorforge-0.1.0/src/models/transformers/LastToken.py +10 -0
- pytensorforge-0.1.0/src/models/transformers/LayerNorm.py +54 -0
- pytensorforge-0.1.0/src/models/transformers/Linear.py +18 -0
- pytensorforge-0.1.0/src/models/transformers/MultiHeadAttention.py +130 -0
- pytensorforge-0.1.0/src/models/transformers/TransformerBlock.py +79 -0
- pytensorforge-0.1.0/src/models/transformers/__init__.py +0 -0
- pytensorforge-0.1.0/src/neural/Dense.py +58 -0
- pytensorforge-0.1.0/src/neural/LSTM.py +167 -0
- pytensorforge-0.1.0/src/neural/Layer.py +72 -0
- pytensorforge-0.1.0/src/neural/Parameter.py +30 -0
- pytensorforge-0.1.0/src/neural/RNN.py +83 -0
- pytensorforge-0.1.0/src/neural/__init__.py +0 -0
- pytensorforge-0.1.0/src/ops/__init__.py +0 -0
- pytensorforge-0.1.0/src/ops/stack.py +40 -0
- pytensorforge-0.1.0/src/optimizers/Adagrad.py +31 -0
- pytensorforge-0.1.0/src/optimizers/Adam.py +98 -0
- pytensorforge-0.1.0/src/optimizers/AdamW.py +84 -0
- pytensorforge-0.1.0/src/optimizers/Batch.py +11 -0
- pytensorforge-0.1.0/src/optimizers/Nesterov.py +35 -0
- pytensorforge-0.1.0/src/optimizers/Optimizer.py +18 -0
- pytensorforge-0.1.0/src/optimizers/RMSProp.py +35 -0
- pytensorforge-0.1.0/src/optimizers/SGD.py +30 -0
- pytensorforge-0.1.0/src/optimizers/SGDMomentum.py +28 -0
- pytensorforge-0.1.0/src/optimizers/__init__.py +9 -0
- pytensorforge-0.1.0/src/scaling/StandardScaler.py +15 -0
- pytensorforge-0.1.0/src/scaling/__init__.py +0 -0
- pytensorforge-0.1.0/src/serialization/__init__.py +0 -0
- pytensorforge-0.1.0/src/serialization/checkpoint.py +58 -0
- pytensorforge-0.1.0/src/serialization/modelio.py +132 -0
- pytensorforge-0.1.0/src/serving/__init__.py +0 -0
- pytensorforge-0.1.0/src/serving/app.py +792 -0
- pytensorforge-0.1.0/src/serving/config.py +216 -0
- pytensorforge-0.1.0/src/serving/errors.py +51 -0
- pytensorforge-0.1.0/src/serving/http.py +599 -0
- pytensorforge-0.1.0/src/serving/metrics.py +293 -0
- pytensorforge-0.1.0/src/serving/model_server.py +287 -0
- pytensorforge-0.1.0/src/serving/protocol.py +377 -0
- pytensorforge-0.1.0/src/serving/security.py +200 -0
- pytensorforge-0.1.0/src/serving/server.py +121 -0
- pytensorforge-0.1.0/src/tokenization/__init__.py +0 -0
- pytensorforge-0.1.0/src/tokenization/base.py +75 -0
- pytensorforge-0.1.0/src/tokenization/bpe.py +190 -0
- pytensorforge-0.1.0/src/tokenization/bytebpe.py +476 -0
- pytensorforge-0.1.0/src/tokenization/registry.py +28 -0
- pytensorforge-0.1.0/src/training/__init__.py +0 -0
- pytensorforge-0.1.0/src/training/checkpoint_manager.py +101 -0
- pytensorforge-0.1.0/src/training/experiment.py +71 -0
- pytensorforge-0.1.0/src/training/losses.py +42 -0
- pytensorforge-0.1.0/src/training/precision.py +141 -0
- pytensorforge-0.1.0/src/training/profiler.py +38 -0
- pytensorforge-0.1.0/src/training/scheduler.py +50 -0
- pytensorforge-0.1.0/src/training/trainer.py +594 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pytensorforge
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deep Learning Framework
|
|
5
|
+
Author: Nnamdi Chidume
|
|
6
|
+
Project-URL: Homepage, http://github.com/philipszdavido/pytensorforge
|
|
7
|
+
Project-URL: Repository, http://github.com/philipszdavido/pytensorforge
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: numpy>=2.0
|
|
11
|
+
Requires-Dist: pyyaml>=6.0
|
|
12
|
+
|
|
13
|
+
# PyTensorForge
|
|
14
|
+
|
|
15
|
+
PyTensorForge is a machine learning framework. It provides a modular core for tensor operations, neural network layers, activation functions, optimizers, loss metrics, and model definitions. It is designed to build and train enterprise-level models for computer vision, forecasting, LLM, NLP, etc.
|
|
16
|
+
|
|
17
|
+
PyTensorForge is also designed for learning, experimentation, and rapid prototyping
|
|
18
|
+
|
|
19
|
+
## Key Features
|
|
20
|
+
|
|
21
|
+
- Core tensor and scalar abstractions for numerical computation
|
|
22
|
+
- Layer-based neural network support with dense and sequential model building
|
|
23
|
+
- Common activation functions such as ReLU, Sigmoid, Tanh, ELU, and SELU
|
|
24
|
+
- Standard optimization algorithms with SGD and batch optimization
|
|
25
|
+
- Loss functions including mean squared error, mean absolute error, and binary cross-entropy
|
|
26
|
+
- Weight initialization utilities with Glorot, He, LeCun, and zeros initializers
|
|
27
|
+
- Model implementations for regression and logistic classification
|
|
28
|
+
|
|
29
|
+
## Project Structure
|
|
30
|
+
|
|
31
|
+
- `src/core/` – Tensor, scalar, matrix, and vector primitives
|
|
32
|
+
- `src/neural/` – Neural layer abstractions, parameters, and dense layers
|
|
33
|
+
- `src/activations/` – Activation function implementations
|
|
34
|
+
- `src/optimizer/` – Optimizer base classes and SGD implementation
|
|
35
|
+
- `src/loss/` – Loss function abstractions and implementations
|
|
36
|
+
- `src/initializers/` – Weight initializer utilities
|
|
37
|
+
- `src/models/` – High-level model APIs for regression, classification, and sequential models
|
|
38
|
+
- `src/scaling/` – Data scaling utilities
|
|
39
|
+
- `src/models/gpt/` – decoder-only GPT Transformer (see `PHASE1_GPT_TRAINING.md`)
|
|
40
|
+
- `src/data/`, `src/training/` – streaming corpora, token shards, resumable trainer (`PHASE1_GPT_TRAINING.md`, `PHASE2_DATA_PIPELINE.md`)
|
|
41
|
+
- `src/tokenization/` – tokenizer abstraction, word-level and byte-level BPE (`TOKENIZER.md`)
|
|
42
|
+
- `src/inference/` – KV-cache inference runtime, continuous batching, chat templates (`PHASE3_INFERENCE.md`)
|
|
43
|
+
- `src/serving/` – OpenAI-compatible HTTP/SSE model server (`PHASE4_SERVING.md`)
|
|
44
|
+
- RoPE, activation checkpointing, bf16/fp16 numerics, parallel tokenization (`PHASE5_TRAINING_EFFICIENCY.md`)
|
|
45
|
+
- Context extension for RoPE models: extrapolate, linear, NTK (`PHASE6_CONTEXT_EXTENSION.md`)
|
|
46
|
+
- Fine-tuning (`init_from`) and chat training with assistant-only loss masking (`PHASE7_FINETUNING.md`)
|
|
47
|
+
- `web/` – TypeScript chat web client (prebuilt in `web/dist`)
|
|
48
|
+
- `predict/` – Prediction utilities and example datasets
|
|
49
|
+
- `test/` – Unit tests and example usage scripts
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
1. Clone the repository:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
git clone https://github.com/philipsz-davido/PyTensorForge.git
|
|
57
|
+
cd PyTensorForge
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
2. Install dependencies:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install -e .
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This installs the `pytensorforge` command (`train`, `resume`, `evaluate`, `inspect`,
|
|
67
|
+
`tokenize`, `prepare-dataset`, `generate`, `export`, `serve`). Runtime dependencies are
|
|
68
|
+
`numpy` and `pyyaml` only.
|
|
69
|
+
|
|
70
|
+
> Note: This repository is intended for educational use and may require additional dependencies depending on the development environment.
|
|
71
|
+
|
|
72
|
+
## Usage
|
|
73
|
+
|
|
74
|
+
Import components from the package and build models using the provided modules. Example:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from src.neural.Dense import Dense
|
|
78
|
+
from src.neural.Layer import Layer
|
|
79
|
+
from src.optimizers.SGD import SGD
|
|
80
|
+
from src.loss.MSE import MSE
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Refer to the `test/` directory for example scripts and usage patterns.
|
|
84
|
+
|
|
85
|
+
Serving a trained model:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pytensorforge export checkpoints/latest --output exports/my-gpt --tokenizer tokenizer/ --chat-template ptf-chat
|
|
89
|
+
pytensorforge serve exports/my-gpt --name my-gpt --api-key-file api_keys.txt
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Then open `http://127.0.0.1:8000/` or point any OpenAI-compatible client at
|
|
93
|
+
`http://127.0.0.1:8000/v1`. See `serve.example.yaml` and `PHASE4_SERVING.md`.
|
|
94
|
+
|
|
95
|
+
## Contribution
|
|
96
|
+
|
|
97
|
+
Contributions are welcome. Please open an issue or submit a pull request for feature requests, bug fixes, or documentation improvements.
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
This project is provided under the terms of the repository license. Check the project root for license details.
|
|
102
|
+
|
|
103
|
+
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# PyTensorForge
|
|
2
|
+
|
|
3
|
+
PyTensorForge is a machine learning framework. It provides a modular core for tensor operations, neural network layers, activation functions, optimizers, loss metrics, and model definitions. It is designed to build and train enterprise-level models for computer vision, forecasting, LLM, NLP, etc.
|
|
4
|
+
|
|
5
|
+
PyTensorForge is also designed for learning, experimentation, and rapid prototyping
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
- Core tensor and scalar abstractions for numerical computation
|
|
10
|
+
- Layer-based neural network support with dense and sequential model building
|
|
11
|
+
- Common activation functions such as ReLU, Sigmoid, Tanh, ELU, and SELU
|
|
12
|
+
- Standard optimization algorithms with SGD and batch optimization
|
|
13
|
+
- Loss functions including mean squared error, mean absolute error, and binary cross-entropy
|
|
14
|
+
- Weight initialization utilities with Glorot, He, LeCun, and zeros initializers
|
|
15
|
+
- Model implementations for regression and logistic classification
|
|
16
|
+
|
|
17
|
+
## Project Structure
|
|
18
|
+
|
|
19
|
+
- `src/core/` – Tensor, scalar, matrix, and vector primitives
|
|
20
|
+
- `src/neural/` – Neural layer abstractions, parameters, and dense layers
|
|
21
|
+
- `src/activations/` – Activation function implementations
|
|
22
|
+
- `src/optimizer/` – Optimizer base classes and SGD implementation
|
|
23
|
+
- `src/loss/` – Loss function abstractions and implementations
|
|
24
|
+
- `src/initializers/` – Weight initializer utilities
|
|
25
|
+
- `src/models/` – High-level model APIs for regression, classification, and sequential models
|
|
26
|
+
- `src/scaling/` – Data scaling utilities
|
|
27
|
+
- `src/models/gpt/` – decoder-only GPT Transformer (see `PHASE1_GPT_TRAINING.md`)
|
|
28
|
+
- `src/data/`, `src/training/` – streaming corpora, token shards, resumable trainer (`PHASE1_GPT_TRAINING.md`, `PHASE2_DATA_PIPELINE.md`)
|
|
29
|
+
- `src/tokenization/` – tokenizer abstraction, word-level and byte-level BPE (`TOKENIZER.md`)
|
|
30
|
+
- `src/inference/` – KV-cache inference runtime, continuous batching, chat templates (`PHASE3_INFERENCE.md`)
|
|
31
|
+
- `src/serving/` – OpenAI-compatible HTTP/SSE model server (`PHASE4_SERVING.md`)
|
|
32
|
+
- RoPE, activation checkpointing, bf16/fp16 numerics, parallel tokenization (`PHASE5_TRAINING_EFFICIENCY.md`)
|
|
33
|
+
- Context extension for RoPE models: extrapolate, linear, NTK (`PHASE6_CONTEXT_EXTENSION.md`)
|
|
34
|
+
- Fine-tuning (`init_from`) and chat training with assistant-only loss masking (`PHASE7_FINETUNING.md`)
|
|
35
|
+
- `web/` – TypeScript chat web client (prebuilt in `web/dist`)
|
|
36
|
+
- `predict/` – Prediction utilities and example datasets
|
|
37
|
+
- `test/` – Unit tests and example usage scripts
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
1. Clone the repository:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
git clone https://github.com/philipsz-davido/PyTensorForge.git
|
|
45
|
+
cd PyTensorForge
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
2. Install dependencies:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install -e .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This installs the `pytensorforge` command (`train`, `resume`, `evaluate`, `inspect`,
|
|
55
|
+
`tokenize`, `prepare-dataset`, `generate`, `export`, `serve`). Runtime dependencies are
|
|
56
|
+
`numpy` and `pyyaml` only.
|
|
57
|
+
|
|
58
|
+
> Note: This repository is intended for educational use and may require additional dependencies depending on the development environment.
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
Import components from the package and build models using the provided modules. Example:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from src.neural.Dense import Dense
|
|
66
|
+
from src.neural.Layer import Layer
|
|
67
|
+
from src.optimizers.SGD import SGD
|
|
68
|
+
from src.loss.MSE import MSE
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Refer to the `test/` directory for example scripts and usage patterns.
|
|
72
|
+
|
|
73
|
+
Serving a trained model:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pytensorforge export checkpoints/latest --output exports/my-gpt --tokenizer tokenizer/ --chat-template ptf-chat
|
|
77
|
+
pytensorforge serve exports/my-gpt --name my-gpt --api-key-file api_keys.txt
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Then open `http://127.0.0.1:8000/` or point any OpenAI-compatible client at
|
|
81
|
+
`http://127.0.0.1:8000/v1`. See `serve.example.yaml` and `PHASE4_SERVING.md`.
|
|
82
|
+
|
|
83
|
+
## Contribution
|
|
84
|
+
|
|
85
|
+
Contributions are welcome. Please open an issue or submit a pull request for feature requests, bug fixes, or documentation improvements.
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
This project is provided under the terms of the repository license. Check the project root for license details.
|
|
90
|
+
|
|
91
|
+
|