pytorch-kito 0.2.9__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 (44) hide show
  1. pytorch_kito-0.2.9/LICENSE +21 -0
  2. pytorch_kito-0.2.9/PKG-INFO +332 -0
  3. pytorch_kito-0.2.9/README.md +259 -0
  4. pytorch_kito-0.2.9/pyproject.toml +89 -0
  5. pytorch_kito-0.2.9/setup.cfg +4 -0
  6. pytorch_kito-0.2.9/src/kito/__init__.py +49 -0
  7. pytorch_kito-0.2.9/src/kito/callbacks/__init__.py +20 -0
  8. pytorch_kito-0.2.9/src/kito/callbacks/callback_base.py +130 -0
  9. pytorch_kito-0.2.9/src/kito/callbacks/csv_logger.py +66 -0
  10. pytorch_kito-0.2.9/src/kito/callbacks/ddp_aware_callback.py +61 -0
  11. pytorch_kito-0.2.9/src/kito/callbacks/early_stopping_callback.py +45 -0
  12. pytorch_kito-0.2.9/src/kito/callbacks/modelcheckpoint.py +78 -0
  13. pytorch_kito-0.2.9/src/kito/callbacks/tensorboard_callback_images.py +371 -0
  14. pytorch_kito-0.2.9/src/kito/callbacks/tensorboard_callbacks.py +132 -0
  15. pytorch_kito-0.2.9/src/kito/callbacks/txt_logger.py +57 -0
  16. pytorch_kito-0.2.9/src/kito/config/__init__.py +0 -0
  17. pytorch_kito-0.2.9/src/kito/config/moduleconfig.py +212 -0
  18. pytorch_kito-0.2.9/src/kito/data/__init__.py +35 -0
  19. pytorch_kito-0.2.9/src/kito/data/datapipeline.py +301 -0
  20. pytorch_kito-0.2.9/src/kito/data/datasets.py +166 -0
  21. pytorch_kito-0.2.9/src/kito/data/preprocessed_dataset.py +106 -0
  22. pytorch_kito-0.2.9/src/kito/data/preprocessing.py +318 -0
  23. pytorch_kito-0.2.9/src/kito/data/registry.py +213 -0
  24. pytorch_kito-0.2.9/src/kito/engine.py +1146 -0
  25. pytorch_kito-0.2.9/src/kito/losses/__init__.py +31 -0
  26. pytorch_kito-0.2.9/src/kito/losses/builtin.py +196 -0
  27. pytorch_kito-0.2.9/src/kito/losses/custom.py +121 -0
  28. pytorch_kito-0.2.9/src/kito/losses/registry.py +174 -0
  29. pytorch_kito-0.2.9/src/kito/losses/utils.py +248 -0
  30. pytorch_kito-0.2.9/src/kito/module.py +450 -0
  31. pytorch_kito-0.2.9/src/kito/strategies/__init__.py +0 -0
  32. pytorch_kito-0.2.9/src/kito/strategies/logger_strategy.py +51 -0
  33. pytorch_kito-0.2.9/src/kito/strategies/progress_bar_strategy.py +57 -0
  34. pytorch_kito-0.2.9/src/kito/strategies/readiness_validator.py +172 -0
  35. pytorch_kito-0.2.9/src/kito/utils/__init__.py +0 -0
  36. pytorch_kito-0.2.9/src/kito/utils/decorators.py +54 -0
  37. pytorch_kito-0.2.9/src/kito/utils/gpu_utils.py +94 -0
  38. pytorch_kito-0.2.9/src/kito/utils/loss_utils.py +38 -0
  39. pytorch_kito-0.2.9/src/kito/utils/ssim_utils.py +94 -0
  40. pytorch_kito-0.2.9/src/pytorch_kito.egg-info/PKG-INFO +332 -0
  41. pytorch_kito-0.2.9/src/pytorch_kito.egg-info/SOURCES.txt +42 -0
  42. pytorch_kito-0.2.9/src/pytorch_kito.egg-info/dependency_links.txt +1 -0
  43. pytorch_kito-0.2.9/src/pytorch_kito.egg-info/requires.txt +31 -0
  44. pytorch_kito-0.2.9/src/pytorch_kito.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Giuseppe Costantino
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.
@@ -0,0 +1,332 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytorch-kito
3
+ Version: 0.2.9
4
+ Summary: Effortless PyTorch training - define your model, Kito handles the rest
5
+ Author-email: Giuseppe Costantino <giuseppe.costantino95@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Giuseppe Costantino
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Homepage, https://github.com/gcostantino/kito
28
+ Project-URL: Documentation, https://kito.readthedocs.io
29
+ Project-URL: Repository, https://github.com/gcostantino/kito
30
+ Project-URL: Bug Tracker, https://github.com/gcostantino/kito/issues
31
+ Keywords: pytorch,deep-learning,machine-learning,training,automation
32
+ Classifier: Development Status :: 3 - Alpha
33
+ Classifier: Intended Audience :: Science/Research
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Programming Language :: Python :: 3
37
+ Classifier: Programming Language :: Python :: 3.9
38
+ Classifier: Programming Language :: Python :: 3.10
39
+ Classifier: Programming Language :: Python :: 3.11
40
+ Classifier: Topic :: Scientific/Engineering
41
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
42
+ Requires-Python: >=3.9
43
+ Description-Content-Type: text/markdown
44
+ License-File: LICENSE
45
+ Requires-Dist: torch>=2.0.0
46
+ Requires-Dist: numpy>=1.20.0
47
+ Requires-Dist: h5py>=3.0.0
48
+ Requires-Dist: torchsummary>=1.5.1
49
+ Requires-Dist: packaging>=20.0
50
+ Requires-Dist: tensorboard>=2.10.0
51
+ Requires-Dist: pkbar>=0.5
52
+ Provides-Extra: dev
53
+ Requires-Dist: pytest>=7.0; extra == "dev"
54
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
55
+ Requires-Dist: pytest-mock>=3.10; extra == "dev"
56
+ Requires-Dist: black>=23.0; extra == "dev"
57
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
58
+ Provides-Extra: tensorboard
59
+ Requires-Dist: tensorboard>=2.10.0; extra == "tensorboard"
60
+ Provides-Extra: docs
61
+ Requires-Dist: sphinx>=5.0; extra == "docs"
62
+ Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
63
+ Provides-Extra: all
64
+ Requires-Dist: tensorboard>=2.10.0; extra == "all"
65
+ Requires-Dist: pytest>=7.0; extra == "all"
66
+ Requires-Dist: pytest-cov>=4.0; extra == "all"
67
+ Requires-Dist: pytest-mock>=3.10; extra == "all"
68
+ Requires-Dist: black>=23.0; extra == "all"
69
+ Requires-Dist: ruff>=0.1.0; extra == "all"
70
+ Requires-Dist: sphinx>=5.0; extra == "all"
71
+ Requires-Dist: sphinx-rtd-theme>=1.0; extra == "all"
72
+ Dynamic: license-file
73
+
74
+ <p align="center">
75
+ <img src="https://raw.githubusercontent.com/gcostantino/kito/refs/heads/main/assets/kito_simplelogo.png" alt="Kito Logo" width="200"/>
76
+ </p>
77
+
78
+ ---
79
+ **Effortless PyTorch training - define your model, Kito handles the rest.**
80
+
81
+ [![Tests](https://github.com/gcostantino/kito/actions/workflows/tests.yml/badge.svg)](https://github.com/gcostantino/kito/actions)
82
+ [![PyPI version](https://img.shields.io/pypi/v/pytorch-kito)](https://pypi.org/project/pytorch-kito/)
83
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
84
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytorch-kito)](https://pypi.org/project/pytorch-kito/)
85
+ [![Downloads](https://img.shields.io/pypi/dm/pytorch-kito?style=round-square)](https://pepy.tech/project/pytorch-kito)
86
+ [![Documentation Status](https://readthedocs.org/projects/kito/badge/?version=latest)](https://kito.readthedocs.io/en/latest/?badge=latest)
87
+
88
+ Kito is a lightweight PyTorch training library that eliminates boilerplate code. Define your model architecture and loss function - Kito automatically handles training loops, optimization, callbacks, distributed training, and more.
89
+
90
+ ## ✨ Key Features
91
+
92
+ - **Zero Boilerplate** - No training loops, no optimizer setup, no device management
93
+ - **Auto-Everything** - Automatic model building, optimizer binding, and device assignment
94
+ - **Built-in DDP** - Distributed training works out of the box
95
+ - **Smart Callbacks** - TensorBoard, checkpointing, logging, and custom callbacks
96
+ - **Flexible** - Simple for beginners, powerful for experts
97
+ - **Lightweight** - Minimal dependencies, pure PyTorch under the hood
98
+
99
+ ## Quick Start
100
+
101
+ ### Installation
102
+
103
+ ```bash
104
+ pip install pytorch-kito
105
+ ```
106
+
107
+ ### Your First Model in 3 Steps
108
+
109
+ ```python
110
+ import torch.nn as nn
111
+ from kito import Engine, KitoModule
112
+
113
+ # 1. Define your model
114
+ class MyModel(KitoModule):
115
+ def build_inner_model(self):
116
+ self.model = nn.Sequential(
117
+ nn.Linear(784, 128),
118
+ nn.ReLU(),
119
+ nn.Linear(128, 10)
120
+ )
121
+ self.model_input_size = (784,)
122
+
123
+ def bind_optimizer(self):
124
+ self.optimizer = torch.optim.Adam(
125
+ self.model.parameters(),
126
+ lr=self.learning_rate
127
+ )
128
+
129
+ # 2. Initialize
130
+ model = MyModel('MyModel', device, config)
131
+ engine = Engine(model, config)
132
+
133
+ # 3. Train! (That's it - everything else is automatic)
134
+ engine.fit(train_loader, val_loader, max_epochs=10)
135
+ ```
136
+
137
+ ## Philosophy
138
+
139
+ Kito follows a **"define once, train anywhere"** philosophy:
140
+
141
+ 1. **You focus on**: Model architecture and research ideas
142
+ 2. **Kito handles**: Training loops, optimization, distributed training, callbacks
143
+
144
+ Perfect for researchers who want to iterate quickly without rewriting training code.
145
+
146
+ ## Core Concepts
147
+
148
+ ### KitoModule
149
+
150
+ Your model inherits from `KitoModule` and implements two methods:
151
+
152
+ ```python
153
+ class MyModel(KitoModule):
154
+ def build_inner_model(self):
155
+ # Define your architecture
156
+ self.model = nn.Sequential(...)
157
+ self.model_input_size = (C, H, W) # Input shape
158
+
159
+ def bind_optimizer(self):
160
+ # Choose your optimizer
161
+ self.optimizer = torch.optim.Adam(
162
+ self.model.parameters(),
163
+ lr=self.learning_rate
164
+ )
165
+ ```
166
+
167
+ ### Engine
168
+
169
+ The `Engine` orchestrates everything:
170
+
171
+ ```python
172
+ engine = Engine(module, config)
173
+
174
+ # Training
175
+ engine.fit(train_loader, val_loader, max_epochs=100)
176
+
177
+ # Inference
178
+ predictions = engine.predict(test_loader)
179
+ ```
180
+
181
+ ### Data Pipeline
182
+
183
+ Kito provides a clean data pipeline with preprocessing:
184
+
185
+ ```python
186
+ from kito.data import H5Dataset, GenericDataPipeline
187
+ from kito.data.preprocessing import Pipeline, Normalize, ToTensor
188
+
189
+ # Create dataset
190
+ dataset = H5Dataset('data.h5')
191
+
192
+ # Add preprocessing
193
+ preprocessing = Pipeline([
194
+ Normalize(min_val=0.0, max_val=1.0),
195
+ ToTensor()
196
+ ])
197
+
198
+ # Setup data pipeline
199
+ pipeline = GenericDataPipeline(
200
+ config=config,
201
+ dataset=dataset,
202
+ preprocessing=preprocessing
203
+ )
204
+ pipeline.setup()
205
+
206
+ # Get dataloaders
207
+ train_loader = pipeline.train_dataloader()
208
+ val_loader = pipeline.val_dataloader()
209
+ ```
210
+
211
+ ### Callbacks
212
+
213
+ Kito includes powerful callbacks for common tasks:
214
+
215
+ ```python
216
+ from kito.callbacks import ModelCheckpoint, EarlyStopping, CSVLogger
217
+
218
+ callbacks = [
219
+ ModelCheckpoint('best_model.pt', monitor='val_loss', mode='min'),
220
+ EarlyStopping(patience=10, monitor='val_loss'),
221
+ CSVLogger('training.csv')
222
+ ]
223
+
224
+ engine.fit(train_loader, val_loader, callbacks=callbacks)
225
+ ```
226
+
227
+ Or create custom callbacks:
228
+
229
+ ```python
230
+ from kito.callbacks import Callback
231
+
232
+ class MyCallback(Callback):
233
+ def on_epoch_end(self, epoch, logs, **kwargs):
234
+ print(f"Epoch {epoch}: loss={logs['train_loss']:.4f}")
235
+ ```
236
+
237
+ ## Advanced Features
238
+
239
+ ### Distributed Training (DDP)
240
+
241
+ Enable distributed training with one config change:
242
+
243
+ ```python
244
+ config.training.distributed_training = True
245
+
246
+ # Everything else stays the same!
247
+ engine.fit(train_loader, val_loader, max_epochs=100)
248
+ ```
249
+
250
+ ### Custom Training Logic
251
+
252
+ Override `training_step` for custom behavior:
253
+
254
+ ```python
255
+ class MyModel(KitoModule):
256
+ def training_step(self, batch, pbar_handler=None):
257
+ inputs, targets = batch
258
+
259
+ # Custom forward pass
260
+ outputs = self.model(inputs)
261
+ loss = self.compute_loss((inputs, targets), outputs)
262
+
263
+ # Custom backward (e.g., gradient clipping)
264
+ self.optimizer.zero_grad()
265
+ loss.backward()
266
+ torch.nn.utils.clip_grad_norm_(self.model.parameters(), max_norm=1.0)
267
+ self.optimizer.step()
268
+
269
+ return {'loss': loss}
270
+ ```
271
+
272
+ ### Multiple Datasets
273
+
274
+ Kito supports HDF5 and in-memory datasets out of the box:
275
+
276
+ ```python
277
+ from kito.data import H5Dataset, MemDataset
278
+
279
+ # HDF5 dataset (lazy loading)
280
+ dataset = H5Dataset('large_data.h5')
281
+
282
+ # In-memory dataset (fast)
283
+ dataset = MemDataset(x_train, y_train)
284
+ ```
285
+
286
+ Register custom datasets easily:
287
+
288
+ ```python
289
+ from kito.data.registry import DATASETS
290
+
291
+ @DATASETS.register('my_custom_dataset')
292
+ class MyDataset(KitoDataset):
293
+ def _load_sample(self, index):
294
+ return data, labels
295
+ ```
296
+
297
+ ## 📦 Installation Options
298
+
299
+ ```bash
300
+ # Basic installation
301
+ pip install pytorch-kito
302
+
303
+ # With TensorBoard support
304
+ pip install pytorch-kito[tensorboard]
305
+
306
+ # Development installation
307
+ pip install pytorch-kito[dev]
308
+
309
+ # Everything
310
+ pip install pytorch-kito[all]
311
+ ```
312
+
313
+ ## 🤝 Contributing
314
+
315
+ Contributions are very welcome! Please check out our [Contributing Guide](CONTRIBUTING.md).
316
+
317
+ ## 📄 License
318
+
319
+ MIT License - see [LICENSE](LICENSE) file for details.
320
+
321
+ ## 🙏 Acknowledgments
322
+
323
+ Kito is inspired by PyTorch Lightning and Keras, aiming to bring similar ease-of-use to pure PyTorch workflows for researchers.
324
+
325
+ ## Contact
326
+
327
+ - **GitHub Issues**: [Report bugs or request features](https://github.com/gcostantino/kito/issues)
328
+ - **GitHub Discussions**: [Ask questions](https://github.com/gcostantino/kito/discussions)
329
+
330
+ ---
331
+
332
+ **Made with ❤️ for the PyTorch community**
@@ -0,0 +1,259 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/gcostantino/kito/refs/heads/main/assets/kito_simplelogo.png" alt="Kito Logo" width="200"/>
3
+ </p>
4
+
5
+ ---
6
+ **Effortless PyTorch training - define your model, Kito handles the rest.**
7
+
8
+ [![Tests](https://github.com/gcostantino/kito/actions/workflows/tests.yml/badge.svg)](https://github.com/gcostantino/kito/actions)
9
+ [![PyPI version](https://img.shields.io/pypi/v/pytorch-kito)](https://pypi.org/project/pytorch-kito/)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytorch-kito)](https://pypi.org/project/pytorch-kito/)
12
+ [![Downloads](https://img.shields.io/pypi/dm/pytorch-kito?style=round-square)](https://pepy.tech/project/pytorch-kito)
13
+ [![Documentation Status](https://readthedocs.org/projects/kito/badge/?version=latest)](https://kito.readthedocs.io/en/latest/?badge=latest)
14
+
15
+ Kito is a lightweight PyTorch training library that eliminates boilerplate code. Define your model architecture and loss function - Kito automatically handles training loops, optimization, callbacks, distributed training, and more.
16
+
17
+ ## ✨ Key Features
18
+
19
+ - **Zero Boilerplate** - No training loops, no optimizer setup, no device management
20
+ - **Auto-Everything** - Automatic model building, optimizer binding, and device assignment
21
+ - **Built-in DDP** - Distributed training works out of the box
22
+ - **Smart Callbacks** - TensorBoard, checkpointing, logging, and custom callbacks
23
+ - **Flexible** - Simple for beginners, powerful for experts
24
+ - **Lightweight** - Minimal dependencies, pure PyTorch under the hood
25
+
26
+ ## Quick Start
27
+
28
+ ### Installation
29
+
30
+ ```bash
31
+ pip install pytorch-kito
32
+ ```
33
+
34
+ ### Your First Model in 3 Steps
35
+
36
+ ```python
37
+ import torch.nn as nn
38
+ from kito import Engine, KitoModule
39
+
40
+ # 1. Define your model
41
+ class MyModel(KitoModule):
42
+ def build_inner_model(self):
43
+ self.model = nn.Sequential(
44
+ nn.Linear(784, 128),
45
+ nn.ReLU(),
46
+ nn.Linear(128, 10)
47
+ )
48
+ self.model_input_size = (784,)
49
+
50
+ def bind_optimizer(self):
51
+ self.optimizer = torch.optim.Adam(
52
+ self.model.parameters(),
53
+ lr=self.learning_rate
54
+ )
55
+
56
+ # 2. Initialize
57
+ model = MyModel('MyModel', device, config)
58
+ engine = Engine(model, config)
59
+
60
+ # 3. Train! (That's it - everything else is automatic)
61
+ engine.fit(train_loader, val_loader, max_epochs=10)
62
+ ```
63
+
64
+ ## Philosophy
65
+
66
+ Kito follows a **"define once, train anywhere"** philosophy:
67
+
68
+ 1. **You focus on**: Model architecture and research ideas
69
+ 2. **Kito handles**: Training loops, optimization, distributed training, callbacks
70
+
71
+ Perfect for researchers who want to iterate quickly without rewriting training code.
72
+
73
+ ## Core Concepts
74
+
75
+ ### KitoModule
76
+
77
+ Your model inherits from `KitoModule` and implements two methods:
78
+
79
+ ```python
80
+ class MyModel(KitoModule):
81
+ def build_inner_model(self):
82
+ # Define your architecture
83
+ self.model = nn.Sequential(...)
84
+ self.model_input_size = (C, H, W) # Input shape
85
+
86
+ def bind_optimizer(self):
87
+ # Choose your optimizer
88
+ self.optimizer = torch.optim.Adam(
89
+ self.model.parameters(),
90
+ lr=self.learning_rate
91
+ )
92
+ ```
93
+
94
+ ### Engine
95
+
96
+ The `Engine` orchestrates everything:
97
+
98
+ ```python
99
+ engine = Engine(module, config)
100
+
101
+ # Training
102
+ engine.fit(train_loader, val_loader, max_epochs=100)
103
+
104
+ # Inference
105
+ predictions = engine.predict(test_loader)
106
+ ```
107
+
108
+ ### Data Pipeline
109
+
110
+ Kito provides a clean data pipeline with preprocessing:
111
+
112
+ ```python
113
+ from kito.data import H5Dataset, GenericDataPipeline
114
+ from kito.data.preprocessing import Pipeline, Normalize, ToTensor
115
+
116
+ # Create dataset
117
+ dataset = H5Dataset('data.h5')
118
+
119
+ # Add preprocessing
120
+ preprocessing = Pipeline([
121
+ Normalize(min_val=0.0, max_val=1.0),
122
+ ToTensor()
123
+ ])
124
+
125
+ # Setup data pipeline
126
+ pipeline = GenericDataPipeline(
127
+ config=config,
128
+ dataset=dataset,
129
+ preprocessing=preprocessing
130
+ )
131
+ pipeline.setup()
132
+
133
+ # Get dataloaders
134
+ train_loader = pipeline.train_dataloader()
135
+ val_loader = pipeline.val_dataloader()
136
+ ```
137
+
138
+ ### Callbacks
139
+
140
+ Kito includes powerful callbacks for common tasks:
141
+
142
+ ```python
143
+ from kito.callbacks import ModelCheckpoint, EarlyStopping, CSVLogger
144
+
145
+ callbacks = [
146
+ ModelCheckpoint('best_model.pt', monitor='val_loss', mode='min'),
147
+ EarlyStopping(patience=10, monitor='val_loss'),
148
+ CSVLogger('training.csv')
149
+ ]
150
+
151
+ engine.fit(train_loader, val_loader, callbacks=callbacks)
152
+ ```
153
+
154
+ Or create custom callbacks:
155
+
156
+ ```python
157
+ from kito.callbacks import Callback
158
+
159
+ class MyCallback(Callback):
160
+ def on_epoch_end(self, epoch, logs, **kwargs):
161
+ print(f"Epoch {epoch}: loss={logs['train_loss']:.4f}")
162
+ ```
163
+
164
+ ## Advanced Features
165
+
166
+ ### Distributed Training (DDP)
167
+
168
+ Enable distributed training with one config change:
169
+
170
+ ```python
171
+ config.training.distributed_training = True
172
+
173
+ # Everything else stays the same!
174
+ engine.fit(train_loader, val_loader, max_epochs=100)
175
+ ```
176
+
177
+ ### Custom Training Logic
178
+
179
+ Override `training_step` for custom behavior:
180
+
181
+ ```python
182
+ class MyModel(KitoModule):
183
+ def training_step(self, batch, pbar_handler=None):
184
+ inputs, targets = batch
185
+
186
+ # Custom forward pass
187
+ outputs = self.model(inputs)
188
+ loss = self.compute_loss((inputs, targets), outputs)
189
+
190
+ # Custom backward (e.g., gradient clipping)
191
+ self.optimizer.zero_grad()
192
+ loss.backward()
193
+ torch.nn.utils.clip_grad_norm_(self.model.parameters(), max_norm=1.0)
194
+ self.optimizer.step()
195
+
196
+ return {'loss': loss}
197
+ ```
198
+
199
+ ### Multiple Datasets
200
+
201
+ Kito supports HDF5 and in-memory datasets out of the box:
202
+
203
+ ```python
204
+ from kito.data import H5Dataset, MemDataset
205
+
206
+ # HDF5 dataset (lazy loading)
207
+ dataset = H5Dataset('large_data.h5')
208
+
209
+ # In-memory dataset (fast)
210
+ dataset = MemDataset(x_train, y_train)
211
+ ```
212
+
213
+ Register custom datasets easily:
214
+
215
+ ```python
216
+ from kito.data.registry import DATASETS
217
+
218
+ @DATASETS.register('my_custom_dataset')
219
+ class MyDataset(KitoDataset):
220
+ def _load_sample(self, index):
221
+ return data, labels
222
+ ```
223
+
224
+ ## 📦 Installation Options
225
+
226
+ ```bash
227
+ # Basic installation
228
+ pip install pytorch-kito
229
+
230
+ # With TensorBoard support
231
+ pip install pytorch-kito[tensorboard]
232
+
233
+ # Development installation
234
+ pip install pytorch-kito[dev]
235
+
236
+ # Everything
237
+ pip install pytorch-kito[all]
238
+ ```
239
+
240
+ ## 🤝 Contributing
241
+
242
+ Contributions are very welcome! Please check out our [Contributing Guide](CONTRIBUTING.md).
243
+
244
+ ## 📄 License
245
+
246
+ MIT License - see [LICENSE](LICENSE) file for details.
247
+
248
+ ## 🙏 Acknowledgments
249
+
250
+ Kito is inspired by PyTorch Lightning and Keras, aiming to bring similar ease-of-use to pure PyTorch workflows for researchers.
251
+
252
+ ## Contact
253
+
254
+ - **GitHub Issues**: [Report bugs or request features](https://github.com/gcostantino/kito/issues)
255
+ - **GitHub Discussions**: [Ask questions](https://github.com/gcostantino/kito/discussions)
256
+
257
+ ---
258
+
259
+ **Made with ❤️ for the PyTorch community**
@@ -0,0 +1,89 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pytorch-kito"
7
+ dynamic = ["version"]
8
+ description = "Effortless PyTorch training - define your model, Kito handles the rest"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = {file = "LICENSE"}
12
+ authors = [
13
+ {name = "Giuseppe Costantino", email = "giuseppe.costantino95@gmail.com"}
14
+ ]
15
+ keywords = ["pytorch", "deep-learning", "machine-learning", "training", "automation"]
16
+
17
+ # 3 - Alpha
18
+ # 4 - Beta
19
+ # 5 - Production/Stable
20
+
21
+ classifiers = [
22
+ "Development Status :: 3 - Alpha",
23
+ "Intended Audience :: Science/Research",
24
+ "Intended Audience :: Developers",
25
+ "License :: OSI Approved :: MIT License",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.9",
28
+ "Programming Language :: Python :: 3.10",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Topic :: Scientific/Engineering",
31
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
32
+ ]
33
+
34
+ # Core dependencies (required for kito to work)
35
+ dependencies = [
36
+ "torch>=2.0.0",
37
+ "numpy>=1.20.0",
38
+ "h5py>=3.0.0",
39
+ "torchsummary>=1.5.1",
40
+ "packaging>=20.0",
41
+ "tensorboard>=2.10.0",
42
+ "pkbar>=0.5",
43
+ ]
44
+
45
+ # Optional dependencies
46
+ [project.optional-dependencies]
47
+ # Development and testing
48
+ dev = [
49
+ "pytest>=7.0",
50
+ "pytest-cov>=4.0",
51
+ "pytest-mock>=3.10",
52
+ "black>=23.0",
53
+ "ruff>=0.1.0",
54
+ ]
55
+
56
+ # TensorBoard support
57
+ tensorboard = [
58
+ "tensorboard>=2.10.0",
59
+ ]
60
+
61
+ # Documentation
62
+ docs = [
63
+ "sphinx>=5.0",
64
+ "sphinx-rtd-theme>=1.0",
65
+ ]
66
+
67
+ # All extras (convenience)
68
+ all = [
69
+ "tensorboard>=2.10.0",
70
+ "pytest>=7.0",
71
+ "pytest-cov>=4.0",
72
+ "pytest-mock>=3.10",
73
+ "black>=23.0",
74
+ "ruff>=0.1.0",
75
+ "sphinx>=5.0",
76
+ "sphinx-rtd-theme>=1.0",
77
+ ]
78
+
79
+ [project.urls]
80
+ Homepage = "https://github.com/gcostantino/kito"
81
+ Documentation = "https://kito.readthedocs.io"
82
+ Repository = "https://github.com/gcostantino/kito"
83
+ "Bug Tracker" = "https://github.com/gcostantino/kito/issues"
84
+
85
+ [tool.setuptools.packages.find]
86
+ where = ["src"]
87
+
88
+ [tool.setuptools.dynamic]
89
+ version = {attr = "kito.__version__"}
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+