amv-forge 2.0.2__tar.gz → 2.0.4__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 (88) hide show
  1. {amv_forge-2.0.2 → amv_forge-2.0.4}/PKG-INFO +32 -7
  2. {amv_forge-2.0.2 → amv_forge-2.0.4}/README.md +26 -3
  3. {amv_forge-2.0.2 → amv_forge-2.0.4}/pyproject.toml +8 -4
  4. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/amv_forge.egg-info/PKG-INFO +32 -7
  5. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/amv_forge.egg-info/SOURCES.txt +8 -0
  6. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/amv_forge.egg-info/requires.txt +3 -0
  7. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/__init__.py +1 -1
  8. amv_forge-2.0.4/src/forge/runtime/__init__.py +23 -0
  9. amv_forge-2.0.4/src/forge/runtime/__main__.py +112 -0
  10. amv_forge-2.0.4/src/forge/runtime/engine.py +488 -0
  11. amv_forge-2.0.4/src/forge/runtime/errors.py +48 -0
  12. amv_forge-2.0.4/src/forge/runtime/graph.py +271 -0
  13. amv_forge-2.0.4/src/forge/runtime/kernel_manifest.json +443 -0
  14. amv_forge-2.0.4/src/forge/runtime/kernels.py +399 -0
  15. amv_forge-2.0.4/tests/test_runtime_engine.py +200 -0
  16. {amv_forge-2.0.2 → amv_forge-2.0.4}/setup.cfg +0 -0
  17. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/amv_forge.egg-info/dependency_links.txt +0 -0
  18. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/amv_forge.egg-info/top_level.txt +0 -0
  19. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/__init__.pyi +0 -0
  20. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/autograd.py +0 -0
  21. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/bridge.py +0 -0
  22. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/data.py +0 -0
  23. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/device.py +0 -0
  24. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/distributions.py +0 -0
  25. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/errors.py +0 -0
  26. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/fft.py +0 -0
  27. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/functional.py +0 -0
  28. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/generated/__init__.py +0 -0
  29. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/generated/op_schema.py +0 -0
  30. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/graph.py +0 -0
  31. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/linalg.py +0 -0
  32. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/models/__init__.py +0 -0
  33. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/models/llama.py +0 -0
  34. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/models/nanogpt.py +0 -0
  35. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/nn.py +0 -0
  36. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/nn.pyi +0 -0
  37. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/ops.py +0 -0
  38. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/optim.py +0 -0
  39. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/optim.pyi +0 -0
  40. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/pipeline.py +0 -0
  41. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/py.typed +0 -0
  42. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/rl/__init__.py +0 -0
  43. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/rl/cartpole.py +0 -0
  44. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/serialization.py +0 -0
  45. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/special.py +0 -0
  46. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/tensor.py +0 -0
  47. {amv_forge-2.0.2 → amv_forge-2.0.4}/src/forge/tensor.pyi +0 -0
  48. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_activation_functions.py +0 -0
  49. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_adversarial_fuzzer.py +0 -0
  50. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_arithmetic_ops.py +0 -0
  51. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_autograd.py +0 -0
  52. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_benchmark.py +0 -0
  53. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_broadcasting.py +0 -0
  54. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_compatibility.py +0 -0
  55. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_core.py +0 -0
  56. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_cpu_ops.py +0 -0
  57. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_dataloader.py +0 -0
  58. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_edge_cases.py +0 -0
  59. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_error_handling.py +0 -0
  60. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_exceptions.py +0 -0
  61. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_extreme.py +0 -0
  62. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_finite_difference.py +0 -0
  63. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_generated_schema.py +0 -0
  64. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_gpu_optimizers.py +0 -0
  65. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_gpu_sgd_contract.py +0 -0
  66. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_graph_monster.py +0 -0
  67. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_hub_models_and_rl.py +0 -0
  68. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_inplace_version_lock.py +0 -0
  69. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_loss_functions.py +0 -0
  70. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_machine_gun.py +0 -0
  71. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_massive_cpu.py +0 -0
  72. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_math_ops.py +0 -0
  73. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_matrix_ops.py +0 -0
  74. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_module_to_contract.py +0 -0
  75. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_nn_module.py +0 -0
  76. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_ops_slice.py +0 -0
  77. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_optimizer_versioning_contract.py +0 -0
  78. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_optimizers.py +0 -0
  79. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_reduction_ops.py +0 -0
  80. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_release2_llm_modules.py +0 -0
  81. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_security.py +0 -0
  82. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_shape_ops.py +0 -0
  83. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_stress.py +0 -0
  84. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_tensor_creation.py +0 -0
  85. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_unbroadcast.py +0 -0
  86. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_v3_features.py +0 -0
  87. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_v3_validation.py +0 -0
  88. {amv_forge-2.0.2 → amv_forge-2.0.4}/tests/test_vram_crusher.py +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amv-forge
3
- Version: 2.0.2
3
+ Version: 2.0.4
4
4
  Summary: High-performance WebGPU-accelerated tensor computation engine with reverse-mode autograd for browser and edge deep learning.
5
- Author-email: AMEVA Foundation <contact@uno-km.com>
5
+ Author-email: AMEVA Foundation <amv.foundation.kr@gmail.com>
6
6
  Maintainer: AMEVA Engineering Team
7
7
  License: MIT
8
- Project-URL: Homepage, https://uno-km.github.io/amv-forge/
9
- Project-URL: Documentation, https://uno-km.github.io/amv-forge/
8
+ Project-URL: Homepage, https://ameva.pro/lib/forge/
9
+ Project-URL: Documentation, https://ameva.pro/lib/forge/
10
10
  Project-URL: Repository, https://github.com/uno-km/amv-forge
11
11
  Project-URL: Issues, https://github.com/uno-km/amv-forge/issues
12
12
  Project-URL: Changelog, https://github.com/uno-km/amv-forge/blob/main/RELEASE_NOTES.md
@@ -28,6 +28,8 @@ Classifier: Operating System :: OS Independent
28
28
  Requires-Python: >=3.9
29
29
  Description-Content-Type: text/markdown
30
30
  Requires-Dist: numpy>=1.20.0
31
+ Provides-Extra: gpu
32
+ Requires-Dist: wgpu>=0.33; extra == "gpu"
31
33
  Provides-Extra: dev
32
34
  Requires-Dist: pytest>=7.0; extra == "dev"
33
35
  Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
@@ -39,7 +41,7 @@ Requires-Dist: pytest-cov>=4.0; extra == "dev"
39
41
  [![Python Version](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://pypi.org/project/amv-forge/)
40
42
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/uno-km/amv-forge/blob/main/LICENSE)
41
43
  [![Test Suite](https://img.shields.io/badge/tests-279%2F279%20passed%20(100%25)-brightgreen.svg)](https://github.com/uno-km/amv-forge)
42
- [![WebGPU Acceleration](https://img.shields.io/badge/acceleration-WebGPU%20WGSL%20%2B%20CPU-orange.svg)](https://uno-km.github.io/amv-forge/)
44
+ [![WebGPU Acceleration](https://img.shields.io/badge/acceleration-WebGPU%20WGSL%20%2B%20CPU-orange.svg)](https://ameva.pro/lib/forge/)
43
45
 
44
46
  **High-Performance Client-Side Tensor Computation Engine & Reverse-Mode Autograd Framework Powered by WebGPU.**
45
47
 
@@ -191,13 +193,36 @@ audio_features = conv(power_spec)
191
193
 
192
194
  ---
193
195
 
196
+ ## Native GPU execution: `forge.runtime` (PC/Mac, no browser)
197
+
198
+ `forge.runtime` runs the amv-forge engine's trusted WGSL kernels on the local GPU through wgpu-py (wgpu-native: Vulkan, Metal or D3D12). It uses the same kernel manifest, WGSL, graph format and error codes as the TypeScript engine (`amv-forge/core`). Tests check that both languages generate byte-identical WGSL.
199
+
200
+ ```bash
201
+ pip install "amv-forge[gpu]"
202
+ python -m forge.runtime doctor
203
+ ```
204
+
205
+ ```python
206
+ import numpy as np
207
+ from forge.runtime import Forge
208
+
209
+ forge = Forge.create(backend="auto", fallback=["cpu"]) # no fallback given = error when no GPU
210
+ print(forge.capabilities()["backend"])
211
+ r = forge.run("matmul", {"a": np.ones((64, 32), np.float32), "b": np.ones((32, 16), np.float32)})
212
+ print(r.backend, r.output.shape)
213
+ print(forge.verify("softmax", {"x": np.random.rand(8, 100).astype(np.float32)})) # GPU vs numpy reference
214
+ exe = forge.compile({"inputs": {"x": {"shape": [None, 8]}}, "nodes": [{"id": "y", "type": "gelu", "inputs": {"x": "x"}}], "outputs": {"y": "y"}})
215
+ ```
216
+
217
+ Not implemented in the Python track: task nodes, chunked or streamed execution of over-limit tensors, custom kernels, autotuning, profiling.
218
+
194
219
  ## In-Browser Zero-Install Execution (WebGPU + Pyodide)
195
220
 
196
221
  amv-forge packages a single bundled JavaScript distribution (`forge-py-bundle.js`) that mounts into browser-native Pyodide runtimes:
197
222
 
198
223
  ```html
199
224
  <script src="https://cdn.jsdelivr.net/pyodide/v0.26.2/full/pyodide.js"></script>
200
- <script src="https://uno-km.github.io/amv-forge/dist/forge-py-bundle.js"></script>
225
+ <script src="https://ameva.pro/lib/forge/dist/forge-py-bundle.js"></script>
201
226
  <script>
202
227
  async function runClientDeepLearning() {
203
228
  let pyodide = await loadPyodide();
@@ -229,7 +254,7 @@ The AMEVA Foundation is dedicated to the **democratisation of client-side artifi
229
254
  - ?¤– **Decentralized LLM Transformers**: Zero-install character and subword transformer models with zero cloud dependency.
230
255
  - ?”’ **Privacy-First AI Sovereignty**: Sovereign on-device machine learning where private data never leaves client silicon.
231
256
 
232
- * **Foundation Portal**: [https://uno-km.github.io/amv-forge/](https://uno-km.github.io/amv-forge/)
257
+ * **Foundation Portal**: [https://ameva.pro/lib/forge/](https://ameva.pro/lib/forge/)
233
258
  * **Official Repository**: [https://github.com/uno-km/amv-forge](https://github.com/uno-km/amv-forge)
234
259
  * **Community & Governance**: [https://github.com/uno-km/amv-forge/issues](https://github.com/uno-km/amv-forge/issues)
235
260
  * **Sponsorship & Research Partnerships**: [https://github.com/uno-km](https://github.com/uno-km)
@@ -4,7 +4,7 @@
4
4
  [![Python Version](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://pypi.org/project/amv-forge/)
5
5
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/uno-km/amv-forge/blob/main/LICENSE)
6
6
  [![Test Suite](https://img.shields.io/badge/tests-279%2F279%20passed%20(100%25)-brightgreen.svg)](https://github.com/uno-km/amv-forge)
7
- [![WebGPU Acceleration](https://img.shields.io/badge/acceleration-WebGPU%20WGSL%20%2B%20CPU-orange.svg)](https://uno-km.github.io/amv-forge/)
7
+ [![WebGPU Acceleration](https://img.shields.io/badge/acceleration-WebGPU%20WGSL%20%2B%20CPU-orange.svg)](https://ameva.pro/lib/forge/)
8
8
 
9
9
  **High-Performance Client-Side Tensor Computation Engine & Reverse-Mode Autograd Framework Powered by WebGPU.**
10
10
 
@@ -156,13 +156,36 @@ audio_features = conv(power_spec)
156
156
 
157
157
  ---
158
158
 
159
+ ## Native GPU execution: `forge.runtime` (PC/Mac, no browser)
160
+
161
+ `forge.runtime` runs the amv-forge engine's trusted WGSL kernels on the local GPU through wgpu-py (wgpu-native: Vulkan, Metal or D3D12). It uses the same kernel manifest, WGSL, graph format and error codes as the TypeScript engine (`amv-forge/core`). Tests check that both languages generate byte-identical WGSL.
162
+
163
+ ```bash
164
+ pip install "amv-forge[gpu]"
165
+ python -m forge.runtime doctor
166
+ ```
167
+
168
+ ```python
169
+ import numpy as np
170
+ from forge.runtime import Forge
171
+
172
+ forge = Forge.create(backend="auto", fallback=["cpu"]) # no fallback given = error when no GPU
173
+ print(forge.capabilities()["backend"])
174
+ r = forge.run("matmul", {"a": np.ones((64, 32), np.float32), "b": np.ones((32, 16), np.float32)})
175
+ print(r.backend, r.output.shape)
176
+ print(forge.verify("softmax", {"x": np.random.rand(8, 100).astype(np.float32)})) # GPU vs numpy reference
177
+ exe = forge.compile({"inputs": {"x": {"shape": [None, 8]}}, "nodes": [{"id": "y", "type": "gelu", "inputs": {"x": "x"}}], "outputs": {"y": "y"}})
178
+ ```
179
+
180
+ Not implemented in the Python track: task nodes, chunked or streamed execution of over-limit tensors, custom kernels, autotuning, profiling.
181
+
159
182
  ## In-Browser Zero-Install Execution (WebGPU + Pyodide)
160
183
 
161
184
  amv-forge packages a single bundled JavaScript distribution (`forge-py-bundle.js`) that mounts into browser-native Pyodide runtimes:
162
185
 
163
186
  ```html
164
187
  <script src="https://cdn.jsdelivr.net/pyodide/v0.26.2/full/pyodide.js"></script>
165
- <script src="https://uno-km.github.io/amv-forge/dist/forge-py-bundle.js"></script>
188
+ <script src="https://ameva.pro/lib/forge/dist/forge-py-bundle.js"></script>
166
189
  <script>
167
190
  async function runClientDeepLearning() {
168
191
  let pyodide = await loadPyodide();
@@ -194,7 +217,7 @@ The AMEVA Foundation is dedicated to the **democratisation of client-side artifi
194
217
  - ?¤– **Decentralized LLM Transformers**: Zero-install character and subword transformer models with zero cloud dependency.
195
218
  - ?”’ **Privacy-First AI Sovereignty**: Sovereign on-device machine learning where private data never leaves client silicon.
196
219
 
197
- * **Foundation Portal**: [https://uno-km.github.io/amv-forge/](https://uno-km.github.io/amv-forge/)
220
+ * **Foundation Portal**: [https://ameva.pro/lib/forge/](https://ameva.pro/lib/forge/)
198
221
  * **Official Repository**: [https://github.com/uno-km/amv-forge](https://github.com/uno-km/amv-forge)
199
222
  * **Community & Governance**: [https://github.com/uno-km/amv-forge/issues](https://github.com/uno-km/amv-forge/issues)
200
223
  * **Sponsorship & Research Partnerships**: [https://github.com/uno-km](https://github.com/uno-km)
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "amv-forge"
7
- version = "2.0.2"
7
+ version = "2.0.4"
8
8
  description = "High-performance WebGPU-accelerated tensor computation engine with reverse-mode autograd for browser and edge deep learning."
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
11
11
  requires-python = ">=3.9"
12
12
  authors = [
13
- {name = "AMEVA Foundation", email = "contact@uno-km.com"}
13
+ {name = "AMEVA Foundation", email = "amv.foundation.kr@gmail.com"}
14
14
  ]
15
15
  maintainers = [
16
16
  {name = "AMEVA Engineering Team"}
@@ -47,6 +47,9 @@ dependencies = [
47
47
  ]
48
48
 
49
49
  [project.optional-dependencies]
50
+ gpu = [
51
+ "wgpu>=0.33",
52
+ ]
50
53
  dev = [
51
54
  "pytest>=7.0",
52
55
  "pytest-asyncio>=0.23",
@@ -54,8 +57,8 @@ dev = [
54
57
  ]
55
58
 
56
59
  [project.urls]
57
- Homepage = "https://uno-km.github.io/amv-forge/"
58
- Documentation = "https://uno-km.github.io/amv-forge/"
60
+ Homepage = "https://ameva.pro/lib/forge/"
61
+ Documentation = "https://ameva.pro/lib/forge/"
59
62
  Repository = "https://github.com/uno-km/amv-forge"
60
63
  Issues = "https://github.com/uno-km/amv-forge/issues"
61
64
  Changelog = "https://github.com/uno-km/amv-forge/blob/main/RELEASE_NOTES.md"
@@ -65,6 +68,7 @@ where = ["src"]
65
68
 
66
69
  [tool.setuptools.package-data]
67
70
  forge = ["py.typed"]
71
+ "forge.runtime" = ["kernel_manifest.json"]
68
72
 
69
73
  [tool.pytest.ini_options]
70
74
  testpaths = ["tests"]
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amv-forge
3
- Version: 2.0.2
3
+ Version: 2.0.4
4
4
  Summary: High-performance WebGPU-accelerated tensor computation engine with reverse-mode autograd for browser and edge deep learning.
5
- Author-email: AMEVA Foundation <contact@uno-km.com>
5
+ Author-email: AMEVA Foundation <amv.foundation.kr@gmail.com>
6
6
  Maintainer: AMEVA Engineering Team
7
7
  License: MIT
8
- Project-URL: Homepage, https://uno-km.github.io/amv-forge/
9
- Project-URL: Documentation, https://uno-km.github.io/amv-forge/
8
+ Project-URL: Homepage, https://ameva.pro/lib/forge/
9
+ Project-URL: Documentation, https://ameva.pro/lib/forge/
10
10
  Project-URL: Repository, https://github.com/uno-km/amv-forge
11
11
  Project-URL: Issues, https://github.com/uno-km/amv-forge/issues
12
12
  Project-URL: Changelog, https://github.com/uno-km/amv-forge/blob/main/RELEASE_NOTES.md
@@ -28,6 +28,8 @@ Classifier: Operating System :: OS Independent
28
28
  Requires-Python: >=3.9
29
29
  Description-Content-Type: text/markdown
30
30
  Requires-Dist: numpy>=1.20.0
31
+ Provides-Extra: gpu
32
+ Requires-Dist: wgpu>=0.33; extra == "gpu"
31
33
  Provides-Extra: dev
32
34
  Requires-Dist: pytest>=7.0; extra == "dev"
33
35
  Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
@@ -39,7 +41,7 @@ Requires-Dist: pytest-cov>=4.0; extra == "dev"
39
41
  [![Python Version](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://pypi.org/project/amv-forge/)
40
42
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/uno-km/amv-forge/blob/main/LICENSE)
41
43
  [![Test Suite](https://img.shields.io/badge/tests-279%2F279%20passed%20(100%25)-brightgreen.svg)](https://github.com/uno-km/amv-forge)
42
- [![WebGPU Acceleration](https://img.shields.io/badge/acceleration-WebGPU%20WGSL%20%2B%20CPU-orange.svg)](https://uno-km.github.io/amv-forge/)
44
+ [![WebGPU Acceleration](https://img.shields.io/badge/acceleration-WebGPU%20WGSL%20%2B%20CPU-orange.svg)](https://ameva.pro/lib/forge/)
43
45
 
44
46
  **High-Performance Client-Side Tensor Computation Engine & Reverse-Mode Autograd Framework Powered by WebGPU.**
45
47
 
@@ -191,13 +193,36 @@ audio_features = conv(power_spec)
191
193
 
192
194
  ---
193
195
 
196
+ ## Native GPU execution: `forge.runtime` (PC/Mac, no browser)
197
+
198
+ `forge.runtime` runs the amv-forge engine's trusted WGSL kernels on the local GPU through wgpu-py (wgpu-native: Vulkan, Metal or D3D12). It uses the same kernel manifest, WGSL, graph format and error codes as the TypeScript engine (`amv-forge/core`). Tests check that both languages generate byte-identical WGSL.
199
+
200
+ ```bash
201
+ pip install "amv-forge[gpu]"
202
+ python -m forge.runtime doctor
203
+ ```
204
+
205
+ ```python
206
+ import numpy as np
207
+ from forge.runtime import Forge
208
+
209
+ forge = Forge.create(backend="auto", fallback=["cpu"]) # no fallback given = error when no GPU
210
+ print(forge.capabilities()["backend"])
211
+ r = forge.run("matmul", {"a": np.ones((64, 32), np.float32), "b": np.ones((32, 16), np.float32)})
212
+ print(r.backend, r.output.shape)
213
+ print(forge.verify("softmax", {"x": np.random.rand(8, 100).astype(np.float32)})) # GPU vs numpy reference
214
+ exe = forge.compile({"inputs": {"x": {"shape": [None, 8]}}, "nodes": [{"id": "y", "type": "gelu", "inputs": {"x": "x"}}], "outputs": {"y": "y"}})
215
+ ```
216
+
217
+ Not implemented in the Python track: task nodes, chunked or streamed execution of over-limit tensors, custom kernels, autotuning, profiling.
218
+
194
219
  ## In-Browser Zero-Install Execution (WebGPU + Pyodide)
195
220
 
196
221
  amv-forge packages a single bundled JavaScript distribution (`forge-py-bundle.js`) that mounts into browser-native Pyodide runtimes:
197
222
 
198
223
  ```html
199
224
  <script src="https://cdn.jsdelivr.net/pyodide/v0.26.2/full/pyodide.js"></script>
200
- <script src="https://uno-km.github.io/amv-forge/dist/forge-py-bundle.js"></script>
225
+ <script src="https://ameva.pro/lib/forge/dist/forge-py-bundle.js"></script>
201
226
  <script>
202
227
  async function runClientDeepLearning() {
203
228
  let pyodide = await loadPyodide();
@@ -229,7 +254,7 @@ The AMEVA Foundation is dedicated to the **democratisation of client-side artifi
229
254
  - ?¤– **Decentralized LLM Transformers**: Zero-install character and subword transformer models with zero cloud dependency.
230
255
  - ?”’ **Privacy-First AI Sovereignty**: Sovereign on-device machine learning where private data never leaves client silicon.
231
256
 
232
- * **Foundation Portal**: [https://uno-km.github.io/amv-forge/](https://uno-km.github.io/amv-forge/)
257
+ * **Foundation Portal**: [https://ameva.pro/lib/forge/](https://ameva.pro/lib/forge/)
233
258
  * **Official Repository**: [https://github.com/uno-km/amv-forge](https://github.com/uno-km/amv-forge)
234
259
  * **Community & Governance**: [https://github.com/uno-km/amv-forge/issues](https://github.com/uno-km/amv-forge/issues)
235
260
  * **Sponsorship & Research Partnerships**: [https://github.com/uno-km](https://github.com/uno-km)
@@ -35,6 +35,13 @@ src/forge/models/llama.py
35
35
  src/forge/models/nanogpt.py
36
36
  src/forge/rl/__init__.py
37
37
  src/forge/rl/cartpole.py
38
+ src/forge/runtime/__init__.py
39
+ src/forge/runtime/__main__.py
40
+ src/forge/runtime/engine.py
41
+ src/forge/runtime/errors.py
42
+ src/forge/runtime/graph.py
43
+ src/forge/runtime/kernel_manifest.json
44
+ src/forge/runtime/kernels.py
38
45
  tests/test_activation_functions.py
39
46
  tests/test_adversarial_fuzzer.py
40
47
  tests/test_arithmetic_ops.py
@@ -68,6 +75,7 @@ tests/test_optimizer_versioning_contract.py
68
75
  tests/test_optimizers.py
69
76
  tests/test_reduction_ops.py
70
77
  tests/test_release2_llm_modules.py
78
+ tests/test_runtime_engine.py
71
79
  tests/test_security.py
72
80
  tests/test_shape_ops.py
73
81
  tests/test_stress.py
@@ -4,3 +4,6 @@ numpy>=1.20.0
4
4
  pytest>=7.0
5
5
  pytest-asyncio>=0.23
6
6
  pytest-cov>=4.0
7
+
8
+ [gpu]
9
+ wgpu>=0.33
@@ -72,7 +72,7 @@ from .errors import (
72
72
  # WHAT: 패키지 버전을 정의하는 변수입니다.
73
73
  # WHY: 패키지 사용자나 다른 도구가 현재 설치된 패키지의 버전을 확인할 수 있게 합니다.
74
74
  # HOW: 문자열 형태로 버전을 저장하여 외부에서 접근 가능하게 합니다.
75
- __version__ = "2.0.2"
75
+ __version__ = "2.0.4"
76
76
 
77
77
  # 기본 통계 및 수학 연산 함수들을 편의상 다른 이름으로 매핑하여 임포트
78
78
  from .ops import sum_op as sum, mean_op as mean, exp_op as exp, log_op as log
@@ -0,0 +1,23 @@
1
+ # Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0 OR Commercial-License
3
+ """
4
+ forge.runtime — amv-forge 엔진의 Python 트랙입니다.
5
+
6
+ TypeScript core(브라우저 / Node.js)와 같은 커널 매니페스트, 같은 WGSL, 같은 그래프 형식, 같은 오류 코드를 씁니다.
7
+ GPU는 wgpu-py(선택 의존성, `pip install amv-forge[gpu]`)로 얻습니다. 대체(fallback)는 명시할 때만 일어납니다.
8
+
9
+ from forge.runtime import Forge
10
+ forge = Forge.create(backend="auto", fallback=["cpu"])
11
+ print(forge.capabilities()["backend"])
12
+ r = forge.run("softmax", {"x": x})
13
+ """
14
+ from .engine import ENGINE_VERSION, Executable, Forge, RunResult, WgpuRuntime
15
+ from .errors import Code, ForgeError
16
+ from .graph import GRAPH_FORMAT, GRAPH_FORMAT_VERSION, compile_graph, parse_graph
17
+ from .kernels import KernelRegistry, compare, format_wgsl_float, gen_elementwise_wgsl, gen_kernel_wgsl, js_number_str, manifest
18
+
19
+ __all__ = [
20
+ "ENGINE_VERSION", "Executable", "Forge", "RunResult", "WgpuRuntime", "Code", "ForgeError",
21
+ "GRAPH_FORMAT", "GRAPH_FORMAT_VERSION", "compile_graph", "parse_graph", "KernelRegistry", "compare",
22
+ "format_wgsl_float", "gen_elementwise_wgsl", "gen_kernel_wgsl", "js_number_str", "manifest",
23
+ ]
@@ -0,0 +1,112 @@
1
+ # Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0 OR Commercial-License
3
+ """
4
+ WHAT: Python 트랙 CLI입니다. python -m forge.runtime doctor | benchmark | inspect <graph.json> | version
5
+ WHY: 네이티브 Python 환경의 GPU 가용성, 정확도, 성능을 한 명령으로 확인하기 위함입니다.
6
+ HOW: doctor는 wgpu-py가 노출한 값만 보고하고, 모든 측정은 numpy CPU 참조와 비교합니다.
7
+ """
8
+ import argparse
9
+ import json
10
+ import sys
11
+ import time
12
+
13
+ import numpy as np
14
+
15
+ from .engine import ENGINE_VERSION, Forge
16
+ from .errors import ForgeError
17
+
18
+
19
+ def _rand(shape, seed):
20
+ return np.random.default_rng(seed).uniform(-2, 2, size=shape).astype(np.float32)
21
+
22
+
23
+ def doctor(args) -> int:
24
+ report = {"engineVersion": ENGINE_VERSION, "python": sys.version.split()[0], "platform": sys.platform}
25
+ lines = [f"amv-forge (python track) doctor, engine {ENGINE_VERSION}", f"python {report['python']} {sys.platform}"]
26
+ try:
27
+ f = Forge.create(backend="webgpu")
28
+ except ForgeError as e:
29
+ report["webgpuError"] = e.to_json()
30
+ lines.append(f"webgpu: NOT AVAILABLE - {e}")
31
+ lines.append("recommended backend: cpu (Forge.create(fallback=['cpu']))")
32
+ print(json.dumps(report, indent=2) if args.json else "\n".join(lines))
33
+ return 2
34
+ caps = f.capabilities()
35
+ a = caps["adapter"]
36
+ lines.append(f"adapter: vendor={a['vendor']!r} device={a['device']!r} backend={a['backend']} type={a['adapterType']}")
37
+ lines.append(f"features: {', '.join(a['features'])}")
38
+ lim = a["limits"]
39
+ lines.append(f"limits: maxBufferSize={lim['maxBufferSize']} maxStorageBufferBindingSize={lim['maxStorageBufferBindingSize']} "
40
+ f"maxComputeInvocationsPerWorkgroup={lim['maxComputeInvocationsPerWorkgroup']}")
41
+ v = f.verify("matmul", {"a": _rand((64, 48), 1), "b": _rand((48, 32), 2)})
42
+ lines.append(f"self-test matmul 64x48x32 on {v['backend']}: {'PASS' if v['ok'] else 'FAIL'} (max abs err {v['maxAbsErr']:.2e}, atol {v['atol']:.2e})")
43
+ report.update({"capabilities": caps, "selfTest": v})
44
+ f.dispose()
45
+ print(json.dumps(report, indent=2, default=str) if args.json else "\n".join(lines))
46
+ return 0 if v["ok"] else 1
47
+
48
+
49
+ def benchmark(args) -> int:
50
+ f = Forge.create(backend="auto", fallback=["cpu"] if args.fallback_cpu else None)
51
+ fails = 0
52
+ out = []
53
+
54
+ def timeit(fn, reps):
55
+ t = []
56
+ for _ in range(reps):
57
+ s = time.perf_counter()
58
+ fn()
59
+ t.append((time.perf_counter() - s) * 1000)
60
+ t.sort()
61
+ return t[len(t) // 2]
62
+
63
+ for n in (128, 256, 512):
64
+ a, b = _rand((n, n), 1), _rand((n, n), 2)
65
+ f.run("matmul", {"a": a, "b": b})
66
+ ms = timeit(lambda: f.run("matmul", {"a": a, "b": b}), args.reps)
67
+ v = f.verify("matmul", {"a": a, "b": b})
68
+ fails += 0 if v["ok"] else 1
69
+ out.append({"name": "matmul", "n": n, "backend": v["backend"], "medianMs": ms, "ok": v["ok"], "maxAbsErr": v["maxAbsErr"]})
70
+ print(f"[{v['backend']}] matmul {n}^3: median {ms:.2f} ms ({2 * n ** 3 / (ms / 1000) / 1e9:.1f} GFLOP/s incl. transfer) "
71
+ f"accuracy {'PASS' if v['ok'] else 'FAIL'} maxAbs {v['maxAbsErr']:.2e}")
72
+ x = _rand((512, 1024), 3)
73
+ for op in ("softmax", "gelu"):
74
+ inp = {"x": x}
75
+ f.run(op, inp)
76
+ ms = timeit(lambda: f.run(op, inp), args.reps)
77
+ v = f.verify(op, inp)
78
+ fails += 0 if v["ok"] else 1
79
+ print(f"[{v['backend']}] {op} [512,1024]: median {ms:.2f} ms accuracy {'PASS' if v['ok'] else 'FAIL'} maxAbs {v['maxAbsErr']:.2e}")
80
+ print("RESULT: all accuracy checks passed" if not fails else f"RESULT: {fails} accuracy check(s) FAILED")
81
+ f.dispose()
82
+ return 1 if fails else 0
83
+
84
+
85
+ def inspect(args) -> int:
86
+ f = Forge.create(backend="cpu")
87
+ with open(args.graph, encoding="utf-8") as fh:
88
+ exe = f.compile(fh.read())
89
+ print(json.dumps(exe.describe(), indent=2))
90
+ return 0
91
+
92
+
93
+ def main(argv=None) -> int:
94
+ p = argparse.ArgumentParser(prog="python -m forge.runtime")
95
+ sub = p.add_subparsers(dest="cmd", required=True)
96
+ d = sub.add_parser("doctor"); d.add_argument("--json", action="store_true")
97
+ b = sub.add_parser("benchmark"); b.add_argument("--reps", type=int, default=5); b.add_argument("--fallback-cpu", action="store_true")
98
+ i = sub.add_parser("inspect"); i.add_argument("graph")
99
+ sub.add_parser("version")
100
+ args = p.parse_args(argv)
101
+ if args.cmd == "version":
102
+ print(ENGINE_VERSION)
103
+ return 0
104
+ try:
105
+ return {"doctor": doctor, "benchmark": benchmark, "inspect": inspect}[args.cmd](args)
106
+ except ForgeError as e:
107
+ print(str(e), file=sys.stderr)
108
+ return 1
109
+
110
+
111
+ if __name__ == "__main__":
112
+ sys.exit(main())