reframx 0.1.1__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 (93) hide show
  1. reframx-0.1.1/LICENSE +21 -0
  2. reframx-0.1.1/MANIFEST.in +16 -0
  3. reframx-0.1.1/PKG-INFO +134 -0
  4. reframx-0.1.1/README.md +102 -0
  5. reframx-0.1.1/pyproject.toml +104 -0
  6. reframx-0.1.1/setup.cfg +4 -0
  7. reframx-0.1.1/src/reframx/__init__.py +180 -0
  8. reframx-0.1.1/src/reframx/api/__init__.py +193 -0
  9. reframx-0.1.1/src/reframx/core/__init__.py +1 -0
  10. reframx-0.1.1/src/reframx/core/components/__init__.py +5 -0
  11. reframx-0.1.1/src/reframx/core/components/handle.py +87 -0
  12. reframx-0.1.1/src/reframx/core/components/metadata.py +33 -0
  13. reframx-0.1.1/src/reframx/core/components/protocols.py +47 -0
  14. reframx-0.1.1/src/reframx/core/components/specification.py +50 -0
  15. reframx-0.1.1/src/reframx/core/contracts/__init__.py +5 -0
  16. reframx-0.1.1/src/reframx/core/contracts/capabilities.py +58 -0
  17. reframx-0.1.1/src/reframx/core/contracts/compatibility.py +574 -0
  18. reframx-0.1.1/src/reframx/core/contracts/io.py +42 -0
  19. reframx-0.1.1/src/reframx/core/contracts/requirements.py +115 -0
  20. reframx-0.1.1/src/reframx/core/exceptions.py +25 -0
  21. reframx-0.1.1/src/reframx/core/registry/__init__.py +27 -0
  22. reframx-0.1.1/src/reframx/core/registry/plugins.py +478 -0
  23. reframx-0.1.1/src/reframx/core/registry/registry.py +186 -0
  24. reframx-0.1.1/src/reframx/core/types.py +14 -0
  25. reframx-0.1.1/src/reframx/core/validation/__init__.py +15 -0
  26. reframx-0.1.1/src/reframx/core/validation/context.py +22 -0
  27. reframx-0.1.1/src/reframx/core/validation/report.py +80 -0
  28. reframx-0.1.1/src/reframx/core/validation/runner.py +41 -0
  29. reframx-0.1.1/src/reframx/datasets/__init__.py +10 -0
  30. reframx-0.1.1/src/reframx/datasets/adapters/__init__.py +5 -0
  31. reframx-0.1.1/src/reframx/datasets/adapters/field_mapping.py +179 -0
  32. reframx-0.1.1/src/reframx/datasets/interface.py +79 -0
  33. reframx-0.1.1/src/reframx/datasets/specification.py +31 -0
  34. reframx-0.1.1/src/reframx/evaluators/__init__.py +11 -0
  35. reframx-0.1.1/src/reframx/evaluators/interface.py +88 -0
  36. reframx-0.1.1/src/reframx/execution/__init__.py +14 -0
  37. reframx-0.1.1/src/reframx/execution/backend.py +73 -0
  38. reframx-0.1.1/src/reframx/execution/context.py +92 -0
  39. reframx-0.1.1/src/reframx/execution/engine.py +257 -0
  40. reframx-0.1.1/src/reframx/execution/hooks/__init__.py +6 -0
  41. reframx-0.1.1/src/reframx/execution/hooks/base.py +46 -0
  42. reframx-0.1.1/src/reframx/experiments/__init__.py +8 -0
  43. reframx-0.1.1/src/reframx/experiments/experiment.py +232 -0
  44. reframx-0.1.1/src/reframx/experiments/run.py +63 -0
  45. reframx-0.1.1/src/reframx/instrumentation/__init__.py +35 -0
  46. reframx-0.1.1/src/reframx/instrumentation/events.py +60 -0
  47. reframx-0.1.1/src/reframx/instrumentation/manager.py +365 -0
  48. reframx-0.1.1/src/reframx/instrumentation/module_hooks.py +185 -0
  49. reframx-0.1.1/src/reframx/instrumentation/probes.py +142 -0
  50. reframx-0.1.1/src/reframx/integrations/__init__.py +1 -0
  51. reframx-0.1.1/src/reframx/integrations/mmengine/__init__.py +15 -0
  52. reframx-0.1.1/src/reframx/integrations/mmengine/backend.py +236 -0
  53. reframx-0.1.1/src/reframx/integrations/mmengine/bridges.py +186 -0
  54. reframx-0.1.1/src/reframx/integrations/mmengine/strategy.py +101 -0
  55. reframx-0.1.1/src/reframx/integrations/mmengine/utils.py +42 -0
  56. reframx-0.1.1/src/reframx/integrations/pytorch/__init__.py +45 -0
  57. reframx-0.1.1/src/reframx/integrations/pytorch/dataset.py +78 -0
  58. reframx-0.1.1/src/reframx/integrations/pytorch/evaluators.py +115 -0
  59. reframx-0.1.1/src/reframx/integrations/pytorch/methods.py +160 -0
  60. reframx-0.1.1/src/reframx/integrations/pytorch/model.py +95 -0
  61. reframx-0.1.1/src/reframx/integrations/pytorch/objectives.py +149 -0
  62. reframx-0.1.1/src/reframx/integrations/pytorch/strategy.py +190 -0
  63. reframx-0.1.1/src/reframx/integrations/pytorch/utils.py +80 -0
  64. reframx-0.1.1/src/reframx/methods/__init__.py +13 -0
  65. reframx-0.1.1/src/reframx/methods/interface.py +138 -0
  66. reframx-0.1.1/src/reframx/methods/specification.py +24 -0
  67. reframx-0.1.1/src/reframx/models/__init__.py +8 -0
  68. reframx-0.1.1/src/reframx/models/interface.py +114 -0
  69. reframx-0.1.1/src/reframx/models/specification.py +28 -0
  70. reframx-0.1.1/src/reframx/objectives/__init__.py +6 -0
  71. reframx-0.1.1/src/reframx/objectives/interface.py +76 -0
  72. reframx-0.1.1/src/reframx/packaging/__init__.py +38 -0
  73. reframx-0.1.1/src/reframx/packaging/archive.py +195 -0
  74. reframx-0.1.1/src/reframx/packaging/exporter.py +206 -0
  75. reframx-0.1.1/src/reframx/packaging/importer.py +186 -0
  76. reframx-0.1.1/src/reframx/packaging/manifest.py +166 -0
  77. reframx-0.1.1/src/reframx/py.typed +0 -0
  78. reframx-0.1.1/src/reframx/strategies/__init__.py +11 -0
  79. reframx-0.1.1/src/reframx/strategies/interface.py +186 -0
  80. reframx-0.1.1/src/reframx/tasks/__init__.py +23 -0
  81. reframx-0.1.1/src/reframx/tasks/builtin/__init__.py +11 -0
  82. reframx-0.1.1/src/reframx/tasks/builtin/common.py +137 -0
  83. reframx-0.1.1/src/reframx/tasks/definitions/__init__.py +9 -0
  84. reframx-0.1.1/src/reframx/tasks/definitions/evaluation.py +20 -0
  85. reframx-0.1.1/src/reframx/tasks/definitions/objectives.py +25 -0
  86. reframx-0.1.1/src/reframx/tasks/definitions/problem.py +10 -0
  87. reframx-0.1.1/src/reframx/tasks/interface.py +57 -0
  88. reframx-0.1.1/src/reframx/tasks/specification.py +65 -0
  89. reframx-0.1.1/src/reframx.egg-info/PKG-INFO +134 -0
  90. reframx-0.1.1/src/reframx.egg-info/SOURCES.txt +91 -0
  91. reframx-0.1.1/src/reframx.egg-info/dependency_links.txt +1 -0
  92. reframx-0.1.1/src/reframx.egg-info/requires.txt +5 -0
  93. reframx-0.1.1/src/reframx.egg-info/top_level.txt +1 -0
reframx-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Research Framework Contributors
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,16 @@
1
+ include LICENSE
2
+ include README.md
3
+ include src/reframx/py.typed
4
+
5
+ # Exclude unimplemented local placeholder directories/files from sdist
6
+ prune src/reframx/analysis
7
+ prune src/reframx/cli
8
+ prune src/reframx/configuration
9
+ prune src/reframx/core/events
10
+ prune src/reframx/development
11
+ prune src/reframx/integrations/transformers
12
+ prune src/reframx/logging
13
+ prune src/reframx/persistence
14
+ prune src/reframx/utils
15
+ exclude src/reframx/experiments/builder.py
16
+ exclude src/reframx/experiments/manager.py
reframx-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: reframx
3
+ Version: 0.1.1
4
+ Summary: A modular, code-first framework for neural network research.
5
+ Author: Research Framework Contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/rushia314/reframx
8
+ Project-URL: Repository, https://github.com/rushia314/reframx
9
+ Project-URL: Documentation, https://github.com/rushia314/reframx/tree/main/docs
10
+ Project-URL: Issues, https://github.com/rushia314/reframx/issues
11
+ Keywords: deep-learning,neural-networks,research,pytorch,mmengine,machine-learning
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=8.0; extra == "dev"
29
+ Requires-Dist: mypy>=1.8; extra == "dev"
30
+ Requires-Dist: ruff>=0.9; extra == "dev"
31
+ Dynamic: license-file
32
+
33
+ # reframx
34
+
35
+ [![PyPI version](https://img.shields.io/pypi/v/reframx.svg)](https://pypi.org/project/reframx/)
36
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
37
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/rushia314/reframx/blob/main/LICENSE)
38
+ [![Typing: Typed](https://img.shields.io/badge/typing-typed-brightgreen.svg)](https://peps.python.org/pep-0561/)
39
+
40
+ A modular, Python-first, code-first framework for neural network research.
41
+
42
+ > **Core philosophy:** Researchers own their architectures, losses, data pipelines, and training algorithms. `reframx` provides contract-driven composition, validation, pluggable execution backends, model instrumentation, plugins, and portable `.rfx` experiment snapshots — without forcing a fixed model hierarchy or a single `forward -> loss -> backward -> step` loop.
43
+
44
+ ## Key Features
45
+
46
+ - **Zero-dependency core:** Core contracts, validation, execution engine, instrumentation, plugins, and `.rfx` packaging rely only on the Python standard library.
47
+ - **Contract-driven composition:** `ComponentSpec`, `Requirement`, `RequirementGroup` (`all_of` / `any_of`), `Capability`, `IOContract`, and `validate_requirements()` with concise `str`/`dict` shorthand.
48
+ - **Full research freedom + sensible defaults:**
49
+ - `BaseMethod` for arbitrary multi-forward / multi-backward / multi-optimizer algorithms.
50
+ - `SupervisedMethod` and PyTorch built-ins (`TorchClassificationMethod`, `TorchRegressionMethod`, `CrossEntropyObjective`, `BCEWithLogitsObjective`, `MSEObjective`, `TorchAccuracyEvaluator`, `TorchRegressionEvaluator`) for rapid standard workflows.
51
+ - **Pluggable execution backends:**
52
+ - `NativeBackend` (default, zero dependencies, easy debugging, `experiment.stop()`).
53
+ - `MMEngineBackend` (optional, lazy-imported: GPU/DDP/FSDP, `OptimWrapper`, `ParamScheduler`, `CheckpointHook` with `save_best`/`save_last`, `Visualizer`).
54
+ - **Non-invasive PyTorch GPU integration:** `TorchModelAdapter`, `TorchDatasetAdapter`, and `TorchStrategy` (auto device placement, AMP `fp16`/`bf16`, `GradScaler`, `max_grad_norm`, gradient accumulation) — never overwrites your existing PyTorch/CUDA installation.
55
+ - **Model instrumentation:** `rf.probe()` / `rf.Probe` (zero-overhead pass-through via `contextvars`), `watch_module` / `watch_modules`, automatic tensor detach, `tensor_stats`, and `check_nan_inf`.
56
+ - **Plugin system:** `ComponentRegistry` and `PluginManager` supporting `load_plugin`, `load_file`, `load_path` (multi-file packages), `load_directory`, safe `discover_entry_points` / `load_entry_points`, and clean `unload_plugin`.
57
+ - **Portable `.rfx` archives:** Atomic, unencrypted ZIP experiment snapshots (`minimal`, `standard`, `portable`, `full` profiles) with SHA-256 verification and safe state restoration.
58
+
59
+ ## Installation
60
+
61
+ ```bash
62
+ pip install reframx
63
+ ```
64
+
65
+ > **Optional integrations:** `torch` and `mmengine` are intentionally **not** installed automatically so `pip install reframx` never overwrites your platform-specific CUDA/PyTorch build. Install PyTorch for your hardware from [pytorch.org](https://pytorch.org/get-started/locally/), and optionally `pip install mmengine` for `MMEngineBackend`.
66
+
67
+ ## Quick Start
68
+
69
+ ```python
70
+ import torch
71
+ from torch import nn
72
+ from torch.utils.data import TensorDataset
73
+ import reframx as rf
74
+ from reframx.integrations.mmengine import MMEngineBackend
75
+ from reframx.integrations.pytorch import (
76
+ BCEWithLogitsObjective,
77
+ TorchAccuracyEvaluator,
78
+ TorchClassificationMethod,
79
+ TorchDatasetAdapter,
80
+ TorchModelAdapter,
81
+ TorchStrategy,
82
+ )
83
+
84
+ # 1. Standard PyTorch model and dataset
85
+ raw_model = nn.Sequential(nn.Linear(16, 32), nn.ReLU(), nn.Linear(32, 1))
86
+ x_train, y_train = torch.randn(256, 16), torch.randint(0, 2, (256, 1)).float()
87
+ x_val, y_val = torch.randn(64, 16), torch.randint(0, 2, (64, 1)).float()
88
+ train_ds, val_ds = TensorDataset(x_train, y_train), TensorDataset(x_val, y_val)
89
+
90
+ # 2. Compose & run on GPU with MMEngine
91
+ experiment = rf.Experiment(
92
+ name="QuickDemo",
93
+ task=rf.ClassificationTask(num_classes=2),
94
+ method=TorchClassificationMethod(),
95
+ model=TorchModelAdapter(raw_model),
96
+ dataset=TorchDatasetAdapter(
97
+ datasets={"train": train_ds, "val": val_ds},
98
+ dataloader_kwargs={"batch_size": 32},
99
+ ),
100
+ objectives=BCEWithLogitsObjective(),
101
+ optimizers=torch.optim.AdamW(raw_model.parameters(), lr=1e-3),
102
+ evaluator=TorchAccuracyEvaluator(),
103
+ strategy=TorchStrategy(device="auto", precision="fp16", max_grad_norm=1.0),
104
+ backend=MMEngineBackend(work_dir="./work_dirs/quick_demo"),
105
+ )
106
+
107
+ run = experiment.run(max_epochs=5, catch_interrupt=True)
108
+ experiment.export("./work_dirs/quick_demo.rfx", profile="standard")
109
+ ```
110
+
111
+ ## Documentation
112
+
113
+ - [Getting Started & Quickstart](https://github.com/rushia314/reframx/blob/main/docs/getting_started/quickstart.md)
114
+ - [User Guide](https://github.com/rushia314/reframx/blob/main/docs/user_guide/usage_guide.md)
115
+ - [Developer Guide: Writing Custom Components](https://github.com/rushia314/reframx/blob/main/docs/developer_guide/writing_custom_components.md)
116
+ - [Developer Guide: Writing Plugins](https://github.com/rushia314/reframx/blob/main/docs/developer_guide/writing_plugins.md)
117
+ - [Architecture & Class/Module Diagrams](https://github.com/rushia314/reframx/blob/main/docs/developer_guide/architecture_diagrams.md)
118
+ - [API Reference](https://github.com/rushia314/reframx/blob/main/docs/api_reference/index.md)
119
+
120
+ ## Examples
121
+
122
+ - [examples/common_component.py](https://github.com/rushia314/reframx/blob/main/examples/common_component.py) — Contract & compatibility validation.
123
+ - [examples/basic/pytorch_experiment.py](https://github.com/rushia314/reframx/blob/main/examples/basic/pytorch_experiment.py) — Concise PyTorch experiment using built-ins.
124
+ - [examples/basic/text_attention_binary_classification.py](https://github.com/rushia314/reframx/blob/main/examples/basic/text_attention_binary_classification.py) — Multi-Head Attention text classification on GPU with `tiktoken`, HuggingFace `datasets`, and `MMEngineBackend`.
125
+ - [examples/custom_task/multilabel_task.py](https://github.com/rushia314/reframx/blob/main/examples/custom_task/multilabel_task.py) — Custom `BaseTask` with shorthand `RequirementGroup` & `IOContract`.
126
+ - [examples/custom_model/residual_model.py](https://github.com/rushia314/reframx/blob/main/examples/custom_model/residual_model.py) — Plain PyTorch `nn.Module` + `TorchModelAdapter` + custom validator + `.rfx` restore.
127
+ - [examples/custom_method/dual_optimizer_method.py](https://github.com/rushia314/reframx/blob/main/examples/custom_method/dual_optimizer_method.py) — Manual `BaseMethod` with 2 models, 2 losses, and 2 optimizers.
128
+ - [examples/custom_execution/custom_strategy_and_hooks.py](https://github.com/rushia314/reframx/blob/main/examples/custom_execution/custom_strategy_and_hooks.py) — Gradient accumulation, `EarlyStopOnLossHook`, `experiment.stop()`, and `catch_interrupt=True`.
129
+ - [examples/custom_instrumentation/probes_and_module_watch.py](https://github.com/rushia314/reframx/blob/main/examples/custom_instrumentation/probes_and_module_watch.py) — `rf.probe()` + non-invasive `watch_modules()` (`post_forward` & `backward`) + `check_nan_inf`.
130
+ - [examples/basic/full_experiment.py](https://github.com/rushia314/reframx/blob/main/examples/basic/full_experiment.py) & [examples/basic/real_binary_classification.py](https://github.com/rushia314/reframx/blob/main/examples/basic/real_binary_classification.py) — Zero-dependency pure-Python examples.
131
+
132
+ ## License
133
+
134
+ Released under the [MIT License](https://github.com/rushia314/reframx/blob/main/LICENSE).
@@ -0,0 +1,102 @@
1
+ # reframx
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/reframx.svg)](https://pypi.org/project/reframx/)
4
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/rushia314/reframx/blob/main/LICENSE)
6
+ [![Typing: Typed](https://img.shields.io/badge/typing-typed-brightgreen.svg)](https://peps.python.org/pep-0561/)
7
+
8
+ A modular, Python-first, code-first framework for neural network research.
9
+
10
+ > **Core philosophy:** Researchers own their architectures, losses, data pipelines, and training algorithms. `reframx` provides contract-driven composition, validation, pluggable execution backends, model instrumentation, plugins, and portable `.rfx` experiment snapshots — without forcing a fixed model hierarchy or a single `forward -> loss -> backward -> step` loop.
11
+
12
+ ## Key Features
13
+
14
+ - **Zero-dependency core:** Core contracts, validation, execution engine, instrumentation, plugins, and `.rfx` packaging rely only on the Python standard library.
15
+ - **Contract-driven composition:** `ComponentSpec`, `Requirement`, `RequirementGroup` (`all_of` / `any_of`), `Capability`, `IOContract`, and `validate_requirements()` with concise `str`/`dict` shorthand.
16
+ - **Full research freedom + sensible defaults:**
17
+ - `BaseMethod` for arbitrary multi-forward / multi-backward / multi-optimizer algorithms.
18
+ - `SupervisedMethod` and PyTorch built-ins (`TorchClassificationMethod`, `TorchRegressionMethod`, `CrossEntropyObjective`, `BCEWithLogitsObjective`, `MSEObjective`, `TorchAccuracyEvaluator`, `TorchRegressionEvaluator`) for rapid standard workflows.
19
+ - **Pluggable execution backends:**
20
+ - `NativeBackend` (default, zero dependencies, easy debugging, `experiment.stop()`).
21
+ - `MMEngineBackend` (optional, lazy-imported: GPU/DDP/FSDP, `OptimWrapper`, `ParamScheduler`, `CheckpointHook` with `save_best`/`save_last`, `Visualizer`).
22
+ - **Non-invasive PyTorch GPU integration:** `TorchModelAdapter`, `TorchDatasetAdapter`, and `TorchStrategy` (auto device placement, AMP `fp16`/`bf16`, `GradScaler`, `max_grad_norm`, gradient accumulation) — never overwrites your existing PyTorch/CUDA installation.
23
+ - **Model instrumentation:** `rf.probe()` / `rf.Probe` (zero-overhead pass-through via `contextvars`), `watch_module` / `watch_modules`, automatic tensor detach, `tensor_stats`, and `check_nan_inf`.
24
+ - **Plugin system:** `ComponentRegistry` and `PluginManager` supporting `load_plugin`, `load_file`, `load_path` (multi-file packages), `load_directory`, safe `discover_entry_points` / `load_entry_points`, and clean `unload_plugin`.
25
+ - **Portable `.rfx` archives:** Atomic, unencrypted ZIP experiment snapshots (`minimal`, `standard`, `portable`, `full` profiles) with SHA-256 verification and safe state restoration.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install reframx
31
+ ```
32
+
33
+ > **Optional integrations:** `torch` and `mmengine` are intentionally **not** installed automatically so `pip install reframx` never overwrites your platform-specific CUDA/PyTorch build. Install PyTorch for your hardware from [pytorch.org](https://pytorch.org/get-started/locally/), and optionally `pip install mmengine` for `MMEngineBackend`.
34
+
35
+ ## Quick Start
36
+
37
+ ```python
38
+ import torch
39
+ from torch import nn
40
+ from torch.utils.data import TensorDataset
41
+ import reframx as rf
42
+ from reframx.integrations.mmengine import MMEngineBackend
43
+ from reframx.integrations.pytorch import (
44
+ BCEWithLogitsObjective,
45
+ TorchAccuracyEvaluator,
46
+ TorchClassificationMethod,
47
+ TorchDatasetAdapter,
48
+ TorchModelAdapter,
49
+ TorchStrategy,
50
+ )
51
+
52
+ # 1. Standard PyTorch model and dataset
53
+ raw_model = nn.Sequential(nn.Linear(16, 32), nn.ReLU(), nn.Linear(32, 1))
54
+ x_train, y_train = torch.randn(256, 16), torch.randint(0, 2, (256, 1)).float()
55
+ x_val, y_val = torch.randn(64, 16), torch.randint(0, 2, (64, 1)).float()
56
+ train_ds, val_ds = TensorDataset(x_train, y_train), TensorDataset(x_val, y_val)
57
+
58
+ # 2. Compose & run on GPU with MMEngine
59
+ experiment = rf.Experiment(
60
+ name="QuickDemo",
61
+ task=rf.ClassificationTask(num_classes=2),
62
+ method=TorchClassificationMethod(),
63
+ model=TorchModelAdapter(raw_model),
64
+ dataset=TorchDatasetAdapter(
65
+ datasets={"train": train_ds, "val": val_ds},
66
+ dataloader_kwargs={"batch_size": 32},
67
+ ),
68
+ objectives=BCEWithLogitsObjective(),
69
+ optimizers=torch.optim.AdamW(raw_model.parameters(), lr=1e-3),
70
+ evaluator=TorchAccuracyEvaluator(),
71
+ strategy=TorchStrategy(device="auto", precision="fp16", max_grad_norm=1.0),
72
+ backend=MMEngineBackend(work_dir="./work_dirs/quick_demo"),
73
+ )
74
+
75
+ run = experiment.run(max_epochs=5, catch_interrupt=True)
76
+ experiment.export("./work_dirs/quick_demo.rfx", profile="standard")
77
+ ```
78
+
79
+ ## Documentation
80
+
81
+ - [Getting Started & Quickstart](https://github.com/rushia314/reframx/blob/main/docs/getting_started/quickstart.md)
82
+ - [User Guide](https://github.com/rushia314/reframx/blob/main/docs/user_guide/usage_guide.md)
83
+ - [Developer Guide: Writing Custom Components](https://github.com/rushia314/reframx/blob/main/docs/developer_guide/writing_custom_components.md)
84
+ - [Developer Guide: Writing Plugins](https://github.com/rushia314/reframx/blob/main/docs/developer_guide/writing_plugins.md)
85
+ - [Architecture & Class/Module Diagrams](https://github.com/rushia314/reframx/blob/main/docs/developer_guide/architecture_diagrams.md)
86
+ - [API Reference](https://github.com/rushia314/reframx/blob/main/docs/api_reference/index.md)
87
+
88
+ ## Examples
89
+
90
+ - [examples/common_component.py](https://github.com/rushia314/reframx/blob/main/examples/common_component.py) — Contract & compatibility validation.
91
+ - [examples/basic/pytorch_experiment.py](https://github.com/rushia314/reframx/blob/main/examples/basic/pytorch_experiment.py) — Concise PyTorch experiment using built-ins.
92
+ - [examples/basic/text_attention_binary_classification.py](https://github.com/rushia314/reframx/blob/main/examples/basic/text_attention_binary_classification.py) — Multi-Head Attention text classification on GPU with `tiktoken`, HuggingFace `datasets`, and `MMEngineBackend`.
93
+ - [examples/custom_task/multilabel_task.py](https://github.com/rushia314/reframx/blob/main/examples/custom_task/multilabel_task.py) — Custom `BaseTask` with shorthand `RequirementGroup` & `IOContract`.
94
+ - [examples/custom_model/residual_model.py](https://github.com/rushia314/reframx/blob/main/examples/custom_model/residual_model.py) — Plain PyTorch `nn.Module` + `TorchModelAdapter` + custom validator + `.rfx` restore.
95
+ - [examples/custom_method/dual_optimizer_method.py](https://github.com/rushia314/reframx/blob/main/examples/custom_method/dual_optimizer_method.py) — Manual `BaseMethod` with 2 models, 2 losses, and 2 optimizers.
96
+ - [examples/custom_execution/custom_strategy_and_hooks.py](https://github.com/rushia314/reframx/blob/main/examples/custom_execution/custom_strategy_and_hooks.py) — Gradient accumulation, `EarlyStopOnLossHook`, `experiment.stop()`, and `catch_interrupt=True`.
97
+ - [examples/custom_instrumentation/probes_and_module_watch.py](https://github.com/rushia314/reframx/blob/main/examples/custom_instrumentation/probes_and_module_watch.py) — `rf.probe()` + non-invasive `watch_modules()` (`post_forward` & `backward`) + `check_nan_inf`.
98
+ - [examples/basic/full_experiment.py](https://github.com/rushia314/reframx/blob/main/examples/basic/full_experiment.py) & [examples/basic/real_binary_classification.py](https://github.com/rushia314/reframx/blob/main/examples/basic/real_binary_classification.py) — Zero-dependency pure-Python examples.
99
+
100
+ ## License
101
+
102
+ Released under the [MIT License](https://github.com/rushia314/reframx/blob/main/LICENSE).
@@ -0,0 +1,104 @@
1
+ [build-system]
2
+ requires = [
3
+ "setuptools>=77",
4
+ "wheel",
5
+ ]
6
+ build-backend = "setuptools.build_meta"
7
+
8
+ [project]
9
+ name = "reframx"
10
+ version = "0.1.1"
11
+ description = "A modular, code-first framework for neural network research."
12
+ readme = "README.md"
13
+ license = "MIT"
14
+ license-files = ["LICENSE"]
15
+ requires-python = ">=3.10"
16
+ authors = [
17
+ { name = "Research Framework Contributors" },
18
+ ]
19
+ keywords = [
20
+ "deep-learning",
21
+ "neural-networks",
22
+ "research",
23
+ "pytorch",
24
+ "mmengine",
25
+ "machine-learning",
26
+ ]
27
+ classifiers = [
28
+ "Development Status :: 3 - Alpha",
29
+ "Intended Audience :: Science/Research",
30
+ "Intended Audience :: Developers",
31
+ "Operating System :: OS Independent",
32
+ "Programming Language :: Python :: 3",
33
+ "Programming Language :: Python :: 3.10",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ "Programming Language :: Python :: 3.13",
37
+ "Programming Language :: Python :: 3.14",
38
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
39
+ "Typing :: Typed",
40
+ ]
41
+ dependencies = []
42
+
43
+ [project.optional-dependencies]
44
+ dev = [
45
+ "pytest>=8.0",
46
+ "mypy>=1.8",
47
+ "ruff>=0.9",
48
+ ]
49
+
50
+ [project.urls]
51
+ Homepage = "https://github.com/rushia314/reframx"
52
+ Repository = "https://github.com/rushia314/reframx"
53
+ Documentation = "https://github.com/rushia314/reframx/tree/main/docs"
54
+ Issues = "https://github.com/rushia314/reframx/issues"
55
+
56
+ [tool.setuptools.packages.find]
57
+ where = ["src"]
58
+ exclude = [
59
+ "reframx.analysis*",
60
+ "reframx.cli*",
61
+ "reframx.configuration*",
62
+ "reframx.core.events*",
63
+ "reframx.datasets.builtin*",
64
+ "reframx.datasets.pipelines*",
65
+ "reframx.development*",
66
+ "reframx.evaluators.builtin*",
67
+ "reframx.execution.loops*",
68
+ "reframx.execution.optimizers*",
69
+ "reframx.execution.state*",
70
+ "reframx.integrations.transformers*",
71
+ "reframx.logging*",
72
+ "reframx.methods.builtin*",
73
+ "reframx.models.adapters*",
74
+ "reframx.models.builtin*",
75
+ "reframx.models.loaders*",
76
+ "reframx.objectives.builtin*",
77
+ "reframx.persistence*",
78
+ "reframx.strategies.builtin*",
79
+ "reframx.utils*",
80
+ ]
81
+
82
+ [tool.setuptools.package-data]
83
+ reframx = ["py.typed"]
84
+
85
+ [tool.setuptools.exclude-package-data]
86
+ "reframx.experiments" = ["builder.py", "manager.py"]
87
+
88
+ [tool.pytest.ini_options]
89
+ pythonpath = ["src"]
90
+ testpaths = ["tests"]
91
+ addopts = "-ra"
92
+
93
+ [tool.mypy]
94
+ python_version = "3.10"
95
+ warn_return_any = true
96
+ warn_unused_configs = true
97
+ check_untyped_defs = true
98
+
99
+ [tool.ruff]
100
+ line-length = 100
101
+ target-version = "py310"
102
+
103
+ [tool.ruff.lint]
104
+ select = ["E", "F", "I", "B"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,180 @@
1
+ """Research Framework public package namespace."""
2
+
3
+ from reframx.api import (
4
+ DEFAULT_ENTRY_POINT_GROUP,
5
+ RFX_EXTENSION,
6
+ ArchiveError,
7
+ ArchiveManifest,
8
+ BaseDataset,
9
+ BaseEvaluator,
10
+ BaseHook,
11
+ BaseMethod,
12
+ BaseModel,
13
+ BaseObjective,
14
+ BaseStrategy,
15
+ BaseTask,
16
+ Capability,
17
+ CausalLMTask,
18
+ ClassificationTask,
19
+ ComponentHandle,
20
+ ComponentIntegrationError,
21
+ ComponentMetadata,
22
+ ComponentRegistry,
23
+ ComponentSpec,
24
+ ComponentValidator,
25
+ ConfigProvider,
26
+ DatasetFieldAdapter,
27
+ DatasetProtocol,
28
+ DatasetSpec,
29
+ DiscoveredPlugin,
30
+ EvaluationDefinition,
31
+ EvaluatorProtocol,
32
+ EvaluatorSpec,
33
+ ExecutionBackend,
34
+ ExecutionContext,
35
+ ExecutionEngine,
36
+ ExecutionState,
37
+ Experiment,
38
+ ExportProfile,
39
+ ImportedExperiment,
40
+ InstrumentationEvent,
41
+ InstrumentationHook,
42
+ InstrumentationManager,
43
+ InstrumentationRecord,
44
+ InvalidSpecificationError,
45
+ IOContract,
46
+ LoadedPlugin,
47
+ MethodResult,
48
+ MethodSpec,
49
+ ModelAdapter,
50
+ ModelSpec,
51
+ NativeBackend,
52
+ ObjectiveGoal,
53
+ ObjectiveSpec,
54
+ PluginLoadError,
55
+ PluginManager,
56
+ PluginManifest,
57
+ PluginProtocol,
58
+ Probe,
59
+ ProblemDefinition,
60
+ RegistrationEntry,
61
+ RegressionTask,
62
+ Requirement,
63
+ RequirementGroup,
64
+ ResearchFrameworkError,
65
+ Run,
66
+ RunStatus,
67
+ SpecProvider,
68
+ StandardBackwardStrategy,
69
+ StateProvider,
70
+ StrategySpec,
71
+ SupervisedMethod,
72
+ TaskSpec,
73
+ ValidationContext,
74
+ ValidationFailedError,
75
+ ValidationIssue,
76
+ ValidationReport,
77
+ ValidationSeverity,
78
+ ValidatorContractError,
79
+ WatchHandle,
80
+ check_nan_inf,
81
+ default_plugin_manager,
82
+ default_registry,
83
+ export_experiment,
84
+ load_experiment,
85
+ probe,
86
+ run_component_validator,
87
+ tensor_stats,
88
+ validate_requirements,
89
+ )
90
+
91
+ __version__ = "0.1.1"
92
+
93
+ __all__ = [
94
+ "__version__",
95
+ "ArchiveError",
96
+ "ArchiveManifest",
97
+ "BaseDataset",
98
+ "BaseEvaluator",
99
+ "BaseHook",
100
+ "BaseMethod",
101
+ "BaseModel",
102
+ "BaseObjective",
103
+ "BaseStrategy",
104
+ "BaseTask",
105
+ "Capability",
106
+ "CausalLMTask",
107
+ "ClassificationTask",
108
+ "ComponentHandle",
109
+ "ComponentIntegrationError",
110
+ "ComponentMetadata",
111
+ "ComponentRegistry",
112
+ "ComponentSpec",
113
+ "ComponentValidator",
114
+ "ConfigProvider",
115
+ "DEFAULT_ENTRY_POINT_GROUP",
116
+ "DatasetFieldAdapter",
117
+ "DatasetProtocol",
118
+ "DatasetSpec",
119
+ "DiscoveredPlugin",
120
+ "EvaluationDefinition",
121
+ "EvaluatorProtocol",
122
+ "EvaluatorSpec",
123
+ "ExecutionBackend",
124
+ "ExecutionContext",
125
+ "ExecutionEngine",
126
+ "ExecutionState",
127
+ "Experiment",
128
+ "ExportProfile",
129
+ "IOContract",
130
+ "ImportedExperiment",
131
+ "InstrumentationEvent",
132
+ "InstrumentationHook",
133
+ "InstrumentationManager",
134
+ "InstrumentationRecord",
135
+ "InvalidSpecificationError",
136
+ "LoadedPlugin",
137
+ "MethodResult",
138
+ "MethodSpec",
139
+ "ModelAdapter",
140
+ "ModelSpec",
141
+ "NativeBackend",
142
+ "ObjectiveGoal",
143
+ "ObjectiveSpec",
144
+ "PluginLoadError",
145
+ "PluginManager",
146
+ "PluginManifest",
147
+ "PluginProtocol",
148
+ "Probe",
149
+ "ProblemDefinition",
150
+ "RFX_EXTENSION",
151
+ "RegistrationEntry",
152
+ "RegressionTask",
153
+ "Requirement",
154
+ "RequirementGroup",
155
+ "ResearchFrameworkError",
156
+ "Run",
157
+ "RunStatus",
158
+ "SpecProvider",
159
+ "StandardBackwardStrategy",
160
+ "StateProvider",
161
+ "StrategySpec",
162
+ "SupervisedMethod",
163
+ "TaskSpec",
164
+ "ValidationContext",
165
+ "ValidationFailedError",
166
+ "ValidationIssue",
167
+ "ValidationReport",
168
+ "ValidationSeverity",
169
+ "ValidatorContractError",
170
+ "WatchHandle",
171
+ "check_nan_inf",
172
+ "default_plugin_manager",
173
+ "default_registry",
174
+ "export_experiment",
175
+ "load_experiment",
176
+ "probe",
177
+ "run_component_validator",
178
+ "tensor_stats",
179
+ "validate_requirements",
180
+ ]