modelstudio 0.3.0__tar.gz → 0.5.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.
- modelstudio-0.5.0/PKG-INFO +241 -0
- modelstudio-0.5.0/README.md +210 -0
- modelstudio-0.5.0/benchmarks/bench_creation.py +38 -0
- modelstudio-0.5.0/benchmarks/bench_elementwise.py +44 -0
- modelstudio-0.5.0/benchmarks/bench_manipulation.py +38 -0
- modelstudio-0.5.0/benchmarks/bench_trace.py +47 -0
- modelstudio-0.5.0/docs/backend-status.md +21 -0
- modelstudio-0.5.0/docs/checkpointing.md +30 -0
- modelstudio-0.5.0/docs/comparison-ops.md +23 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/docs/data.md +9 -0
- modelstudio-0.5.0/docs/functional-api.md +22 -0
- modelstudio-0.5.0/docs/linalg.md +23 -0
- modelstudio-0.5.0/docs/metrics.md +11 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/docs/native-backend-roadmap.md +12 -2
- {modelstudio-0.3.0 → modelstudio-0.5.0}/docs/nn.md +3 -0
- modelstudio-0.5.0/docs/numpy-interop.md +22 -0
- modelstudio-0.5.0/docs/optimizers.md +28 -0
- modelstudio-0.5.0/docs/random.md +26 -0
- modelstudio-0.5.0/docs/serialization.md +34 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/docs/tensor-api.md +5 -0
- modelstudio-0.5.0/docs/tensor-creation.md +22 -0
- modelstudio-0.5.0/docs/tensor-manipulation.md +25 -0
- modelstudio-0.5.0/docs/tracing.md +21 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/docs/training.md +1 -2
- modelstudio-0.5.0/examples/backend_status.py +16 -0
- modelstudio-0.5.0/examples/checkpoint_resume.py +43 -0
- modelstudio-0.5.0/examples/functional_training.py +35 -0
- modelstudio-0.5.0/examples/metrics_demo.py +20 -0
- modelstudio-0.5.0/examples/numpy_interop.py +21 -0
- modelstudio-0.5.0/examples/random_linalg_demo.py +20 -0
- modelstudio-0.5.0/examples/scheduler_training.py +27 -0
- modelstudio-0.5.0/examples/tracing_demo.py +20 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/pyproject.toml +1 -1
- modelstudio-0.5.0/python/modelstudio/__init__.py +155 -0
- modelstudio-0.5.0/python/modelstudio/_version.py +1 -0
- modelstudio-0.5.0/python/modelstudio/backends/__init__.py +4 -0
- modelstudio-0.5.0/python/modelstudio/backends/status.py +62 -0
- modelstudio-0.5.0/python/modelstudio/compile/graph_capture.py +83 -0
- modelstudio-0.5.0/python/modelstudio/compile/ir.py +62 -0
- modelstudio-0.5.0/python/modelstudio/data/__init__.py +4 -0
- modelstudio-0.5.0/python/modelstudio/data/dataset.py +59 -0
- modelstudio-0.5.0/python/modelstudio/interop.py +41 -0
- modelstudio-0.5.0/python/modelstudio/linalg.py +32 -0
- modelstudio-0.5.0/python/modelstudio/metrics/__init__.py +4 -0
- modelstudio-0.5.0/python/modelstudio/metrics/classification.py +19 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/nn/__init__.py +6 -2
- modelstudio-0.5.0/python/modelstudio/nn/activations.py +57 -0
- modelstudio-0.5.0/python/modelstudio/nn/functional.py +162 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/nn/module.py +6 -1
- modelstudio-0.5.0/python/modelstudio/ops/__init__.py +116 -0
- modelstudio-0.5.0/python/modelstudio/ops/comparison.py +77 -0
- modelstudio-0.5.0/python/modelstudio/ops/creation.py +251 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/ops/linalg.py +5 -1
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/ops/math.py +78 -2
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/ops/movement.py +140 -0
- modelstudio-0.5.0/python/modelstudio/optim/__init__.py +7 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/optim/adamw.py +43 -28
- modelstudio-0.5.0/python/modelstudio/optim/lr_scheduler.py +114 -0
- modelstudio-0.5.0/python/modelstudio/optim/optimizer.py +98 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/optim/sgd.py +20 -8
- modelstudio-0.5.0/python/modelstudio/random.py +120 -0
- modelstudio-0.5.0/python/modelstudio/serialization.py +124 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/tensor.py +123 -2
- modelstudio-0.5.0/python/modelstudio.egg-info/PKG-INFO +241 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio.egg-info/SOURCES.txt +55 -0
- modelstudio-0.5.0/scripts/smoke_test.py +92 -0
- modelstudio-0.5.0/tests/test_activations_more.py +42 -0
- modelstudio-0.5.0/tests/test_backend_status.py +39 -0
- modelstudio-0.5.0/tests/test_checkpoint_helpers.py +37 -0
- modelstudio-0.5.0/tests/test_clone_copy.py +42 -0
- modelstudio-0.5.0/tests/test_comparison_ops.py +55 -0
- modelstudio-0.5.0/tests/test_creation_more.py +52 -0
- modelstudio-0.5.0/tests/test_data_split.py +32 -0
- modelstudio-0.5.0/tests/test_dtype_conversion.py +32 -0
- modelstudio-0.5.0/tests/test_functional.py +113 -0
- modelstudio-0.5.0/tests/test_indexing_assignment.py +45 -0
- modelstudio-0.5.0/tests/test_linalg.py +36 -0
- modelstudio-0.5.0/tests/test_lr_scheduler.py +42 -0
- modelstudio-0.5.0/tests/test_manipulation_ops.py +64 -0
- modelstudio-0.5.0/tests/test_metrics.py +18 -0
- modelstudio-0.5.0/tests/test_native_cpu_mode.py +35 -0
- modelstudio-0.5.0/tests/test_numpy_interop.py +51 -0
- modelstudio-0.5.0/tests/test_optimizer_param_groups.py +48 -0
- modelstudio-0.5.0/tests/test_public_exports.py +27 -0
- modelstudio-0.5.0/tests/test_random_namespace.py +45 -0
- modelstudio-0.5.0/tests/test_scalar_behavior.py +41 -0
- modelstudio-0.5.0/tests/test_serialization_hardening.py +77 -0
- modelstudio-0.5.0/tests/test_trace.py +60 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_version.py +1 -1
- modelstudio-0.3.0/PKG-INFO +0 -223
- modelstudio-0.3.0/README.md +0 -192
- modelstudio-0.3.0/docs/serialization.md +0 -25
- modelstudio-0.3.0/python/modelstudio/__init__.py +0 -76
- modelstudio-0.3.0/python/modelstudio/_version.py +0 -1
- modelstudio-0.3.0/python/modelstudio/compile/graph_capture.py +0 -12
- modelstudio-0.3.0/python/modelstudio/compile/ir.py +0 -37
- modelstudio-0.3.0/python/modelstudio/data/__init__.py +0 -4
- modelstudio-0.3.0/python/modelstudio/data/dataset.py +0 -30
- modelstudio-0.3.0/python/modelstudio/nn/activations.py +0 -29
- modelstudio-0.3.0/python/modelstudio/ops/__init__.py +0 -58
- modelstudio-0.3.0/python/modelstudio/ops/creation.py +0 -90
- modelstudio-0.3.0/python/modelstudio/optim/__init__.py +0 -5
- modelstudio-0.3.0/python/modelstudio/optim/optimizer.py +0 -35
- modelstudio-0.3.0/python/modelstudio/random.py +0 -20
- modelstudio-0.3.0/python/modelstudio/serialization.py +0 -63
- modelstudio-0.3.0/python/modelstudio.egg-info/PKG-INFO +0 -223
- modelstudio-0.3.0/scripts/smoke_test.py +0 -51
- {modelstudio-0.3.0 → modelstudio-0.5.0}/CMakeLists.txt +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/LICENSE +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/MANIFEST.in +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/benchmarks/bench_attention.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/benchmarks/bench_conv.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/benchmarks/bench_dataloader.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/benchmarks/bench_dropout.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/benchmarks/bench_matmul.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/benchmarks/bench_mlp.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/CMakeLists.txt +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/cpu/cpu_backend.cpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/cpu/cpu_backend.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/cpu/kernels/add.cpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/cpu/kernels/matmul.cpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/cpu/kernels/mul.cpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/cpu/kernels/relu.cpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/cuda/README.md +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/cuda/cuda_backend.cu +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/cuda/cuda_backend.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/cuda/cuda_memory.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/oneapi/README.md +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/oneapi/oneapi_backend.cpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/oneapi/oneapi_backend.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/oneapi/sycl_memory.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/rocm/README.md +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/rocm/hip_memory.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/rocm/rocm_backend.cpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/backends/rocm/rocm_backend.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/bindings/python_bindings.cpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/core/device.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/core/dtype.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/core/error.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/core/shape.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/core/storage.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/core/tensor.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/dispatcher/backend.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/dispatcher/dispatcher.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/csrc/dispatcher/operator_registry.hpp +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/docs/autograd.md +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/docs/backend-architecture.md +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/docs/modules.md +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/docs/randomness.md +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/docs/releasing.md +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/examples/checkpoint_training.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/examples/dropout_batchnorm.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/examples/save_load.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/examples/tiny_transformer.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/examples/train_classifier.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/examples/train_cnn_toy.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/examples/train_mlp.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/autograd/__init__.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/autograd/engine.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/autograd/function.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/autograd/grad_mode.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/compile/__init__.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/compile/passes.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/data/dataloader.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/device.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/dtypes.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/errors.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/nn/convolution.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/nn/embedding.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/nn/init.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/nn/linear.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/nn/losses.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/nn/normalization.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/nn/parameter.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/nn/pooling.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/nn/transformer.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/nn/utils.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/ops/reductions.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/py.typed +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/runtime/__init__.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/runtime/backend.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/runtime/dispatcher.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/storage.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/testing/__init__.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio/testing/gradcheck.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio.egg-info/dependency_links.txt +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio.egg-info/requires.txt +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/python/modelstudio.egg-info/top_level.txt +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/setup.cfg +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_attention.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_autograd.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_batchnorm.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_buffers.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_concat_stack.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_conv.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_data.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_dataloader_seed.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_dispatcher.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_dropout.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_embedding.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_grad_clip.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_gradcheck.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_indexing.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_init.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_loss_reductions.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_losses.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_module_ergonomics.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_nn.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_norms.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_ops.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_optim.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_optimizer_state.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_pooling.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_random.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_reductions_axis.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_serialization.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_shape_ops.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_state_dict.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_tensor.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_transformer.py +0 -0
- {modelstudio-0.3.0 → modelstudio-0.5.0}/tests/test_unary_ops.py +0 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: modelstudio
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: An early-stage AI tensor framework with CPU tensors, autograd, and backend extension scaffolding.
|
|
5
|
+
Author: ModelStudio Contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/imattas/modelstudio
|
|
8
|
+
Project-URL: Repository, https://github.com/imattas/modelstudio
|
|
9
|
+
Project-URL: Issues, https://github.com/imattas/modelstudio/issues
|
|
10
|
+
Keywords: ai,autograd,deep-learning,neural-networks,tensor
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy>=1.26
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
27
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
28
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
29
|
+
Requires-Dist: twine>=5; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# ModelStudio
|
|
33
|
+
|
|
34
|
+
ModelStudio is an early-stage AI tensor framework. Version `0.5.0` provides a
|
|
35
|
+
CPU tensor/autograd MVP with neural-network modules, optimizers, serialization,
|
|
36
|
+
data loading, graph tracing metadata, backend status inspection, and small
|
|
37
|
+
LLM-oriented building blocks.
|
|
38
|
+
|
|
39
|
+
It is not a PyTorch or TensorFlow replacement. CPU is the only working backend.
|
|
40
|
+
CUDA, ROCm, and oneAPI remain explicit scaffolds until real kernels are built
|
|
41
|
+
and tested.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
From PyPI:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
python -m pip install modelstudio
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
For development:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
python -m pip install -e ".[dev]"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Feature Table
|
|
58
|
+
|
|
59
|
+
| Area | Status |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| CPU tensors | Working MVP |
|
|
62
|
+
| Autograd | Reverse-mode for core CPU ops |
|
|
63
|
+
| Reductions | `sum`, `mean`, `max`, `all`, and `any`; `max` is value-only |
|
|
64
|
+
| Comparisons | Elementwise comparisons, `equal`, `isclose`, and `allclose` |
|
|
65
|
+
| Activations | ReLU, GELU, LeakyReLU, ELU, Softplus, exp, log, tanh, sigmoid, SiLU, softmax, log-softmax |
|
|
66
|
+
| Losses | MSE and cross entropy with `none`, `mean`, and `sum` reductions |
|
|
67
|
+
| Functional API | `modelstudio.nn.functional` wrappers for common NN operations |
|
|
68
|
+
| Modules | Parameters, buffers, child traversal, state dicts, save/load |
|
|
69
|
+
| Layers | Linear, Embedding, LayerNorm, RMSNorm, BatchNorm1d, Dropout, Conv1d, Conv2d, pooling, TransformerBlock |
|
|
70
|
+
| Optimizers | SGD and AdamW with state serialization, parameter groups, and LR schedulers |
|
|
71
|
+
| Data | Dataset, TensorDataset, random_split, DataLoader with deterministic seeded shuffle |
|
|
72
|
+
| Randomness | `manual_seed`, `ms.random`, RNG-backed creation, dropout, and init helpers |
|
|
73
|
+
| Linalg | `ms.linalg.matmul`, `norm`, `vector_norm`, and `transpose` |
|
|
74
|
+
| Interop | `asarray`, `from_numpy`, `to_numpy`, and `ms.numpy` |
|
|
75
|
+
| Metrics | accuracy and top-k accuracy |
|
|
76
|
+
| Compiler | Metadata-only tracing plus placeholder IR and passes |
|
|
77
|
+
|
|
78
|
+
## Backend Status
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
import modelstudio as ms
|
|
82
|
+
|
|
83
|
+
print(ms.backends.status())
|
|
84
|
+
print(ms.backends.native_cpu_available())
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Expected shape:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
{
|
|
91
|
+
"cpu": {"available": True, "native": False},
|
|
92
|
+
"cuda": {"available": False, "reason": "..."},
|
|
93
|
+
"rocm": {"available": False, "reason": "..."},
|
|
94
|
+
"oneapi": {"available": False, "reason": "..."},
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The production CPU path is the NumPy backend. `ms.backends.use_native_cpu(True)`
|
|
99
|
+
raises `ModelStudioBackendUnavailable` unless a future optional native extension
|
|
100
|
+
is actually installed. Unsupported accelerator devices fail with
|
|
101
|
+
`ModelStudioBackendUnavailable`.
|
|
102
|
+
|
|
103
|
+
## Tensor Example
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
import modelstudio as ms
|
|
107
|
+
|
|
108
|
+
x = ms.randn((32, 784), requires_grad=True)
|
|
109
|
+
w = ms.randn((784, 10), requires_grad=True)
|
|
110
|
+
loss = (x @ w).mean()
|
|
111
|
+
loss.backward()
|
|
112
|
+
print(w.grad)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Functional API
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
import modelstudio as ms
|
|
119
|
+
from modelstudio import nn
|
|
120
|
+
from modelstudio.nn import functional as F
|
|
121
|
+
|
|
122
|
+
model = nn.Linear(4, 2)
|
|
123
|
+
x = ms.random.randn((8, 4))
|
|
124
|
+
target = ms.random.randn((8, 2))
|
|
125
|
+
loss = F.mse_loss(F.relu(F.linear(x, model.weight, model.bias)), target)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Tracing
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
import modelstudio as ms
|
|
132
|
+
from modelstudio.nn import functional as F
|
|
133
|
+
|
|
134
|
+
x = ms.random.randn((4, 3))
|
|
135
|
+
w = ms.random.randn((3, 2))
|
|
136
|
+
graph = ms.trace(lambda a, b: F.relu(a @ b), x, w)
|
|
137
|
+
print(graph)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Tracing captures operation names and tensor metadata. It does not optimize or
|
|
141
|
+
execute graphs yet. `ms.compile(fn)` remains a documented no-op that returns the
|
|
142
|
+
original callable.
|
|
143
|
+
|
|
144
|
+
## Random And Linalg
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
ms.random.seed(123)
|
|
148
|
+
x = ms.random.normal((4, 3), mean=0.0, std=1.0)
|
|
149
|
+
w = ms.random.uniform((3, 2), low=-0.1, high=0.1)
|
|
150
|
+
y = ms.linalg.matmul(x, w)
|
|
151
|
+
print(ms.linalg.norm(y).item())
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Comparisons
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
x = ms.tensor([1.0, 2.0, 3.0])
|
|
158
|
+
y = ms.tensor([1.0, 2.1, 3.0])
|
|
159
|
+
print(ms.isclose(x, y, atol=0.05))
|
|
160
|
+
print(ms.allclose(x, y, atol=0.05))
|
|
161
|
+
print((x > 1.5).any().item())
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Comparison and logical outputs are bool tensors and do not track gradients.
|
|
165
|
+
|
|
166
|
+
## Checkpointing
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
model = nn.Linear(4, 2)
|
|
170
|
+
optimizer = ms.optim.AdamW(model.parameters(), lr=1e-3)
|
|
171
|
+
ms.save_checkpoint("checkpoint.ms", model=model, optimizer=optimizer, extra={"epoch": 1})
|
|
172
|
+
checkpoint = ms.load_checkpoint("checkpoint.ms", model=model, optimizer=optimizer, map_location="cpu")
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Checkpoint loading validates structure and model state. CPU is the only accepted
|
|
176
|
+
`map_location` in the current release.
|
|
177
|
+
|
|
178
|
+
## Commands
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
python -m pytest
|
|
182
|
+
python scripts/smoke_test.py
|
|
183
|
+
python examples/train_mlp.py
|
|
184
|
+
python examples/train_classifier.py
|
|
185
|
+
python examples/tiny_transformer.py
|
|
186
|
+
python examples/save_load.py
|
|
187
|
+
python examples/train_cnn_toy.py
|
|
188
|
+
python examples/dropout_batchnorm.py
|
|
189
|
+
python examples/checkpoint_training.py
|
|
190
|
+
python examples/numpy_interop.py
|
|
191
|
+
python examples/scheduler_training.py
|
|
192
|
+
python examples/checkpoint_resume.py
|
|
193
|
+
python examples/metrics_demo.py
|
|
194
|
+
python examples/backend_status.py
|
|
195
|
+
python examples/tracing_demo.py
|
|
196
|
+
python examples/functional_training.py
|
|
197
|
+
python examples/random_linalg_demo.py
|
|
198
|
+
python benchmarks/bench_matmul.py
|
|
199
|
+
python benchmarks/bench_mlp.py
|
|
200
|
+
python benchmarks/bench_attention.py
|
|
201
|
+
python benchmarks/bench_dataloader.py
|
|
202
|
+
python benchmarks/bench_conv.py
|
|
203
|
+
python benchmarks/bench_dropout.py
|
|
204
|
+
python benchmarks/bench_creation.py
|
|
205
|
+
python benchmarks/bench_manipulation.py
|
|
206
|
+
python benchmarks/bench_elementwise.py
|
|
207
|
+
python benchmarks/bench_trace.py
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Documentation
|
|
211
|
+
|
|
212
|
+
- [Backend status](docs/backend-status.md)
|
|
213
|
+
- [Tracing](docs/tracing.md)
|
|
214
|
+
- [Functional API](docs/functional-api.md)
|
|
215
|
+
- [Random namespace](docs/random.md)
|
|
216
|
+
- [Linalg namespace](docs/linalg.md)
|
|
217
|
+
- [Comparison ops](docs/comparison-ops.md)
|
|
218
|
+
- [Tensor API](docs/tensor-api.md)
|
|
219
|
+
- [Neural network API](docs/nn.md)
|
|
220
|
+
- [Data utilities](docs/data.md)
|
|
221
|
+
- [Training](docs/training.md)
|
|
222
|
+
- [Modules](docs/modules.md)
|
|
223
|
+
- [Serialization](docs/serialization.md)
|
|
224
|
+
- [Native backend roadmap](docs/native-backend-roadmap.md)
|
|
225
|
+
- [NumPy interop](docs/numpy-interop.md)
|
|
226
|
+
- [Tensor creation](docs/tensor-creation.md)
|
|
227
|
+
- [Tensor manipulation](docs/tensor-manipulation.md)
|
|
228
|
+
- [Optimizers](docs/optimizers.md)
|
|
229
|
+
- [Checkpointing](docs/checkpointing.md)
|
|
230
|
+
- [Metrics](docs/metrics.md)
|
|
231
|
+
- [Backend architecture](docs/backend-architecture.md)
|
|
232
|
+
- [Autograd design](docs/autograd.md)
|
|
233
|
+
- [Releasing](docs/releasing.md)
|
|
234
|
+
- [Contributing](CONTRIBUTING.md)
|
|
235
|
+
|
|
236
|
+
## Roadmap
|
|
237
|
+
|
|
238
|
+
- Expand tensor and autograd coverage.
|
|
239
|
+
- Wire optional native CPU kernels only after a safe Python extension exists.
|
|
240
|
+
- Add tested CUDA, ROCm, and oneAPI packages when hardware-backed CI exists.
|
|
241
|
+
- Improve compiler graph capture, analysis passes, and lowering.
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# ModelStudio
|
|
2
|
+
|
|
3
|
+
ModelStudio is an early-stage AI tensor framework. Version `0.5.0` provides a
|
|
4
|
+
CPU tensor/autograd MVP with neural-network modules, optimizers, serialization,
|
|
5
|
+
data loading, graph tracing metadata, backend status inspection, and small
|
|
6
|
+
LLM-oriented building blocks.
|
|
7
|
+
|
|
8
|
+
It is not a PyTorch or TensorFlow replacement. CPU is the only working backend.
|
|
9
|
+
CUDA, ROCm, and oneAPI remain explicit scaffolds until real kernels are built
|
|
10
|
+
and tested.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
From PyPI:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
python -m pip install modelstudio
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
For development:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
python -m pip install -e ".[dev]"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Feature Table
|
|
27
|
+
|
|
28
|
+
| Area | Status |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| CPU tensors | Working MVP |
|
|
31
|
+
| Autograd | Reverse-mode for core CPU ops |
|
|
32
|
+
| Reductions | `sum`, `mean`, `max`, `all`, and `any`; `max` is value-only |
|
|
33
|
+
| Comparisons | Elementwise comparisons, `equal`, `isclose`, and `allclose` |
|
|
34
|
+
| Activations | ReLU, GELU, LeakyReLU, ELU, Softplus, exp, log, tanh, sigmoid, SiLU, softmax, log-softmax |
|
|
35
|
+
| Losses | MSE and cross entropy with `none`, `mean`, and `sum` reductions |
|
|
36
|
+
| Functional API | `modelstudio.nn.functional` wrappers for common NN operations |
|
|
37
|
+
| Modules | Parameters, buffers, child traversal, state dicts, save/load |
|
|
38
|
+
| Layers | Linear, Embedding, LayerNorm, RMSNorm, BatchNorm1d, Dropout, Conv1d, Conv2d, pooling, TransformerBlock |
|
|
39
|
+
| Optimizers | SGD and AdamW with state serialization, parameter groups, and LR schedulers |
|
|
40
|
+
| Data | Dataset, TensorDataset, random_split, DataLoader with deterministic seeded shuffle |
|
|
41
|
+
| Randomness | `manual_seed`, `ms.random`, RNG-backed creation, dropout, and init helpers |
|
|
42
|
+
| Linalg | `ms.linalg.matmul`, `norm`, `vector_norm`, and `transpose` |
|
|
43
|
+
| Interop | `asarray`, `from_numpy`, `to_numpy`, and `ms.numpy` |
|
|
44
|
+
| Metrics | accuracy and top-k accuracy |
|
|
45
|
+
| Compiler | Metadata-only tracing plus placeholder IR and passes |
|
|
46
|
+
|
|
47
|
+
## Backend Status
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import modelstudio as ms
|
|
51
|
+
|
|
52
|
+
print(ms.backends.status())
|
|
53
|
+
print(ms.backends.native_cpu_available())
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Expected shape:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
{
|
|
60
|
+
"cpu": {"available": True, "native": False},
|
|
61
|
+
"cuda": {"available": False, "reason": "..."},
|
|
62
|
+
"rocm": {"available": False, "reason": "..."},
|
|
63
|
+
"oneapi": {"available": False, "reason": "..."},
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The production CPU path is the NumPy backend. `ms.backends.use_native_cpu(True)`
|
|
68
|
+
raises `ModelStudioBackendUnavailable` unless a future optional native extension
|
|
69
|
+
is actually installed. Unsupported accelerator devices fail with
|
|
70
|
+
`ModelStudioBackendUnavailable`.
|
|
71
|
+
|
|
72
|
+
## Tensor Example
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
import modelstudio as ms
|
|
76
|
+
|
|
77
|
+
x = ms.randn((32, 784), requires_grad=True)
|
|
78
|
+
w = ms.randn((784, 10), requires_grad=True)
|
|
79
|
+
loss = (x @ w).mean()
|
|
80
|
+
loss.backward()
|
|
81
|
+
print(w.grad)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Functional API
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
import modelstudio as ms
|
|
88
|
+
from modelstudio import nn
|
|
89
|
+
from modelstudio.nn import functional as F
|
|
90
|
+
|
|
91
|
+
model = nn.Linear(4, 2)
|
|
92
|
+
x = ms.random.randn((8, 4))
|
|
93
|
+
target = ms.random.randn((8, 2))
|
|
94
|
+
loss = F.mse_loss(F.relu(F.linear(x, model.weight, model.bias)), target)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Tracing
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
import modelstudio as ms
|
|
101
|
+
from modelstudio.nn import functional as F
|
|
102
|
+
|
|
103
|
+
x = ms.random.randn((4, 3))
|
|
104
|
+
w = ms.random.randn((3, 2))
|
|
105
|
+
graph = ms.trace(lambda a, b: F.relu(a @ b), x, w)
|
|
106
|
+
print(graph)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Tracing captures operation names and tensor metadata. It does not optimize or
|
|
110
|
+
execute graphs yet. `ms.compile(fn)` remains a documented no-op that returns the
|
|
111
|
+
original callable.
|
|
112
|
+
|
|
113
|
+
## Random And Linalg
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
ms.random.seed(123)
|
|
117
|
+
x = ms.random.normal((4, 3), mean=0.0, std=1.0)
|
|
118
|
+
w = ms.random.uniform((3, 2), low=-0.1, high=0.1)
|
|
119
|
+
y = ms.linalg.matmul(x, w)
|
|
120
|
+
print(ms.linalg.norm(y).item())
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Comparisons
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
x = ms.tensor([1.0, 2.0, 3.0])
|
|
127
|
+
y = ms.tensor([1.0, 2.1, 3.0])
|
|
128
|
+
print(ms.isclose(x, y, atol=0.05))
|
|
129
|
+
print(ms.allclose(x, y, atol=0.05))
|
|
130
|
+
print((x > 1.5).any().item())
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Comparison and logical outputs are bool tensors and do not track gradients.
|
|
134
|
+
|
|
135
|
+
## Checkpointing
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
model = nn.Linear(4, 2)
|
|
139
|
+
optimizer = ms.optim.AdamW(model.parameters(), lr=1e-3)
|
|
140
|
+
ms.save_checkpoint("checkpoint.ms", model=model, optimizer=optimizer, extra={"epoch": 1})
|
|
141
|
+
checkpoint = ms.load_checkpoint("checkpoint.ms", model=model, optimizer=optimizer, map_location="cpu")
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Checkpoint loading validates structure and model state. CPU is the only accepted
|
|
145
|
+
`map_location` in the current release.
|
|
146
|
+
|
|
147
|
+
## Commands
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
python -m pytest
|
|
151
|
+
python scripts/smoke_test.py
|
|
152
|
+
python examples/train_mlp.py
|
|
153
|
+
python examples/train_classifier.py
|
|
154
|
+
python examples/tiny_transformer.py
|
|
155
|
+
python examples/save_load.py
|
|
156
|
+
python examples/train_cnn_toy.py
|
|
157
|
+
python examples/dropout_batchnorm.py
|
|
158
|
+
python examples/checkpoint_training.py
|
|
159
|
+
python examples/numpy_interop.py
|
|
160
|
+
python examples/scheduler_training.py
|
|
161
|
+
python examples/checkpoint_resume.py
|
|
162
|
+
python examples/metrics_demo.py
|
|
163
|
+
python examples/backend_status.py
|
|
164
|
+
python examples/tracing_demo.py
|
|
165
|
+
python examples/functional_training.py
|
|
166
|
+
python examples/random_linalg_demo.py
|
|
167
|
+
python benchmarks/bench_matmul.py
|
|
168
|
+
python benchmarks/bench_mlp.py
|
|
169
|
+
python benchmarks/bench_attention.py
|
|
170
|
+
python benchmarks/bench_dataloader.py
|
|
171
|
+
python benchmarks/bench_conv.py
|
|
172
|
+
python benchmarks/bench_dropout.py
|
|
173
|
+
python benchmarks/bench_creation.py
|
|
174
|
+
python benchmarks/bench_manipulation.py
|
|
175
|
+
python benchmarks/bench_elementwise.py
|
|
176
|
+
python benchmarks/bench_trace.py
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Documentation
|
|
180
|
+
|
|
181
|
+
- [Backend status](docs/backend-status.md)
|
|
182
|
+
- [Tracing](docs/tracing.md)
|
|
183
|
+
- [Functional API](docs/functional-api.md)
|
|
184
|
+
- [Random namespace](docs/random.md)
|
|
185
|
+
- [Linalg namespace](docs/linalg.md)
|
|
186
|
+
- [Comparison ops](docs/comparison-ops.md)
|
|
187
|
+
- [Tensor API](docs/tensor-api.md)
|
|
188
|
+
- [Neural network API](docs/nn.md)
|
|
189
|
+
- [Data utilities](docs/data.md)
|
|
190
|
+
- [Training](docs/training.md)
|
|
191
|
+
- [Modules](docs/modules.md)
|
|
192
|
+
- [Serialization](docs/serialization.md)
|
|
193
|
+
- [Native backend roadmap](docs/native-backend-roadmap.md)
|
|
194
|
+
- [NumPy interop](docs/numpy-interop.md)
|
|
195
|
+
- [Tensor creation](docs/tensor-creation.md)
|
|
196
|
+
- [Tensor manipulation](docs/tensor-manipulation.md)
|
|
197
|
+
- [Optimizers](docs/optimizers.md)
|
|
198
|
+
- [Checkpointing](docs/checkpointing.md)
|
|
199
|
+
- [Metrics](docs/metrics.md)
|
|
200
|
+
- [Backend architecture](docs/backend-architecture.md)
|
|
201
|
+
- [Autograd design](docs/autograd.md)
|
|
202
|
+
- [Releasing](docs/releasing.md)
|
|
203
|
+
- [Contributing](CONTRIBUTING.md)
|
|
204
|
+
|
|
205
|
+
## Roadmap
|
|
206
|
+
|
|
207
|
+
- Expand tensor and autograd coverage.
|
|
208
|
+
- Wire optional native CPU kernels only after a safe Python extension exists.
|
|
209
|
+
- Add tested CUDA, ROCm, and oneAPI packages when hardware-backed CI exists.
|
|
210
|
+
- Improve compiler graph capture, analysis passes, and lowering.
|
|
@@ -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,44 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import platform
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
import modelstudio as ms
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _time_ms(fn, warmup: int, iterations: int) -> float:
|
|
10
|
+
for _ in range(warmup):
|
|
11
|
+
fn()
|
|
12
|
+
start = time.perf_counter()
|
|
13
|
+
for _ in range(iterations):
|
|
14
|
+
fn()
|
|
15
|
+
return (time.perf_counter() - start) * 1000.0 / iterations
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def main() -> None:
|
|
19
|
+
shape = (1024, 1024)
|
|
20
|
+
warmup = 5
|
|
21
|
+
iterations = 50
|
|
22
|
+
ms.random.seed(123)
|
|
23
|
+
x = ms.random.randn(shape)
|
|
24
|
+
y = ms.random.randn(shape)
|
|
25
|
+
|
|
26
|
+
add_ms = _time_ms(lambda: x + y, warmup, iterations)
|
|
27
|
+
relu_ms = _time_ms(lambda: ms.relu(x), warmup, iterations)
|
|
28
|
+
cmp_ms = _time_ms(lambda: x > y, warmup, iterations)
|
|
29
|
+
|
|
30
|
+
print(f"Python: {platform.python_version()}")
|
|
31
|
+
print(f"NumPy: {ms.numpy.__version__}")
|
|
32
|
+
print(f"ModelStudio: {ms.__version__}")
|
|
33
|
+
print(f"Shape: {shape}")
|
|
34
|
+
print(f"Warmup: {warmup}")
|
|
35
|
+
print(f"Iterations: {iterations}")
|
|
36
|
+
print(f"Backend: {ms.backends.status()}")
|
|
37
|
+
print(f"add avg: {add_ms:.3f} ms")
|
|
38
|
+
print(f"relu avg: {relu_ms:.3f} ms")
|
|
39
|
+
print(f"compare avg: {cmp_ms:.3f} ms")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if __name__ == "__main__":
|
|
43
|
+
main()
|
|
44
|
+
|
|
@@ -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,47 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import platform
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
import modelstudio as ms
|
|
7
|
+
from modelstudio.nn import functional as F
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _time_ms(fn, warmup: int, iterations: 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) * 1000.0 / iterations
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main() -> None:
|
|
20
|
+
shape = (64, 128)
|
|
21
|
+
weight_shape = (128, 32)
|
|
22
|
+
warmup = 5
|
|
23
|
+
iterations = 100
|
|
24
|
+
x = ms.random.randn(shape)
|
|
25
|
+
w = ms.random.randn(weight_shape)
|
|
26
|
+
|
|
27
|
+
def forward(a: ms.Tensor, b: ms.Tensor) -> ms.Tensor:
|
|
28
|
+
return F.relu(a @ b)
|
|
29
|
+
|
|
30
|
+
trace_ms = _time_ms(lambda: ms.trace(forward, x, w), warmup, iterations)
|
|
31
|
+
graph = ms.trace(forward, x, w)
|
|
32
|
+
|
|
33
|
+
print(f"Python: {platform.python_version()}")
|
|
34
|
+
print(f"NumPy: {ms.numpy.__version__}")
|
|
35
|
+
print(f"ModelStudio: {ms.__version__}")
|
|
36
|
+
print(f"Input: {shape}")
|
|
37
|
+
print(f"Weight: {weight_shape}")
|
|
38
|
+
print(f"Warmup: {warmup}")
|
|
39
|
+
print(f"Iterations: {iterations}")
|
|
40
|
+
print(f"Backend: {ms.backends.status()}")
|
|
41
|
+
print(f"Trace avg: {trace_ms:.3f} ms")
|
|
42
|
+
print(f"Nodes: {[node.op for node in graph.nodes]}")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
main()
|
|
47
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Backend Status
|
|
2
|
+
|
|
3
|
+
ModelStudio 0.5.0 keeps CPU as the only available runtime backend.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
import modelstudio as ms
|
|
7
|
+
|
|
8
|
+
status = ms.backends.status()
|
|
9
|
+
print(status["cpu"])
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`ms.backends.status()` returns a mapping for `cpu`, `cuda`, `rocm`, and
|
|
13
|
+
`oneapi`. CPU is always available through the NumPy backend. Accelerator
|
|
14
|
+
backends remain explicit unavailable scaffolds and include a human-readable
|
|
15
|
+
reason.
|
|
16
|
+
|
|
17
|
+
`ms.backends.native_cpu_available()` checks for the optional future native CPU
|
|
18
|
+
extension. `ms.backends.use_native_cpu(True)` raises
|
|
19
|
+
`ModelStudioBackendUnavailable` unless that extension is installed. The NumPy
|
|
20
|
+
CPU backend remains the production path.
|
|
21
|
+
|
|
@@ -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
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Comparison Ops
|
|
2
|
+
|
|
3
|
+
ModelStudio 0.5.0 adds elementwise tensor comparisons:
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
x = ms.tensor([1.0, 2.0, 3.0])
|
|
7
|
+
y = ms.tensor([1.0, 2.1, 3.0])
|
|
8
|
+
|
|
9
|
+
print(x == y)
|
|
10
|
+
print(x > 1.5)
|
|
11
|
+
print(ms.isclose(x, y, atol=0.05))
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Available helpers:
|
|
15
|
+
|
|
16
|
+
- `ms.equal(x, y)` for exact shape and value equality
|
|
17
|
+
- `ms.allclose(x, y, rtol=1e-5, atol=1e-8)`
|
|
18
|
+
- `ms.isclose(x, y, rtol=1e-5, atol=1e-8)`
|
|
19
|
+
- `x.all(axis=None, keepdims=False)` and `x.any(...)`
|
|
20
|
+
- `ms.all(x, axis=None, keepdims=False)` and `ms.any(...)`
|
|
21
|
+
|
|
22
|
+
Comparison and logical outputs are bool tensors and do not track gradients.
|
|
23
|
+
|