modelstudio 0.3.0__tar.gz → 0.4.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 (182) hide show
  1. {modelstudio-0.3.0/python/modelstudio.egg-info → modelstudio-0.4.0}/PKG-INFO +48 -6
  2. {modelstudio-0.3.0 → modelstudio-0.4.0}/README.md +47 -5
  3. modelstudio-0.4.0/benchmarks/bench_creation.py +38 -0
  4. modelstudio-0.4.0/benchmarks/bench_manipulation.py +38 -0
  5. modelstudio-0.4.0/docs/checkpointing.md +30 -0
  6. {modelstudio-0.3.0 → modelstudio-0.4.0}/docs/data.md +9 -0
  7. modelstudio-0.4.0/docs/metrics.md +11 -0
  8. {modelstudio-0.3.0 → modelstudio-0.4.0}/docs/native-backend-roadmap.md +1 -2
  9. {modelstudio-0.3.0 → modelstudio-0.4.0}/docs/nn.md +3 -0
  10. modelstudio-0.4.0/docs/numpy-interop.md +22 -0
  11. modelstudio-0.4.0/docs/optimizers.md +28 -0
  12. {modelstudio-0.3.0 → modelstudio-0.4.0}/docs/tensor-api.md +5 -0
  13. modelstudio-0.4.0/docs/tensor-creation.md +23 -0
  14. modelstudio-0.4.0/docs/tensor-manipulation.md +25 -0
  15. {modelstudio-0.3.0 → modelstudio-0.4.0}/docs/training.md +1 -2
  16. modelstudio-0.4.0/examples/checkpoint_resume.py +43 -0
  17. modelstudio-0.4.0/examples/metrics_demo.py +20 -0
  18. modelstudio-0.4.0/examples/numpy_interop.py +21 -0
  19. modelstudio-0.4.0/examples/scheduler_training.py +27 -0
  20. {modelstudio-0.3.0 → modelstudio-0.4.0}/pyproject.toml +1 -1
  21. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/__init__.py +79 -7
  22. modelstudio-0.4.0/python/modelstudio/_version.py +1 -0
  23. modelstudio-0.4.0/python/modelstudio/data/__init__.py +4 -0
  24. modelstudio-0.4.0/python/modelstudio/data/dataset.py +59 -0
  25. modelstudio-0.4.0/python/modelstudio/interop.py +41 -0
  26. modelstudio-0.4.0/python/modelstudio/metrics/__init__.py +4 -0
  27. modelstudio-0.4.0/python/modelstudio/metrics/classification.py +19 -0
  28. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/nn/__init__.py +4 -1
  29. modelstudio-0.4.0/python/modelstudio/nn/activations.py +57 -0
  30. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/ops/__init__.py +56 -4
  31. modelstudio-0.4.0/python/modelstudio/ops/creation.py +251 -0
  32. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/ops/math.py +68 -0
  33. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/ops/movement.py +140 -0
  34. modelstudio-0.4.0/python/modelstudio/optim/__init__.py +7 -0
  35. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/optim/adamw.py +43 -28
  36. modelstudio-0.4.0/python/modelstudio/optim/lr_scheduler.py +114 -0
  37. modelstudio-0.4.0/python/modelstudio/optim/optimizer.py +98 -0
  38. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/optim/sgd.py +20 -8
  39. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/serialization.py +33 -0
  40. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/tensor.py +72 -1
  41. {modelstudio-0.3.0 → modelstudio-0.4.0/python/modelstudio.egg-info}/PKG-INFO +48 -6
  42. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio.egg-info/SOURCES.txt +27 -0
  43. {modelstudio-0.3.0 → modelstudio-0.4.0}/scripts/smoke_test.py +23 -0
  44. modelstudio-0.4.0/tests/test_activations_more.py +42 -0
  45. modelstudio-0.4.0/tests/test_checkpoint_helpers.py +37 -0
  46. modelstudio-0.4.0/tests/test_creation_more.py +52 -0
  47. modelstudio-0.4.0/tests/test_data_split.py +32 -0
  48. modelstudio-0.4.0/tests/test_dtype_conversion.py +32 -0
  49. modelstudio-0.4.0/tests/test_indexing_assignment.py +45 -0
  50. modelstudio-0.4.0/tests/test_lr_scheduler.py +42 -0
  51. modelstudio-0.4.0/tests/test_manipulation_ops.py +64 -0
  52. modelstudio-0.4.0/tests/test_metrics.py +18 -0
  53. modelstudio-0.4.0/tests/test_numpy_interop.py +51 -0
  54. modelstudio-0.4.0/tests/test_optimizer_param_groups.py +48 -0
  55. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_version.py +1 -1
  56. modelstudio-0.3.0/python/modelstudio/_version.py +0 -1
  57. modelstudio-0.3.0/python/modelstudio/data/__init__.py +0 -4
  58. modelstudio-0.3.0/python/modelstudio/data/dataset.py +0 -30
  59. modelstudio-0.3.0/python/modelstudio/nn/activations.py +0 -29
  60. modelstudio-0.3.0/python/modelstudio/ops/creation.py +0 -90
  61. modelstudio-0.3.0/python/modelstudio/optim/__init__.py +0 -5
  62. modelstudio-0.3.0/python/modelstudio/optim/optimizer.py +0 -35
  63. {modelstudio-0.3.0 → modelstudio-0.4.0}/CMakeLists.txt +0 -0
  64. {modelstudio-0.3.0 → modelstudio-0.4.0}/LICENSE +0 -0
  65. {modelstudio-0.3.0 → modelstudio-0.4.0}/MANIFEST.in +0 -0
  66. {modelstudio-0.3.0 → modelstudio-0.4.0}/benchmarks/bench_attention.py +0 -0
  67. {modelstudio-0.3.0 → modelstudio-0.4.0}/benchmarks/bench_conv.py +0 -0
  68. {modelstudio-0.3.0 → modelstudio-0.4.0}/benchmarks/bench_dataloader.py +0 -0
  69. {modelstudio-0.3.0 → modelstudio-0.4.0}/benchmarks/bench_dropout.py +0 -0
  70. {modelstudio-0.3.0 → modelstudio-0.4.0}/benchmarks/bench_matmul.py +0 -0
  71. {modelstudio-0.3.0 → modelstudio-0.4.0}/benchmarks/bench_mlp.py +0 -0
  72. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/CMakeLists.txt +0 -0
  73. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/cpu/cpu_backend.cpp +0 -0
  74. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/cpu/cpu_backend.hpp +0 -0
  75. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/cpu/kernels/add.cpp +0 -0
  76. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/cpu/kernels/matmul.cpp +0 -0
  77. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/cpu/kernels/mul.cpp +0 -0
  78. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/cpu/kernels/relu.cpp +0 -0
  79. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/cuda/README.md +0 -0
  80. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/cuda/cuda_backend.cu +0 -0
  81. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/cuda/cuda_backend.hpp +0 -0
  82. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/cuda/cuda_memory.hpp +0 -0
  83. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/oneapi/README.md +0 -0
  84. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/oneapi/oneapi_backend.cpp +0 -0
  85. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/oneapi/oneapi_backend.hpp +0 -0
  86. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/oneapi/sycl_memory.hpp +0 -0
  87. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/rocm/README.md +0 -0
  88. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/rocm/hip_memory.hpp +0 -0
  89. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/rocm/rocm_backend.cpp +0 -0
  90. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/backends/rocm/rocm_backend.hpp +0 -0
  91. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/bindings/python_bindings.cpp +0 -0
  92. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/core/device.hpp +0 -0
  93. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/core/dtype.hpp +0 -0
  94. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/core/error.hpp +0 -0
  95. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/core/shape.hpp +0 -0
  96. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/core/storage.hpp +0 -0
  97. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/core/tensor.hpp +0 -0
  98. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/dispatcher/backend.hpp +0 -0
  99. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/dispatcher/dispatcher.hpp +0 -0
  100. {modelstudio-0.3.0 → modelstudio-0.4.0}/csrc/dispatcher/operator_registry.hpp +0 -0
  101. {modelstudio-0.3.0 → modelstudio-0.4.0}/docs/autograd.md +0 -0
  102. {modelstudio-0.3.0 → modelstudio-0.4.0}/docs/backend-architecture.md +0 -0
  103. {modelstudio-0.3.0 → modelstudio-0.4.0}/docs/modules.md +0 -0
  104. {modelstudio-0.3.0 → modelstudio-0.4.0}/docs/randomness.md +0 -0
  105. {modelstudio-0.3.0 → modelstudio-0.4.0}/docs/releasing.md +0 -0
  106. {modelstudio-0.3.0 → modelstudio-0.4.0}/docs/serialization.md +0 -0
  107. {modelstudio-0.3.0 → modelstudio-0.4.0}/examples/checkpoint_training.py +0 -0
  108. {modelstudio-0.3.0 → modelstudio-0.4.0}/examples/dropout_batchnorm.py +0 -0
  109. {modelstudio-0.3.0 → modelstudio-0.4.0}/examples/save_load.py +0 -0
  110. {modelstudio-0.3.0 → modelstudio-0.4.0}/examples/tiny_transformer.py +0 -0
  111. {modelstudio-0.3.0 → modelstudio-0.4.0}/examples/train_classifier.py +0 -0
  112. {modelstudio-0.3.0 → modelstudio-0.4.0}/examples/train_cnn_toy.py +0 -0
  113. {modelstudio-0.3.0 → modelstudio-0.4.0}/examples/train_mlp.py +0 -0
  114. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/autograd/__init__.py +0 -0
  115. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/autograd/engine.py +0 -0
  116. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/autograd/function.py +0 -0
  117. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/autograd/grad_mode.py +0 -0
  118. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/compile/__init__.py +0 -0
  119. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/compile/graph_capture.py +0 -0
  120. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/compile/ir.py +0 -0
  121. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/compile/passes.py +0 -0
  122. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/data/dataloader.py +0 -0
  123. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/device.py +0 -0
  124. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/dtypes.py +0 -0
  125. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/errors.py +0 -0
  126. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/nn/convolution.py +0 -0
  127. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/nn/embedding.py +0 -0
  128. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/nn/init.py +0 -0
  129. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/nn/linear.py +0 -0
  130. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/nn/losses.py +0 -0
  131. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/nn/module.py +0 -0
  132. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/nn/normalization.py +0 -0
  133. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/nn/parameter.py +0 -0
  134. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/nn/pooling.py +0 -0
  135. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/nn/transformer.py +0 -0
  136. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/nn/utils.py +0 -0
  137. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/ops/linalg.py +0 -0
  138. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/ops/reductions.py +0 -0
  139. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/py.typed +0 -0
  140. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/random.py +0 -0
  141. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/runtime/__init__.py +0 -0
  142. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/runtime/backend.py +0 -0
  143. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/runtime/dispatcher.py +0 -0
  144. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/storage.py +0 -0
  145. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/testing/__init__.py +0 -0
  146. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio/testing/gradcheck.py +0 -0
  147. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio.egg-info/dependency_links.txt +0 -0
  148. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio.egg-info/requires.txt +0 -0
  149. {modelstudio-0.3.0 → modelstudio-0.4.0}/python/modelstudio.egg-info/top_level.txt +0 -0
  150. {modelstudio-0.3.0 → modelstudio-0.4.0}/setup.cfg +0 -0
  151. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_attention.py +0 -0
  152. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_autograd.py +0 -0
  153. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_batchnorm.py +0 -0
  154. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_buffers.py +0 -0
  155. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_concat_stack.py +0 -0
  156. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_conv.py +0 -0
  157. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_data.py +0 -0
  158. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_dataloader_seed.py +0 -0
  159. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_dispatcher.py +0 -0
  160. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_dropout.py +0 -0
  161. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_embedding.py +0 -0
  162. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_grad_clip.py +0 -0
  163. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_gradcheck.py +0 -0
  164. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_indexing.py +0 -0
  165. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_init.py +0 -0
  166. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_loss_reductions.py +0 -0
  167. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_losses.py +0 -0
  168. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_module_ergonomics.py +0 -0
  169. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_nn.py +0 -0
  170. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_norms.py +0 -0
  171. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_ops.py +0 -0
  172. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_optim.py +0 -0
  173. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_optimizer_state.py +0 -0
  174. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_pooling.py +0 -0
  175. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_random.py +0 -0
  176. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_reductions_axis.py +0 -0
  177. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_serialization.py +0 -0
  178. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_shape_ops.py +0 -0
  179. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_state_dict.py +0 -0
  180. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_tensor.py +0 -0
  181. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_transformer.py +0 -0
  182. {modelstudio-0.3.0 → modelstudio-0.4.0}/tests/test_unary_ops.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modelstudio
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: An early-stage AI tensor framework with CPU tensors, autograd, and backend extension scaffolding.
5
5
  Author: ModelStudio Contributors
6
6
  License-Expression: MIT
@@ -31,7 +31,7 @@ Dynamic: license-file
31
31
 
32
32
  # ModelStudio
33
33
 
34
- ModelStudio is an early-stage AI tensor framework. Version `0.3.0` provides a
34
+ ModelStudio is an early-stage AI tensor framework. Version `0.4.0` provides a
35
35
  CPU tensor/autograd MVP with neural-network modules, optimizers, serialization,
36
36
  basic data loading, and small LLM-oriented building blocks.
37
37
 
@@ -60,13 +60,15 @@ python -m pip install -e ".[dev]"
60
60
  | CPU tensors | Working MVP |
61
61
  | Autograd | Reverse-mode for core CPU ops |
62
62
  | Reductions | `sum`, `mean`, `max` with axis and keepdims; `max` is value-only |
63
- | Activations | ReLU, GELU, exp, log, tanh, sigmoid, SiLU, softmax, log-softmax |
63
+ | Activations | ReLU, GELU, LeakyReLU, ELU, Softplus, exp, log, tanh, sigmoid, SiLU, softmax, log-softmax |
64
64
  | Losses | MSE and cross entropy with `none`, `mean`, and `sum` reductions |
65
65
  | Modules | Parameters, buffers, child traversal, state dicts, save/load |
66
66
  | Layers | Linear, Embedding, LayerNorm, RMSNorm, BatchNorm1d, Dropout, Conv1d, Conv2d, pooling, TransformerBlock |
67
- | Optimizers | SGD and AdamW with state serialization |
68
- | Data | Dataset, TensorDataset, DataLoader with deterministic seeded shuffle |
67
+ | Optimizers | SGD and AdamW with state serialization, parameter groups, and LR schedulers |
68
+ | Data | Dataset, TensorDataset, random_split, DataLoader with deterministic seeded shuffle |
69
69
  | Randomness | `manual_seed`, RNG-backed `randn`, dropout, and init helpers |
70
+ | Interop | `asarray`, `from_numpy`, `to_numpy`, and `ms.numpy` |
71
+ | Metrics | accuracy and top-k accuracy |
70
72
  | Compiler | Placeholder IR and passes |
71
73
 
72
74
  ## Backend Status
@@ -165,7 +167,7 @@ y = block(x)
165
167
  print(y.shape)
166
168
  ```
167
169
 
168
- ## 0.3.0 Training Utilities
170
+ ## 0.4.0 Training Utilities
169
171
 
170
172
  ```python
171
173
  ms.manual_seed(123)
@@ -180,6 +182,34 @@ New CPU-only helpers include `ms.concat`, `ms.stack`, `Tensor.flatten`,
180
182
  `nn.BatchNorm1d`, `nn.Conv1d`, `nn.Conv2d`, `nn.AvgPool2d`, `nn.MaxPool2d`,
181
183
  and `nn.utils` gradient clipping.
182
184
 
185
+ ## NumPy Interop
186
+
187
+ ```python
188
+ x = ms.asarray([[1, 2, 3], [4, 5, 6]], dtype=ms.float32)
189
+ arr = ms.to_numpy(x)
190
+ y = ms.from_numpy(arr)
191
+ ```
192
+
193
+ CPU uses NumPy internally. Normal examples prefer ModelStudio APIs; `ms.numpy`
194
+ is exposed for advanced users who explicitly want NumPy access.
195
+
196
+ ## Schedulers and Metrics
197
+
198
+ ```python
199
+ optimizer = ms.optim.AdamW(model.parameters(), lr=1e-3)
200
+ scheduler = ms.optim.lr_scheduler.StepLR(optimizer, step_size=1, gamma=0.5)
201
+ scheduler.step()
202
+
203
+ acc = ms.metrics.accuracy(logits, targets)
204
+ ```
205
+
206
+ ## Checkpointing
207
+
208
+ ```python
209
+ ms.save_checkpoint("checkpoint.ms", model=model, optimizer=optimizer, scheduler=scheduler, extra={"epoch": 1})
210
+ checkpoint = ms.load_checkpoint("checkpoint.ms", model=model, optimizer=optimizer, scheduler=scheduler)
211
+ ```
212
+
183
213
  ## Commands
184
214
 
185
215
  ```bash
@@ -192,12 +222,18 @@ python examples/save_load.py
192
222
  python examples/train_cnn_toy.py
193
223
  python examples/dropout_batchnorm.py
194
224
  python examples/checkpoint_training.py
225
+ python examples/numpy_interop.py
226
+ python examples/scheduler_training.py
227
+ python examples/checkpoint_resume.py
228
+ python examples/metrics_demo.py
195
229
  python benchmarks/bench_matmul.py
196
230
  python benchmarks/bench_mlp.py
197
231
  python benchmarks/bench_attention.py
198
232
  python benchmarks/bench_dataloader.py
199
233
  python benchmarks/bench_conv.py
200
234
  python benchmarks/bench_dropout.py
235
+ python benchmarks/bench_creation.py
236
+ python benchmarks/bench_manipulation.py
201
237
  ```
202
238
 
203
239
  ## Documentation
@@ -210,6 +246,12 @@ python benchmarks/bench_dropout.py
210
246
  - [Serialization](docs/serialization.md)
211
247
  - [Randomness](docs/randomness.md)
212
248
  - [Native backend roadmap](docs/native-backend-roadmap.md)
249
+ - [NumPy interop](docs/numpy-interop.md)
250
+ - [Tensor creation](docs/tensor-creation.md)
251
+ - [Tensor manipulation](docs/tensor-manipulation.md)
252
+ - [Optimizers](docs/optimizers.md)
253
+ - [Checkpointing](docs/checkpointing.md)
254
+ - [Metrics](docs/metrics.md)
213
255
  - [Backend architecture](docs/backend-architecture.md)
214
256
  - [Autograd design](docs/autograd.md)
215
257
  - [Releasing](docs/releasing.md)
@@ -1,6 +1,6 @@
1
1
  # ModelStudio
2
2
 
3
- ModelStudio is an early-stage AI tensor framework. Version `0.3.0` provides a
3
+ ModelStudio is an early-stage AI tensor framework. Version `0.4.0` provides a
4
4
  CPU tensor/autograd MVP with neural-network modules, optimizers, serialization,
5
5
  basic data loading, and small LLM-oriented building blocks.
6
6
 
@@ -29,13 +29,15 @@ python -m pip install -e ".[dev]"
29
29
  | CPU tensors | Working MVP |
30
30
  | Autograd | Reverse-mode for core CPU ops |
31
31
  | Reductions | `sum`, `mean`, `max` with axis and keepdims; `max` is value-only |
32
- | Activations | ReLU, GELU, exp, log, tanh, sigmoid, SiLU, softmax, log-softmax |
32
+ | Activations | ReLU, GELU, LeakyReLU, ELU, Softplus, exp, log, tanh, sigmoid, SiLU, softmax, log-softmax |
33
33
  | Losses | MSE and cross entropy with `none`, `mean`, and `sum` reductions |
34
34
  | Modules | Parameters, buffers, child traversal, state dicts, save/load |
35
35
  | Layers | Linear, Embedding, LayerNorm, RMSNorm, BatchNorm1d, Dropout, Conv1d, Conv2d, pooling, TransformerBlock |
36
- | Optimizers | SGD and AdamW with state serialization |
37
- | Data | Dataset, TensorDataset, DataLoader with deterministic seeded shuffle |
36
+ | Optimizers | SGD and AdamW with state serialization, parameter groups, and LR schedulers |
37
+ | Data | Dataset, TensorDataset, random_split, DataLoader with deterministic seeded shuffle |
38
38
  | Randomness | `manual_seed`, RNG-backed `randn`, dropout, and init helpers |
39
+ | Interop | `asarray`, `from_numpy`, `to_numpy`, and `ms.numpy` |
40
+ | Metrics | accuracy and top-k accuracy |
39
41
  | Compiler | Placeholder IR and passes |
40
42
 
41
43
  ## Backend Status
@@ -134,7 +136,7 @@ y = block(x)
134
136
  print(y.shape)
135
137
  ```
136
138
 
137
- ## 0.3.0 Training Utilities
139
+ ## 0.4.0 Training Utilities
138
140
 
139
141
  ```python
140
142
  ms.manual_seed(123)
@@ -149,6 +151,34 @@ New CPU-only helpers include `ms.concat`, `ms.stack`, `Tensor.flatten`,
149
151
  `nn.BatchNorm1d`, `nn.Conv1d`, `nn.Conv2d`, `nn.AvgPool2d`, `nn.MaxPool2d`,
150
152
  and `nn.utils` gradient clipping.
151
153
 
154
+ ## NumPy Interop
155
+
156
+ ```python
157
+ x = ms.asarray([[1, 2, 3], [4, 5, 6]], dtype=ms.float32)
158
+ arr = ms.to_numpy(x)
159
+ y = ms.from_numpy(arr)
160
+ ```
161
+
162
+ CPU uses NumPy internally. Normal examples prefer ModelStudio APIs; `ms.numpy`
163
+ is exposed for advanced users who explicitly want NumPy access.
164
+
165
+ ## Schedulers and Metrics
166
+
167
+ ```python
168
+ optimizer = ms.optim.AdamW(model.parameters(), lr=1e-3)
169
+ scheduler = ms.optim.lr_scheduler.StepLR(optimizer, step_size=1, gamma=0.5)
170
+ scheduler.step()
171
+
172
+ acc = ms.metrics.accuracy(logits, targets)
173
+ ```
174
+
175
+ ## Checkpointing
176
+
177
+ ```python
178
+ ms.save_checkpoint("checkpoint.ms", model=model, optimizer=optimizer, scheduler=scheduler, extra={"epoch": 1})
179
+ checkpoint = ms.load_checkpoint("checkpoint.ms", model=model, optimizer=optimizer, scheduler=scheduler)
180
+ ```
181
+
152
182
  ## Commands
153
183
 
154
184
  ```bash
@@ -161,12 +191,18 @@ python examples/save_load.py
161
191
  python examples/train_cnn_toy.py
162
192
  python examples/dropout_batchnorm.py
163
193
  python examples/checkpoint_training.py
194
+ python examples/numpy_interop.py
195
+ python examples/scheduler_training.py
196
+ python examples/checkpoint_resume.py
197
+ python examples/metrics_demo.py
164
198
  python benchmarks/bench_matmul.py
165
199
  python benchmarks/bench_mlp.py
166
200
  python benchmarks/bench_attention.py
167
201
  python benchmarks/bench_dataloader.py
168
202
  python benchmarks/bench_conv.py
169
203
  python benchmarks/bench_dropout.py
204
+ python benchmarks/bench_creation.py
205
+ python benchmarks/bench_manipulation.py
170
206
  ```
171
207
 
172
208
  ## Documentation
@@ -179,6 +215,12 @@ python benchmarks/bench_dropout.py
179
215
  - [Serialization](docs/serialization.md)
180
216
  - [Randomness](docs/randomness.md)
181
217
  - [Native backend roadmap](docs/native-backend-roadmap.md)
218
+ - [NumPy interop](docs/numpy-interop.md)
219
+ - [Tensor creation](docs/tensor-creation.md)
220
+ - [Tensor manipulation](docs/tensor-manipulation.md)
221
+ - [Optimizers](docs/optimizers.md)
222
+ - [Checkpointing](docs/checkpointing.md)
223
+ - [Metrics](docs/metrics.md)
182
224
  - [Backend architecture](docs/backend-architecture.md)
183
225
  - [Autograd design](docs/autograd.md)
184
226
  - [Releasing](docs/releasing.md)
@@ -0,0 +1,38 @@
1
+ from __future__ import annotations
2
+
3
+ import platform
4
+ import time
5
+
6
+ import modelstudio as ms
7
+ import numpy as np
8
+
9
+
10
+ def timeit(fn, iterations: int, warmup: int) -> float:
11
+ for _ in range(warmup):
12
+ fn()
13
+ start = time.perf_counter()
14
+ for _ in range(iterations):
15
+ fn()
16
+ return (time.perf_counter() - start) / iterations
17
+
18
+
19
+ def main() -> None:
20
+ warmup = 5
21
+ iterations = 50
22
+ shape = (512, 512)
23
+
24
+ print(f"Python: {platform.python_version()}")
25
+ print(f"NumPy: {np.__version__}")
26
+ print(f"ModelStudio: {ms.__version__}")
27
+ print(f"Operation: rand/full/eye shape={shape}")
28
+ print(f"Warmup: {warmup}")
29
+ print(f"Iterations: {iterations}")
30
+ print("Backend: CPU only")
31
+ print(f"rand avg: {timeit(lambda: ms.rand(shape), iterations, warmup) * 1_000:.3f} ms")
32
+ print(f"full avg: {timeit(lambda: ms.full(shape, 1.25), iterations, warmup) * 1_000:.3f} ms")
33
+ print(f"eye avg: {timeit(lambda: ms.eye(512), iterations, warmup) * 1_000:.3f} ms")
34
+
35
+
36
+ if __name__ == "__main__":
37
+ main()
38
+
@@ -0,0 +1,38 @@
1
+ from __future__ import annotations
2
+
3
+ import platform
4
+ import time
5
+
6
+ import modelstudio as ms
7
+ import numpy as np
8
+
9
+
10
+ def timeit(fn, iterations: int, warmup: int) -> float:
11
+ for _ in range(warmup):
12
+ fn()
13
+ start = time.perf_counter()
14
+ for _ in range(iterations):
15
+ fn()
16
+ return (time.perf_counter() - start) / iterations
17
+
18
+
19
+ def main() -> None:
20
+ warmup = 5
21
+ iterations = 50
22
+ x = ms.randn((64, 64, 8))
23
+
24
+ print(f"Python: {platform.python_version()}")
25
+ print(f"NumPy: {np.__version__}")
26
+ print(f"ModelStudio: {ms.__version__}")
27
+ print("Operation: permute/repeat/tile")
28
+ print(f"Warmup: {warmup}")
29
+ print(f"Iterations: {iterations}")
30
+ print("Backend: CPU only")
31
+ print(f"permute avg: {timeit(lambda: ms.permute(x, (2, 0, 1)), iterations, warmup) * 1_000:.3f} ms")
32
+ print(f"repeat avg: {timeit(lambda: ms.repeat(x, 2, axis=0), iterations, warmup) * 1_000:.3f} ms")
33
+ print(f"tile avg: {timeit(lambda: ms.tile(x, (2, 1, 1)), iterations, warmup) * 1_000:.3f} ms")
34
+
35
+
36
+ if __name__ == "__main__":
37
+ main()
38
+
@@ -0,0 +1,30 @@
1
+ # Checkpointing
2
+
3
+ High-level checkpoint helpers wrap `ms.save` and `ms.load`.
4
+
5
+ ```python
6
+ ms.save_checkpoint(
7
+ "checkpoint.ms",
8
+ model=model,
9
+ optimizer=optimizer,
10
+ scheduler=scheduler,
11
+ extra={"epoch": 3},
12
+ )
13
+
14
+ checkpoint = ms.load_checkpoint(
15
+ "checkpoint.ms",
16
+ model=model,
17
+ optimizer=optimizer,
18
+ scheduler=scheduler,
19
+ )
20
+ ```
21
+
22
+ The checkpoint dictionary contains:
23
+
24
+ - `model`
25
+ - optional `optimizer`
26
+ - optional `scheduler`
27
+ - `extra`
28
+
29
+ The file format is currently ModelStudio's internal pickle-backed format.
30
+
@@ -31,3 +31,12 @@ The current `DataLoader` is intentionally simple:
31
31
  - deterministic shuffle when `seed` is provided
32
32
  - supports tensors, tuples/lists, and simple Python numeric values
33
33
  - batches along axis 0
34
+
35
+ ## random_split
36
+
37
+ ```python
38
+ train_set, valid_set = data.random_split(dataset, [80, 20], seed=123)
39
+ ```
40
+
41
+ Split lengths must sum to the dataset length. When `seed` is supplied, split
42
+ order is deterministic.
@@ -0,0 +1,11 @@
1
+ # Metrics
2
+
3
+ ModelStudio includes small CPU metrics for training loops.
4
+
5
+ ```python
6
+ acc = ms.metrics.accuracy(logits, targets)
7
+ top5 = ms.metrics.top_k_accuracy(logits, targets, k=5)
8
+ ```
9
+
10
+ Metrics accept Tensor inputs and return Python floats.
11
+
@@ -1,6 +1,6 @@
1
1
  # Native Backend Roadmap
2
2
 
3
- The Python runtime still uses NumPy CPU kernels in 0.3.0. The native C++ tree is
3
+ The Python runtime still uses NumPy CPU kernels in 0.4.0. The native C++ tree is
4
4
  scaffolding for future backend work and is intentionally not wired into Python
5
5
  dispatch yet.
6
6
 
@@ -23,4 +23,3 @@ The intended path is:
23
23
 
24
24
  CUDA, ROCm, and oneAPI remain unavailable placeholders. Requesting those device
25
25
  types raises `ModelStudioBackendUnavailable`.
26
-
@@ -45,6 +45,9 @@ Current CPU layers include:
45
45
  - `TransformerBlock`
46
46
  - `ReLU`
47
47
  - `GELU`
48
+ - `LeakyReLU`
49
+ - `ELU`
50
+ - `Softplus`
48
51
  - `MSELoss`
49
52
  - `CrossEntropyLoss`
50
53
 
@@ -0,0 +1,22 @@
1
+ # NumPy Interop
2
+
3
+ ModelStudio CPU tensors use NumPy internally, but normal user code does not need
4
+ to import NumPy directly.
5
+
6
+ ```python
7
+ import modelstudio as ms
8
+
9
+ x = ms.asarray([[1, 2], [3, 4]], dtype=ms.float32)
10
+ arr = ms.to_numpy(x)
11
+ y = ms.from_numpy(arr)
12
+ ```
13
+
14
+ APIs:
15
+
16
+ - `ms.asarray(obj, dtype=None, device="cpu")`
17
+ - `ms.from_numpy(array, copy=True, requires_grad=False)`
18
+ - `ms.to_numpy(obj)`
19
+ - `ms.numpy` for advanced users who explicitly want NumPy access
20
+
21
+ `Tensor.numpy()` remains supported and returns a copy.
22
+
@@ -0,0 +1,28 @@
1
+ # Optimizers
2
+
3
+ ModelStudio includes `SGD` and `AdamW`.
4
+
5
+ Flat parameter lists still work:
6
+
7
+ ```python
8
+ optimizer = ms.optim.AdamW(model.parameters(), lr=1e-3)
9
+ ```
10
+
11
+ Parameter groups are supported:
12
+
13
+ ```python
14
+ optimizer = ms.optim.AdamW([
15
+ {"params": model.fc1.parameters(), "lr": 1e-3},
16
+ {"params": model.fc2.parameters(), "lr": 1e-4, "weight_decay": 0.01},
17
+ ])
18
+ ```
19
+
20
+ Schedulers live under `ms.optim.lr_scheduler`:
21
+
22
+ - `StepLR`
23
+ - `ExponentialLR`
24
+ - `CosineAnnealingLR`
25
+
26
+ Schedulers support `step()`, `get_last_lr()`, `state_dict()`, and
27
+ `load_state_dict()`.
28
+
@@ -38,8 +38,13 @@ y = x.sum(axis=-1, keepdims=True)
38
38
  z = x.softmax(axis=-1)
39
39
  flat = x.flatten(start_dim=1)
40
40
  joined = ms.concat([flat, flat], axis=-1)
41
+ mask = ms.where(ms.ones_like(joined, dtype=ms.bool), joined, ms.zeros_like(joined))
41
42
  ```
42
43
 
44
+ Creation helpers added in 0.4.0 include `full`, `*_like`, `eye`, `linspace`,
45
+ `rand`, and `randint`. Manipulation helpers include `permute`, `swapaxes`,
46
+ `broadcast_to`, `repeat`, `tile`, and `where`.
47
+
43
48
  Autograd is implemented for the core CPU ops used by the neural-network API.
44
49
  `max` is available as a value operation, but its result does not currently track
45
50
  gradients.
@@ -0,0 +1,23 @@
1
+ # Tensor Creation
2
+
3
+ ModelStudio 0.4.0 expands CPU tensor creation utilities:
4
+
5
+ - `tensor`
6
+ - `empty`, `zeros`, `ones`, `full`
7
+ - `empty_like`, `zeros_like`, `ones_like`, `full_like`
8
+ - `randn`, `rand`, `randint`
9
+ - `arange`, `linspace`, `eye`
10
+
11
+ Random functions use `ms.manual_seed`.
12
+
13
+ ```python
14
+ import modelstudio as ms
15
+
16
+ ms.manual_seed(123)
17
+ x = ms.rand((2, 3))
18
+ y = ms.randint(0, 10, shape=(2, 3))
19
+ z = ms.eye(3)
20
+ ```
21
+
22
+ Only floating tensors may require gradients.
23
+
@@ -0,0 +1,25 @@
1
+ # Tensor Manipulation
2
+
3
+ ModelStudio supports common CPU tensor manipulation with autograd where the
4
+ operation is differentiable:
5
+
6
+ - `permute`
7
+ - `swapaxes`
8
+ - `broadcast_to`
9
+ - `repeat`
10
+ - `tile`
11
+ - `where`
12
+ - `concat` / `cat`
13
+ - `stack`
14
+ - `flatten`, `squeeze`, `unsqueeze`
15
+
16
+ ```python
17
+ x = ms.randn((2, 3, 4), requires_grad=True)
18
+ y = x.permute((2, 0, 1)).repeat(2, axis=0)
19
+ loss = y.mean()
20
+ loss.backward()
21
+ ```
22
+
23
+ `where` propagates gradients to the selected `x` and `y` values, not to the
24
+ condition.
25
+
@@ -1,6 +1,6 @@
1
1
  # Training
2
2
 
3
- ModelStudio 0.3.0 supports CPU-only training loops with modules, optimizers,
3
+ ModelStudio 0.4.0 supports CPU-only training loops with modules, optimizers,
4
4
  loss functions, DataLoader batching, dropout, BatchNorm1d, and checkpointing.
5
5
 
6
6
  ```python
@@ -26,4 +26,3 @@ Dropout masks are active only in training mode. BatchNorm1d updates running
26
26
  statistics only in training mode and reads those buffers in eval mode.
27
27
 
28
28
  Loss reductions support `none`, `mean`, and `sum` for MSE and cross entropy.
29
-
@@ -0,0 +1,43 @@
1
+ from __future__ import annotations
2
+
3
+ import tempfile
4
+ from pathlib import Path
5
+
6
+ import modelstudio as ms
7
+ from modelstudio import nn, optim
8
+
9
+
10
+ def main() -> None:
11
+ ms.manual_seed(33)
12
+ model = nn.Linear(3, 2)
13
+ optimizer = optim.AdamW(model.parameters(), lr=1e-2)
14
+ scheduler = optim.lr_scheduler.ExponentialLR(optimizer, gamma=0.9)
15
+ x = ms.randn((8, 3))
16
+ target = ms.randint(0, 2, shape=(8,))
17
+
18
+ loss = ms.cross_entropy(model(x), target)
19
+ optimizer.zero_grad()
20
+ loss.backward()
21
+ optimizer.step()
22
+ scheduler.step()
23
+
24
+ with tempfile.TemporaryDirectory() as tmpdir:
25
+ path = Path(tmpdir) / "checkpoint.ms"
26
+ ms.save_checkpoint(path, model=model, optimizer=optimizer, scheduler=scheduler, extra={"epoch": 1})
27
+ restored = nn.Linear(3, 2)
28
+ restored_optimizer = optim.AdamW(restored.parameters(), lr=1e-3)
29
+ restored_scheduler = optim.lr_scheduler.ExponentialLR(restored_optimizer, gamma=0.1)
30
+ checkpoint = ms.load_checkpoint(
31
+ path,
32
+ model=restored,
33
+ optimizer=restored_optimizer,
34
+ scheduler=restored_scheduler,
35
+ )
36
+
37
+ print(f"extra={checkpoint['extra']}")
38
+ print(f"restored_lr={restored_scheduler.get_last_lr()[0]:.6f}")
39
+
40
+
41
+ if __name__ == "__main__":
42
+ main()
43
+
@@ -0,0 +1,20 @@
1
+ from __future__ import annotations
2
+
3
+ import modelstudio as ms
4
+ from modelstudio import nn
5
+
6
+
7
+ def main() -> None:
8
+ ms.manual_seed(99)
9
+ model = nn.Linear(5, 4)
10
+ x = ms.randn((10, 5))
11
+ target = ms.randint(0, 4, shape=(10,))
12
+ logits = model(x)
13
+
14
+ print(f"accuracy={ms.metrics.accuracy(logits, target):.3f}")
15
+ print(f"top2_accuracy={ms.metrics.top_k_accuracy(logits, target, k=2):.3f}")
16
+
17
+
18
+ if __name__ == "__main__":
19
+ main()
20
+
@@ -0,0 +1,21 @@
1
+ from __future__ import annotations
2
+
3
+ import modelstudio as ms
4
+ import numpy as np
5
+
6
+
7
+ def main() -> None:
8
+ arr = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float32)
9
+ x = ms.from_numpy(arr)
10
+ y = ms.asarray([[10, 20, 30], [40, 50, 60]], dtype=ms.float32)
11
+ out = x + y
12
+
13
+ print(f"version={ms.__version__}")
14
+ print(f"tensor_shape={out.shape}")
15
+ print(f"numpy_sum={ms.to_numpy(out).sum():.1f}")
16
+ print(f"advanced_namespace_shape={ms.numpy.zeros((2, 2)).shape}")
17
+
18
+
19
+ if __name__ == "__main__":
20
+ main()
21
+
@@ -0,0 +1,27 @@
1
+ from __future__ import annotations
2
+
3
+ import modelstudio as ms
4
+ from modelstudio import nn, optim
5
+
6
+
7
+ def main() -> None:
8
+ ms.manual_seed(12)
9
+ model = nn.Linear(4, 3)
10
+ optimizer = optim.AdamW(model.parameters(), lr=1e-2)
11
+ scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=1, gamma=0.5)
12
+ x = ms.randn((12, 4))
13
+ target = ms.randint(0, 3, shape=(12,))
14
+
15
+ for epoch in range(3):
16
+ logits = model(x)
17
+ loss = ms.cross_entropy(logits, target)
18
+ optimizer.zero_grad()
19
+ loss.backward()
20
+ optimizer.step()
21
+ scheduler.step()
22
+ print(f"epoch={epoch} loss={loss.item():.6f} lr={scheduler.get_last_lr()[0]:.6f}")
23
+
24
+
25
+ if __name__ == "__main__":
26
+ main()
27
+
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "modelstudio"
7
- version = "0.3.0"
7
+ version = "0.4.0"
8
8
  description = "An early-stage AI tensor framework with CPU tensors, autograd, and backend extension scaffolding."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"