munet-nn 0.3.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 (160) hide show
  1. munet_nn-0.3.1/.github/workflows/ci.yml +79 -0
  2. munet_nn-0.3.1/.github/workflows/wheels.yml +222 -0
  3. munet_nn-0.3.1/.gitignore +20 -0
  4. munet_nn-0.3.1/CHANGELOG.md +75 -0
  5. munet_nn-0.3.1/CMakeLists.txt +71 -0
  6. munet_nn-0.3.1/Makefile +95 -0
  7. munet_nn-0.3.1/PKG-INFO +250 -0
  8. munet_nn-0.3.1/README.md +224 -0
  9. munet_nn-0.3.1/cmake/MuNetConfig.cmake.in +3 -0
  10. munet_nn-0.3.1/cmake/kernel_sources.hpp.in +6 -0
  11. munet_nn-0.3.1/conftest.py +8 -0
  12. munet_nn-0.3.1/cpp/attention.cpp +302 -0
  13. munet_nn-0.3.1/cpp/bindings.cpp +53 -0
  14. munet_nn-0.3.1/cpp/core.cpp +966 -0
  15. munet_nn-0.3.1/cpp/core.hpp +182 -0
  16. munet_nn-0.3.1/cpp/kernels/assignment.inc +18 -0
  17. munet_nn-0.3.1/cpp/kernels/concat.inc +3 -0
  18. munet_nn-0.3.1/cpp/kernels/conv.inc +15 -0
  19. munet_nn-0.3.1/cpp/kernels/det.inc +12 -0
  20. munet_nn-0.3.1/cpp/kernels/gather.inc +4 -0
  21. munet_nn-0.3.1/cpp/kernels/grid.inc +14 -0
  22. munet_nn-0.3.1/cpp/kernels/matmul.inc +5 -0
  23. munet_nn-0.3.1/cpp/kernels/max.inc +4 -0
  24. munet_nn-0.3.1/cpp/kernels/maxroipool.inc +13 -0
  25. munet_nn-0.3.1/cpp/kernels/nms.inc +16 -0
  26. munet_nn-0.3.1/cpp/kernels/permute.inc +1 -0
  27. munet_nn-0.3.1/cpp/kernels/pointwise.inc +24 -0
  28. munet_nn-0.3.1/cpp/kernels/pool.inc +16 -0
  29. munet_nn-0.3.1/cpp/kernels/random.inc +3 -0
  30. munet_nn-0.3.1/cpp/kernels/resize.inc +5 -0
  31. munet_nn-0.3.1/cpp/kernels/roialign.inc +24 -0
  32. munet_nn-0.3.1/cpp/kernels/scatter.inc +19 -0
  33. munet_nn-0.3.1/cpp/kernels/slice.inc +3 -0
  34. munet_nn-0.3.1/cpp/kernels/take.inc +4 -0
  35. munet_nn-0.3.1/cpp/kernels/topk.inc +4 -0
  36. munet_nn-0.3.1/cpp/layout.cpp +113 -0
  37. munet_nn-0.3.1/cpp/matmul.cpp +887 -0
  38. munet_nn-0.3.1/cpp/ops.cpp +245 -0
  39. munet_nn-0.3.1/cpp/ops.hpp +11 -0
  40. munet_nn-0.3.1/cpp/swarm/node.cpp +391 -0
  41. munet_nn-0.3.1/cpp/third_party/README.md +9 -0
  42. munet_nn-0.3.1/cpp/third_party/nlohmann/LICENSE.MIT +21 -0
  43. munet_nn-0.3.1/cpp/third_party/nlohmann/json.hpp +24765 -0
  44. munet_nn-0.3.1/cpp/vulkan.cpp +492 -0
  45. munet_nn-0.3.1/cpp/vulkan_loader.hpp +161 -0
  46. munet_nn-0.3.1/docs/architecture.md +149 -0
  47. munet_nn-0.3.1/docs/install.md +196 -0
  48. munet_nn-0.3.1/docs/op_coverage.md +209 -0
  49. munet_nn-0.3.1/docs/perf/README.md +151 -0
  50. munet_nn-0.3.1/docs/perf/attention.json +182 -0
  51. munet_nn-0.3.1/docs/perf/attention.md +23 -0
  52. munet_nn-0.3.1/docs/perf/autotune.json +592 -0
  53. munet_nn-0.3.1/docs/perf/autotune.md +43 -0
  54. munet_nn-0.3.1/docs/perf/baseline.json +5180 -0
  55. munet_nn-0.3.1/docs/perf/baseline.md +107 -0
  56. munet_nn-0.3.1/docs/perf/conv.json +5627 -0
  57. munet_nn-0.3.1/docs/perf/conv.md +107 -0
  58. munet_nn-0.3.1/docs/perf/epilogue.json +5714 -0
  59. munet_nn-0.3.1/docs/perf/epilogue.md +107 -0
  60. munet_nn-0.3.1/docs/perf/fp16-activations.json +346 -0
  61. munet_nn-0.3.1/docs/perf/fp16-activations.md +31 -0
  62. munet_nn-0.3.1/docs/perf/fp32.json +1089 -0
  63. munet_nn-0.3.1/docs/perf/fp32.md +51 -0
  64. munet_nn-0.3.1/docs/perf/latest.json +6963 -0
  65. munet_nn-0.3.1/docs/perf/latest.md +119 -0
  66. munet_nn-0.3.1/docs/perf/permute.json +818 -0
  67. munet_nn-0.3.1/docs/perf/permute.md +55 -0
  68. munet_nn-0.3.1/docs/perf/phase1.json +5550 -0
  69. munet_nn-0.3.1/docs/perf/phase1.md +107 -0
  70. munet_nn-0.3.1/docs/perf/reductions.json +658 -0
  71. munet_nn-0.3.1/docs/perf/reductions.md +47 -0
  72. munet_nn-0.3.1/docs/quantization.md +163 -0
  73. munet_nn-0.3.1/docs/rtdetr-acceptance.md +77 -0
  74. munet_nn-0.3.1/docs/rtdetr-coverage.json +175 -0
  75. munet_nn-0.3.1/docs/rtdetr.md +176 -0
  76. munet_nn-0.3.1/docs/swarm.md +158 -0
  77. munet_nn-0.3.1/docs/validation.md +218 -0
  78. munet_nn-0.3.1/examples/__init__.py +1 -0
  79. munet_nn-0.3.1/examples/rtdetr/LICENSE-RT-DETR +201 -0
  80. munet_nn-0.3.1/examples/rtdetr/NOTICE +9 -0
  81. munet_nn-0.3.1/examples/rtdetr/README.md +42 -0
  82. munet_nn-0.3.1/examples/rtdetr/__init__.py +49 -0
  83. munet_nn-0.3.1/examples/rtdetr/backbone.py +229 -0
  84. munet_nn-0.3.1/examples/rtdetr/backbone_common.py +10 -0
  85. munet_nn-0.3.1/examples/rtdetr/data.py +112 -0
  86. munet_nn-0.3.1/examples/rtdetr/decoder.py +555 -0
  87. munet_nn-0.3.1/examples/rtdetr/denoising.py +58 -0
  88. munet_nn-0.3.1/examples/rtdetr/encoder.py +302 -0
  89. munet_nn-0.3.1/examples/rtdetr/evaluate.py +22 -0
  90. munet_nn-0.3.1/examples/rtdetr/fetch_reference.py +21 -0
  91. munet_nn-0.3.1/examples/rtdetr/infer.py +25 -0
  92. munet_nn-0.3.1/examples/rtdetr/initialization.py +18 -0
  93. munet_nn-0.3.1/examples/rtdetr/loss.py +96 -0
  94. munet_nn-0.3.1/examples/rtdetr/requirements-eval.txt +2 -0
  95. munet_nn-0.3.1/examples/rtdetr/requirements.txt +2 -0
  96. munet_nn-0.3.1/examples/rtdetr/tests/__init__.py +1 -0
  97. munet_nn-0.3.1/examples/rtdetr/tests/rtdetr-reference.json +46 -0
  98. munet_nn-0.3.1/examples/rtdetr/tests/rtdetr_reference.py +70 -0
  99. munet_nn-0.3.1/examples/rtdetr/tests/test_rtdetr.py +121 -0
  100. munet_nn-0.3.1/examples/rtdetr/tests/test_rtdetr_convergence.py +17 -0
  101. munet_nn-0.3.1/examples/rtdetr/tests/test_rtdetr_workflow.py +103 -0
  102. munet_nn-0.3.1/examples/rtdetr/train.py +36 -0
  103. munet_nn-0.3.1/examples/rtdetr/training.py +127 -0
  104. munet_nn-0.3.1/examples/rtdetr/utils.py +34 -0
  105. munet_nn-0.3.1/examples/rtdetr/validate_training.py +38 -0
  106. munet_nn-0.3.1/examples/swarm_mlp.py +51 -0
  107. munet_nn-0.3.1/examples/train_mlp.py +41 -0
  108. munet_nn-0.3.1/examples/zoo/README.md +27 -0
  109. munet_nn-0.3.1/examples/zoo/__init__.py +8 -0
  110. munet_nn-0.3.1/examples/zoo/detection.py +108 -0
  111. munet_nn-0.3.1/examples/zoo/language.py +59 -0
  112. munet_nn-0.3.1/examples/zoo/tests/__init__.py +0 -0
  113. munet_nn-0.3.1/examples/zoo/tests/test_zoo.py +172 -0
  114. munet_nn-0.3.1/examples/zoo/tests/torch_twins.py +186 -0
  115. munet_nn-0.3.1/examples/zoo/vision.py +167 -0
  116. munet_nn-0.3.1/pyproject.toml +49 -0
  117. munet_nn-0.3.1/python/munet/__init__.py +13 -0
  118. munet_nn-0.3.1/python/munet/autotune.py +133 -0
  119. munet_nn-0.3.1/python/munet/checkpoint.py +67 -0
  120. munet_nn-0.3.1/python/munet/cli.py +11 -0
  121. munet_nn-0.3.1/python/munet/core.py +635 -0
  122. munet_nn-0.3.1/python/munet/interop.py +793 -0
  123. munet_nn-0.3.1/python/munet/nn.py +954 -0
  124. munet_nn-0.3.1/python/munet/onnx_extra.py +640 -0
  125. munet_nn-0.3.1/python/munet/onnx_passes.py +295 -0
  126. munet_nn-0.3.1/python/munet/optim.py +162 -0
  127. munet_nn-0.3.1/python/munet/quantization.py +384 -0
  128. munet_nn-0.3.1/python/munet/serialization.py +182 -0
  129. munet_nn-0.3.1/python/munet/swarm/__init__.py +5 -0
  130. munet_nn-0.3.1/python/munet/swarm/__main__.py +52 -0
  131. munet_nn-0.3.1/python/munet/swarm/artifacts.py +79 -0
  132. munet_nn-0.3.1/python/munet/swarm/bundle.py +95 -0
  133. munet_nn-0.3.1/python/munet/swarm/owner.py +266 -0
  134. munet_nn-0.3.1/python/munet/swarm/server.py +113 -0
  135. munet_nn-0.3.1/python/munet_nn/__init__.py +21 -0
  136. munet_nn-0.3.1/python/munet_nn/swarm/__init__.py +9 -0
  137. munet_nn-0.3.1/python/munet_nn/swarm/__main__.py +4 -0
  138. munet_nn-0.3.1/tests/test_format_limits.py +35 -0
  139. munet_nn-0.3.1/tests/test_interop.py +427 -0
  140. munet_nn-0.3.1/tests/test_layers.py +224 -0
  141. munet_nn-0.3.1/tests/test_nn_ops.py +624 -0
  142. munet_nn-0.3.1/tests/test_onnx_ops.py +319 -0
  143. munet_nn-0.3.1/tests/test_packaging.py +67 -0
  144. munet_nn-0.3.1/tests/test_perf_regression.py +33 -0
  145. munet_nn-0.3.1/tests/test_runtime.py +315 -0
  146. munet_nn-0.3.1/tests/test_swarm.py +422 -0
  147. munet_nn-0.3.1/tools/bench_torch.py +154 -0
  148. munet_nn-0.3.1/tools/bench_workloads.py +378 -0
  149. munet_nn-0.3.1/tools/benchmark.py +290 -0
  150. munet_nn-0.3.1/tools/build.py +22 -0
  151. munet_nn-0.3.1/tools/build_release.py +102 -0
  152. munet_nn-0.3.1/tools/device_peaks.py +118 -0
  153. munet_nn-0.3.1/tools/op_coverage.py +116 -0
  154. munet_nn-0.3.1/tools/release_version.py +40 -0
  155. munet_nn-0.3.1/tools/server_entry.py +5 -0
  156. munet_nn-0.3.1/tools/smoke_install.py +37 -0
  157. munet_nn-0.3.1/tools/smoke_release.py +84 -0
  158. munet_nn-0.3.1/tools/smoke_sdk.py +40 -0
  159. munet_nn-0.3.1/tools/test.py +30 -0
  160. munet_nn-0.3.1/tools/validate_artifacts.py +73 -0
@@ -0,0 +1,79 @@
1
+ name: native-and-vulkan-correctness
2
+ on:
3
+ workflow_call:
4
+ workflow_dispatch:
5
+ permissions:
6
+ contents: read
7
+ jobs:
8
+ worker-cxx-standards:
9
+ name: Native worker (C++${{ matrix.standard }})
10
+ runs-on: ubuntu-24.04
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ standard: [17, 20, 23]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev libssl-dev
18
+ # cxx_std_17 is a minimum: newer compiler defaults can select C++20 or later.
19
+ - name: Configure standalone worker
20
+ run: >-
21
+ cmake -S . -B build-worker -DCMAKE_BUILD_TYPE=Release
22
+ -DMUNET_PYTHON=OFF -DMUNET_VULKAN=OFF -DMUNET_SWARM_NODE=ON
23
+ -DCMAKE_CXX_STANDARD=${{ matrix.standard }} -DCMAKE_CXX_STANDARD_REQUIRED=ON
24
+ - run: cmake --build build-worker --parallel 2
25
+ - run: ./build-worker/munet-node --version
26
+
27
+ correctness:
28
+ runs-on: ubuntu-24.04
29
+ strategy:
30
+ fail-fast: false
31
+ matrix:
32
+ backend: [cpu, vulkan]
33
+ steps:
34
+ - uses: actions/checkout@v4
35
+ - uses: actions/setup-python@v5
36
+ with:
37
+ python-version: '3.12'
38
+ - run: sudo apt-get update && sudo apt-get install -y libvulkan-dev mesa-vulkan-drivers glslang-tools vulkan-validationlayers libcurl4-openssl-dev libssl-dev
39
+ - run: python -m pip install cmake pybind11 pytest numpy onnx onnxruntime onnxscript scikit-build-core scipy Pillow
40
+ - run: python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
41
+ - name: Fetch pinned RT-DETR reference for numerical tests
42
+ run: python examples/rtdetr/fetch_reference.py
43
+ - name: Build CPU only
44
+ if: matrix.backend == 'cpu'
45
+ run: python tools/build.py --cpu-only --cmake-arg=-DMUNET_SWARM_NODE=ON
46
+ - name: Build Vulkan
47
+ if: matrix.backend == 'vulkan'
48
+ run: python tools/build.py --cmake-arg=-DMUNET_SWARM_NODE=ON
49
+ - name: Select software Vulkan driver
50
+ if: matrix.backend == 'vulkan'
51
+ shell: python
52
+ run: |
53
+ import glob, os
54
+ paths = glob.glob('/usr/share/vulkan/icd.d/lvp_icd*.json')
55
+ assert paths, 'Mesa software Vulkan ICD is required'
56
+ with open(os.environ['GITHUB_ENV'], 'a') as f:
57
+ f.write('VK_ICD_FILENAMES=' + paths[0] + '\nMUNET_TEST_VULKAN=1\n')
58
+ - name: CPU tests
59
+ if: matrix.backend == 'cpu'
60
+ run: python tools/test.py --swarm tests examples/rtdetr/tests
61
+ env:
62
+ PYTHONPATH: python
63
+ # Model-level GPU coverage (including RT-DETR) lives in the zoo suite; examples/rtdetr/tests is the CPU gate.
64
+ - name: Vulkan numerical and synchronization validation
65
+ if: matrix.backend == 'vulkan'
66
+ run: python tools/test.py --vulkan-validation --swarm tests examples/zoo/tests
67
+ env:
68
+ PYTHONPATH: python
69
+ - name: Full default R50-vd training state advancement
70
+ if: matrix.backend == 'cpu'
71
+ run: python -m examples.rtdetr.validate_training --device cpu
72
+ env:
73
+ PYTHONPATH: python
74
+ - name: Save numerical and fault-recovery evidence
75
+ if: always()
76
+ uses: actions/upload-artifact@v4
77
+ with:
78
+ name: correctness-${{ matrix.backend }}
79
+ path: artifacts/validation/
@@ -0,0 +1,222 @@
1
+ # Keep this path: the existing munet-nn PyPI trusted publisher is bound to it.
2
+ name: Wheels
3
+
4
+ on:
5
+ push:
6
+ branches: [master]
7
+ tags: ["v*", "dev*"]
8
+ pull_request:
9
+ workflow_dispatch:
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ concurrency:
15
+ group: wheels-${{ github.ref }}
16
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
17
+
18
+ jobs:
19
+ version:
20
+ name: Validate package and release identity
21
+ runs-on: ubuntu-24.04
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - uses: actions/setup-python@v5
25
+ with:
26
+ python-version: '3.12'
27
+ - run: python -m pip install packaging
28
+ - run: python tools/release_version.py
29
+
30
+ correctness:
31
+ needs: version
32
+ uses: ./.github/workflows/ci.yml
33
+
34
+ build_wheels:
35
+ name: Wheels (${{ matrix.arch }})
36
+ needs: version
37
+ runs-on: ${{ matrix.runner }}
38
+ strategy:
39
+ fail-fast: false
40
+ matrix:
41
+ include:
42
+ - runner: ubuntu-24.04
43
+ arch: x86_64
44
+ - runner: ubuntu-24.04-arm
45
+ arch: aarch64
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+ - name: Build and exercise installed CPU/Vulkan wheels
49
+ uses: pypa/cibuildwheel@v4.2.1
50
+ env:
51
+ CIBW_ARCHS_LINUX: ${{ matrix.arch }}
52
+ CIBW_BEFORE_ALL_LINUX: dnf -y install vulkan-headers libcurl-devel openssl-devel
53
+ # A single runtime per Python/platform avoids colliding CPU/GPU filenames.
54
+ CIBW_ENVIRONMENT_LINUX: >-
55
+ CMAKE_ARGS="-DMUNET_VULKAN=ON -DMUNET_SWARM_NODE=ON -DMUNET_INSTALL_SDK=OFF"
56
+ # libvulkan is loaded lazily from the host. auditwheel repairs the native
57
+ # worker and extension, including their libcurl/OpenSSL dependencies.
58
+ - uses: actions/upload-artifact@v4
59
+ with:
60
+ name: wheels-linux-${{ matrix.arch }}
61
+ path: wheelhouse/*.whl
62
+ if-no-files-found: error
63
+
64
+ source:
65
+ name: Source distribution
66
+ needs: version
67
+ runs-on: ubuntu-24.04
68
+ steps:
69
+ - uses: actions/checkout@v4
70
+ - uses: actions/setup-python@v5
71
+ with:
72
+ python-version: '3.12'
73
+ - run: python -m pip install build twine
74
+ - run: python -m build --sdist
75
+ - run: python -m twine check dist/*
76
+ - uses: actions/upload-artifact@v4
77
+ with:
78
+ name: source-dist
79
+ path: dist/*.tar.gz
80
+ if-no-files-found: error
81
+
82
+ native:
83
+ name: Node, server and SDK (${{ matrix.arch }})
84
+ needs: build_wheels
85
+ runs-on: ${{ matrix.runner }}
86
+ container: quay.io/pypa/manylinux_2_28_${{ matrix.arch }}
87
+ strategy:
88
+ fail-fast: false
89
+ matrix:
90
+ include:
91
+ - runner: ubuntu-24.04
92
+ arch: x86_64
93
+ - runner: ubuntu-24.04-arm
94
+ arch: aarch64
95
+ steps:
96
+ - uses: actions/checkout@v4
97
+ - uses: actions/download-artifact@v4
98
+ with:
99
+ name: wheels-linux-${{ matrix.arch }}
100
+ path: wheelhouse
101
+ - name: Install packaging tools and the actual CPython 3.12 wheel
102
+ shell: bash
103
+ run: |
104
+ # The /opt/python manylinux interpreters are static wheel builders.
105
+ # Freezing needs the distribution Python's shared libpython instead.
106
+ dnf -y install vulkan-headers python3.12 python3.12-pip python3.12-devel
107
+ /usr/bin/python3.12 -m venv /tmp/munet-freeze
108
+ /tmp/munet-freeze/bin/python -m pip install cmake pyinstaller==6.22.2 packaging
109
+ /tmp/munet-freeze/bin/python -m pip install wheelhouse/*cp312-cp312-*.whl
110
+ - name: Freeze server, package native node and SDK, and exercise all three
111
+ shell: bash
112
+ run: |
113
+ /tmp/munet-freeze/bin/python tools/build_release.py --wheel wheelhouse/*cp312-cp312-*.whl
114
+ - uses: actions/upload-artifact@v4
115
+ with:
116
+ name: native-linux-${{ matrix.arch }}
117
+ path: release-dist/*
118
+ if-no-files-found: error
119
+
120
+ validate_wheels:
121
+ name: Validate all distributions
122
+ needs: [build_wheels, source, native, correctness]
123
+ runs-on: ubuntu-24.04
124
+ steps:
125
+ - uses: actions/checkout@v4
126
+ - uses: actions/setup-python@v5
127
+ with:
128
+ python-version: '3.12'
129
+ - uses: actions/download-artifact@v4
130
+ with:
131
+ pattern: wheels-*
132
+ path: incoming
133
+ - uses: actions/download-artifact@v4
134
+ with:
135
+ name: source-dist
136
+ path: incoming/source
137
+ - run: python -m pip install packaging twine
138
+ - run: python tools/validate_artifacts.py incoming
139
+ - name: Collect validated, uniquely named Python distributions
140
+ shell: python
141
+ run: |
142
+ from pathlib import Path
143
+ import shutil, subprocess, sys
144
+ target = Path('dist')
145
+ target.mkdir()
146
+ for p in Path('incoming').rglob('*'):
147
+ if p.is_file() and (p.name.endswith('.whl') or p.name.endswith('.tar.gz')):
148
+ assert not (target / p.name).exists(), p.name
149
+ shutil.copyfile(p, target / p.name)
150
+ subprocess.run([sys.executable, '-m', 'twine', 'check', *map(str, target.iterdir())], check=True)
151
+ - uses: actions/upload-artifact@v4
152
+ with:
153
+ name: python-distributions
154
+ path: dist/*
155
+
156
+ publish_testpypi:
157
+ name: Publish dev wheels to TestPyPI
158
+ needs: validate_wheels
159
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/dev')
160
+ runs-on: ubuntu-24.04
161
+ permissions:
162
+ id-token: write
163
+ contents: read
164
+ steps:
165
+ - uses: actions/download-artifact@v4
166
+ with:
167
+ name: python-distributions
168
+ path: dist
169
+ - uses: pypa/gh-action-pypi-publish@release/v1
170
+ with:
171
+ packages-dir: dist/
172
+ repository-url: https://test.pypi.org/legacy/
173
+
174
+ publish:
175
+ name: Publish release wheels to PyPI
176
+ needs: validate_wheels
177
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
178
+ runs-on: ubuntu-24.04
179
+ permissions:
180
+ id-token: write
181
+ contents: read
182
+ steps:
183
+ - uses: actions/download-artifact@v4
184
+ with:
185
+ name: python-distributions
186
+ path: dist
187
+ - uses: pypa/gh-action-pypi-publish@release/v1
188
+ with:
189
+ packages-dir: dist/
190
+
191
+ release:
192
+ name: Publish standalone downloads
193
+ needs: [validate_wheels, publish]
194
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
195
+ runs-on: ubuntu-24.04
196
+ permissions:
197
+ contents: write
198
+ steps:
199
+ - uses: actions/checkout@v4
200
+ - uses: actions/download-artifact@v4
201
+ with:
202
+ pattern: native-linux-*
203
+ path: release-dist
204
+ merge-multiple: true
205
+ - uses: actions/download-artifact@v4
206
+ with:
207
+ name: python-distributions
208
+ path: release-dist
209
+ - name: Detect prerelease version
210
+ id: version
211
+ shell: python
212
+ run: |
213
+ import os, re
214
+ tag = os.environ['GITHUB_REF_NAME']
215
+ with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
216
+ f.write('prerelease=' + str(bool(re.search(r'(?:a|b|rc)\d', tag))).lower() + '\n')
217
+ - uses: softprops/action-gh-release@v2
218
+ with:
219
+ files: release-dist/*
220
+ fail_on_unmatched_files: true
221
+ generate_release_notes: true
222
+ prerelease: ${{ steps.version.outputs.prerelease }}
@@ -0,0 +1,20 @@
1
+ build*/
2
+ artifacts/
3
+ dist/
4
+ *.so
5
+ *.pyd
6
+ *.pyc
7
+ __pycache__/
8
+ .pytest_cache/
9
+ .venv/
10
+ *.egg-info/
11
+
12
+ release-dist/
13
+ wheelhouse/
14
+ incoming/
15
+ *.spec
16
+ python/bin/
17
+ python/include/
18
+ python/lib/
19
+ python/munet/bin/
20
+ .venv-cuda/
@@ -0,0 +1,75 @@
1
+ # Changelog
2
+
3
+ ## 0.3.1
4
+
5
+ First PyPI release since 0.1.2 (0.3.0 was tagged but not published to PyPI). It includes the 0.2
6
+ rewrite (unreleased on PyPI), the Vulkan performance, quantization and import work, and full ONNX operator coverage
7
+ (all 191 operators of opsets 13-21). Measurements are on an RTX 3060 (driver 615.78) unless stated; see
8
+ [docs/perf](docs/perf/README.md) for methodology and full tables.
9
+
10
+ ### Upgrade notes
11
+
12
+ - **Swarm protocol is `munet-swarm-13`.** Generated kernels changed, so owners and nodes must run the same release;
13
+ a node from another release refuses the job's artifacts and assignments (ABI check), and compiled shaders are
14
+ verified by hash.
15
+ - **`from_onnx` merges layers by default** (`optimize=True`): BatchNorm folding, parallel-branch re-parameterization,
16
+ linear-chain collapse and sibling merging. Results are exact up to float32 rounding; `program.optimizations` lists
17
+ the rewrites and `optimize=False` restores the graph as exported. Layer names in int8 selections refer to the
18
+ merged graph.
19
+ - **Integer ONNX model inputs and outputs are accepted.** Integer/bool inputs are converted to float32 on the way in
20
+ (values above 2^24 are rejected), and integer outputs are returned as numpy arrays of their declared type instead
21
+ of lazy results.
22
+ - **`NonMaxSuppression` imports when its result is a model output**, returned as int64 `[num_selected, 3]` with padding
23
+ removed; graphs that consume the result inside the model are rejected.
24
+ - **Weights behind resident packs live in host-visible memory.** Device memory holds each inference weight once
25
+ (fp16, int8 or int4). The first call after loading or `Parameter.assign` is 30-80 ms slower on large models.
26
+ - `precision="mixed_safe"` keeps the explicit attention backward (about 2% slower than before this release).
27
+
28
+ ### 0.2 rewrite (previously unreleased on PyPI)
29
+
30
+ - Greenfield C++/Python runtime: traced static graphs compiled to Vulkan compute (single command-buffer replay, arena
31
+ memory, hazard-based barriers) with a CPU reference executor; the `munet-nn` / `munet_nn` package identity is
32
+ retained.
33
+ - Resilient training swarm (native worker, owner server, leases, journaled recovery), installable Linux wheels,
34
+ frozen server bundle and CMake SDK.
35
+ - Native RT-DETR training, inference and model interchange as a standalone source example (`examples/rtdetr`).
36
+ - Makefile for setup, builds and CPU/Vulkan test runs.
37
+
38
+ ### Performance (Vulkan)
39
+
40
+ - Mixed precision (fp16 inputs, fp32 accumulation) on cooperative matrices with unrolled fragment loops: GEMM
41
+ 4096^3 at 23.5 TFLOP/s (90% of the measured ceiling, cuBLAS parity), implicit-GEMM convolutions (tap-major),
42
+ epilogue fusion, producer and permute/slice inlining, two-stage reductions, fp16 activations, split-K.
43
+ - Fused flash attention forward and backward (S/P/dP/dS never reach memory): transformer training step 1.54x PyTorch
44
+ eager (was 1.70x).
45
+ - `precision="fp32"` tuned: implicit-GEMM fp32 convolutions and a register-prefetched fp32 GEMM (ResNet-50 209 ->
46
+ 17.8 ms, RT-DETR R50 452 -> 38.9 ms; PyTorch fp32 16.8 / 35.3 ms).
47
+ - Tiled transposes and radix-select top-k (33600-wide top-300: 1.7 -> 0.14 ms); dependency-level kernel scheduling
48
+ when it costs no memory (batch-1 transformer 0.191 -> 0.119 ms).
49
+ - Opt-in autotuner (`compile(autotune=True)`, `from_onnx(autotune=True)`), pipeline cache, zero-copy feeds with
50
+ double-buffered input staging.
51
+ - Against PyTorch eager on the same GPU: ResNet-50, ViT-S/16 and GPT at parity or better; RT-DETR R50 inference
52
+ 0.68x; TensorRT remains 2.2-3.6x faster on CNN/ViT inference.
53
+
54
+ ### Quantization
55
+
56
+ - int8 GEMM (W8A8, 16x16x32 int8 cooperative matrices, 54 TOP/s) and int8 implicit-GEMM convolutions
57
+ (channels-last int8 activations; 3x3 convolutions 1.4-2.8x faster than fp16).
58
+ - Weight-only `w8`/`w4` that save memory and bandwidth: a streaming GEMV for up to 8 rows (batch 1: 2.3x / 4.0x faster
59
+ than fp16) and dequantizing cooperative-matrix tiles above that.
60
+ - `mu.quantize` (w8a8, w8a8_dynamic, w8, w4; minmax/percentile/mse observers), ONNX QDQ/QLinear import and export.
61
+ - `munet.quantization.calibrate_onnx` (MSE histogram calibration) and `from_onnx(int8=...)`.
62
+ - `munet.quantization.autoquantize`: per-layer int8 selection from measured per-layer speed and a task metric within
63
+ a tolerance. On an RT-DETR-style 1280x1280 detector: 24 of 80 layers in int8, 23.67 -> 21.07 ms, mAP50
64
+ 86.30 -> 85.90.
65
+
66
+ ### Import and coverage
67
+
68
+ - ONNX: all 191 operators of opsets 13-21, machine-checked coverage table. New in this release: bitwise ops and BitShift, Det, ScatterElements/ScatterND, GatherND, MaxUnpool, MaxRoiPool, Col2Im, ReverseSequence, ReduceProd, AffineGrid, CenterCropPad, DeformConv, DFT, STFT, window functions, MelWeightMatrix, DynamicQuantizeLinear, RNN/GRU/LSTM (unrolled), TfIdfVectorizer, random operators (new samples every call), sequences and optionals (resolved at import), If/Loop/Scan/SequenceMap (branch selection or Where, unrolled loops), and string/bytes operators and Unique from constant inputs; shape-specialized programs for symbolic
69
+ dimensions; `from_onnx(precision=, autotune=, int8=, optimize=, profile=)`; graph nodes carry ONNX node names
70
+ (`describe()` attributes kernels to layers).
71
+ - Weight-level layer merging (`munet.onnx_passes`): a RepVGG-style network in training form 4.28 -> 3.02 ms.
72
+ - Model zoo (`examples/zoo`: ResNet-18/50, MobileNetV2, ViT, U-Net, GPT, BERT, DETR, YOLO, RT-DETR) with PyTorch
73
+ twins, mixed-precision accuracy and ONNX round trips. Model-level Vulkan tests live in the zoo suite;
74
+ `examples/rtdetr/tests` is the detector's CPU reference gate.
75
+ - RoiAlign and fixed-size NMS (`nn.functional.nms` / `batched_nms`).
@@ -0,0 +1,71 @@
1
+ cmake_minimum_required(VERSION 3.20)
2
+ file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/pyproject.toml" _munet_version_line REGEX "^version = ")
3
+ string(REGEX REPLACE ".*\"([^\"]+)\".*" "\\1" MUNET_VERSION "${_munet_version_line}")
4
+ string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" MUNET_ABI_VERSION "${MUNET_VERSION}")
5
+ project(MuNet VERSION ${MUNET_ABI_VERSION} LANGUAGES CXX)
6
+ include(GNUInstallDirs)
7
+ option(MUNET_VULKAN "Build the Vulkan compute runtime" ON)
8
+ option(MUNET_PYTHON "Build the Python interface" ON)
9
+ option(MUNET_SWARM_NODE "Build the standalone Linux/POSIX swarm worker" OFF)
10
+ option(MUNET_INSTALL_SDK "Install the C++ library, headers, and CMake package" ON)
11
+ add_library(munet_core STATIC cpp/core.cpp cpp/matmul.cpp cpp/attention.cpp cpp/layout.cpp cpp/ops.cpp cpp/vulkan.cpp)
12
+ file(GLOB MUNET_KERNELS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cpp/kernels/*.inc")
13
+ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${MUNET_KERNELS})
14
+ set(MUNET_KERNEL_SOURCE "")
15
+ foreach(kernel IN LISTS MUNET_KERNELS)
16
+ get_filename_component(kernel_name "${kernel}" NAME_WE)
17
+ file(READ "${kernel}" kernel_text)
18
+ string(APPEND MUNET_KERNEL_SOURCE "{\"${kernel_name}\", R\"kernel(${kernel_text})kernel\"},\n")
19
+ endforeach()
20
+ configure_file(cmake/kernel_sources.hpp.in kernel_sources.hpp @ONLY)
21
+ target_include_directories(munet_core PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
22
+ add_library(MuNet::core ALIAS munet_core)
23
+ target_compile_features(munet_core PUBLIC cxx_std_17)
24
+ target_include_directories(munet_core PUBLIC
25
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp>
26
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
27
+ set_target_properties(munet_core PROPERTIES POSITION_INDEPENDENT_CODE ON EXPORT_NAME core)
28
+ if(MUNET_VULKAN)
29
+ # CPU execution and owner startup must work without a Vulkan loader installed.
30
+ find_path(Vulkan_INCLUDE_DIR vulkan/vulkan.h HINTS "$ENV{VULKAN_SDK}/include" REQUIRED)
31
+ target_include_directories(munet_core PRIVATE ${Vulkan_INCLUDE_DIR})
32
+ target_link_libraries(munet_core PRIVATE ${CMAKE_DL_LIBS})
33
+ target_compile_definitions(munet_core PRIVATE MUNET_VULKAN=1)
34
+ endif()
35
+ if(MUNET_SWARM_NODE)
36
+ if(NOT UNIX)
37
+ message(FATAL_ERROR "The v1 swarm worker currently requires POSIX file locking and fsync")
38
+ endif()
39
+ find_package(CURL REQUIRED)
40
+ find_package(OpenSSL REQUIRED)
41
+ find_package(Threads REQUIRED)
42
+ add_executable(munet-node cpp/swarm/node.cpp)
43
+ target_include_directories(munet-node PRIVATE cpp/third_party)
44
+ target_link_libraries(munet-node PRIVATE munet_core CURL::libcurl OpenSSL::Crypto Threads::Threads)
45
+ target_compile_definitions(munet-node PRIVATE MUNET_VERSION="${MUNET_VERSION}")
46
+ if(SKBUILD)
47
+ install(TARGETS munet-node RUNTIME DESTINATION munet/bin)
48
+ else()
49
+ install(TARGETS munet-node RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
50
+ endif()
51
+ endif()
52
+ if(MUNET_INSTALL_SDK)
53
+ include(CMakePackageConfigHelpers)
54
+ install(TARGETS munet_core EXPORT MuNetTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
55
+ install(FILES cpp/core.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/munet)
56
+ install(EXPORT MuNetTargets NAMESPACE MuNet:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MuNet)
57
+ configure_package_config_file(cmake/MuNetConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/MuNetConfig.cmake
58
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MuNet)
59
+ write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/MuNetConfigVersion.cmake
60
+ VERSION ${PROJECT_VERSION} COMPATIBILITY SameMinorVersion)
61
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/MuNetConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/MuNetConfigVersion.cmake
62
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MuNet)
63
+ endif()
64
+ if(MUNET_PYTHON)
65
+ set(PYBIND11_FINDPYTHON ON)
66
+ find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
67
+ find_package(pybind11 CONFIG REQUIRED)
68
+ pybind11_add_module(_native cpp/bindings.cpp)
69
+ target_link_libraries(_native PRIVATE munet_core)
70
+ install(TARGETS _native LIBRARY DESTINATION munet RUNTIME DESTINATION munet)
71
+ endif()
@@ -0,0 +1,95 @@
1
+ .DEFAULT_GOAL := help
2
+ # Native builds install into the same source tree; serialize multi-target invocations.
3
+ .NOTPARALLEL:
4
+
5
+ PYTHON ?= python3
6
+ VENV ?= .venv
7
+ VULKAN ?= 1
8
+ BUILD_DIR ?= build/local
9
+ CMAKE_ARGS ?=
10
+ TORCH_INDEX_URL ?= https://download.pytorch.org/whl/cpu
11
+ DEVICE ?= cpu
12
+
13
+ VENV_PYTHON := $(abspath $(VENV))/bin/python
14
+ RUN := env PYTHONPATH="$(CURDIR)/python" MUNET_SWARM_NODE="$(abspath $(BUILD_DIR))/munet-node" "$(VENV_PYTHON)"
15
+ BUILD_FLAGS := --build-dir="$(BUILD_DIR)" --cmake-arg=-DMUNET_SWARM_NODE=ON --cmake-arg=-DMUNET_INSTALL_SDK=OFF
16
+ ifeq ($(VULKAN),0)
17
+ BUILD_FLAGS += --cpu-only
18
+ endif
19
+ ifeq ($(filter 0 1,$(VULKAN)),)
20
+ $(error VULKAN must be 0 or 1)
21
+ endif
22
+
23
+ .PHONY: help setup deps build test-deps rtdetr-deps setup-rtdetr reference test test-vulkan test-rtdetr test-zoo smoke install clean
24
+
25
+ help:
26
+ @printf '%s\n' \
27
+ 'make setup Create .venv and build the library/node (no PyTorch or model downloads)' \
28
+ 'make setup VULKAN=0 Set up without Vulkan headers or a GPU driver' \
29
+ 'make build Rebuild native code after edits (incremental)' \
30
+ 'make test Install reference-test tools and run library CPU/swarm tests' \
31
+ 'make test-vulkan CPU + Vulkan tests with API/synchronization validation (VULKAN=1)' \
32
+ 'make setup-rtdetr Set up the optional RT-DETR example and image dependencies' \
33
+ 'make test-rtdetr Run RT-DETR example acceptance tests (CPU reference; GPU coverage is in test-zoo)' \
34
+ 'make test-zoo Run model-zoo parity/ONNX tests (VULKAN=1 adds Vulkan with validation)' \
35
+ 'make smoke Run the small MLP training example (DEVICE=cpu or vulkan)' \
36
+ 'make install Install library and node/server commands into the virtual environment' \
37
+ 'make clean Clean native build outputs; keep dependencies, data and checkpoints' \
38
+ '' \
39
+ 'Overrides: PYTHON, VENV, VULKAN=0|1, BUILD_DIR, CMAKE_ARGS, TORCH_INDEX_URL, DEVICE' \
40
+ 'Use the same overrides for later commands. See docs/install.md for system prerequisites.'
41
+
42
+ $(VENV_PYTHON):
43
+ "$(PYTHON)" -m venv "$(VENV)"
44
+
45
+ # Keep the development dependencies aligned with pyproject.toml and ci.yml.
46
+ $(VENV)/.munet-deps: pyproject.toml Makefile | $(VENV_PYTHON)
47
+ "$(VENV_PYTHON)" -m pip install --upgrade pip
48
+ "$(VENV_PYTHON)" -m pip install 'cmake>=3.20' 'pybind11>=3.0' 'scikit-build-core>=0.10' 'numpy>=1.24' 'pytest>=8' 'onnx>=1.16'
49
+ touch "$@"
50
+
51
+ $(VENV)/.munet-test-deps: pyproject.toml Makefile | deps
52
+ "$(VENV_PYTHON)" -m pip install 'onnxruntime>=1.18' 'onnxscript>=0.3' 'scipy>=1.10'
53
+ "$(VENV_PYTHON)" -m pip install 'torch>=2.6' torchvision --index-url "$(TORCH_INDEX_URL)"
54
+ touch "$@"
55
+
56
+ $(VENV)/.munet-rtdetr-deps: examples/rtdetr/requirements.txt | deps
57
+ "$(VENV_PYTHON)" -m pip install -r examples/rtdetr/requirements.txt
58
+ touch "$@"
59
+
60
+ deps: $(VENV)/.munet-deps
61
+ test-deps: $(VENV)/.munet-test-deps
62
+ rtdetr-deps: $(VENV)/.munet-rtdetr-deps
63
+
64
+ setup: build
65
+ setup-rtdetr: build rtdetr-deps
66
+
67
+ build: deps
68
+ "$(VENV_PYTHON)" tools/build.py $(BUILD_FLAGS) $(CMAKE_ARGS)
69
+
70
+ reference: $(VENV_PYTHON)
71
+ "$(VENV_PYTHON)" examples/rtdetr/fetch_reference.py
72
+
73
+ test: build test-deps
74
+ MUNET_TEST_VULKAN=0 $(RUN) tools/test.py --swarm
75
+
76
+ test-vulkan:
77
+ @test "$(VULKAN)" = 1 || { printf '%s\n' 'Use make test-vulkan VULKAN=1 to build and test the Vulkan runtime.'; exit 1; }
78
+ $(MAKE) build test-deps
79
+ $(RUN) tools/test.py --vulkan-validation --swarm
80
+
81
+ test-rtdetr: build test-deps rtdetr-deps reference
82
+ MUNET_TEST_VULKAN=0 $(RUN) tools/test.py examples/rtdetr/tests
83
+
84
+ test-zoo: build test-deps reference
85
+ $(if $(filter 1,$(VULKAN)),$(RUN) tools/test.py --vulkan-validation examples/zoo/tests,MUNET_TEST_VULKAN=0 $(RUN) tools/test.py examples/zoo/tests)
86
+
87
+ smoke: build
88
+ $(RUN) examples/train_mlp.py --device "$(DEVICE)" --steps 20
89
+
90
+ # Normal installation for scripts outside this checkout; rerun after source edits.
91
+ install: deps
92
+ "$(VENV_PYTHON)" -m pip install --no-build-isolation --no-deps . -Ccmake.define.MUNET_VULKAN=$(if $(filter 0,$(VULKAN)),OFF,ON)
93
+
94
+ clean:
95
+ @if test -f "$(BUILD_DIR)/CMakeCache.txt"; then "$(VENV_PYTHON)" -m cmake --build "$(BUILD_DIR)" --target clean; fi