pacrunner 0.5.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.
- pacrunner-0.5.1/LICENSE +21 -0
- pacrunner-0.5.1/MANIFEST.in +6 -0
- pacrunner-0.5.1/PKG-INFO +453 -0
- pacrunner-0.5.1/README.md +425 -0
- pacrunner-0.5.1/pacrunner/__init__.py +55 -0
- pacrunner-0.5.1/pacrunner/_artifacts.py +259 -0
- pacrunner-0.5.1/pacrunner/_env.py +260 -0
- pacrunner-0.5.1/pacrunner/_libraries.py +314 -0
- pacrunner-0.5.1/pacrunner/_literal.py +52 -0
- pacrunner-0.5.1/pacrunner/_mad.py +276 -0
- pacrunner-0.5.1/pacrunner/_madgraph.py +357 -0
- pacrunner-0.5.1/pacrunner/_mgrun.py +110 -0
- pacrunner-0.5.1/pacrunner/_pyamplicol.py +134 -0
- pacrunner-0.5.1/pacrunner/_runtime.py +142 -0
- pacrunner-0.5.1/pacrunner/c/UMAMI_LICENSE +41 -0
- pacrunner-0.5.1/pacrunner/c/cuda/pool.cu +151 -0
- pacrunner-0.5.1/pacrunner/c/cuda/pool.h +55 -0
- pacrunner-0.5.1/pacrunner/c/cuda/uirgpu.c +103 -0
- pacrunner-0.5.1/pacrunner/c/cuda/uirgpu.h +70 -0
- pacrunner-0.5.1/pacrunner/c/cuda/uirgpu_pool.c +89 -0
- pacrunner-0.5.1/pacrunner/c/cuda/uirgpu_provider.c +103 -0
- pacrunner-0.5.1/pacrunner/c/cuda/uirgpu_umami.c +108 -0
- pacrunner-0.5.1/pacrunner/c/metal/PLAN.md +248 -0
- pacrunner-0.5.1/pacrunner/c/metal/df64.h +185 -0
- pacrunner-0.5.1/pacrunner/c/metal/metalpool.h +47 -0
- pacrunner-0.5.1/pacrunner/c/metal/metalpool.m +93 -0
- pacrunner-0.5.1/pacrunner/c/metal/msl_shim.h +86 -0
- pacrunner-0.5.1/pacrunner/c/metal/pacops.metal +472 -0
- pacrunner-0.5.1/pacrunner/c/metal/uirmetal.h +42 -0
- pacrunner-0.5.1/pacrunner/c/metal/uirmetal.m +222 -0
- pacrunner-0.5.1/pacrunner/c/metal/uirvm.metal +491 -0
- pacrunner-0.5.1/pacrunner/c/metal/umami_metal.c +230 -0
- pacrunner-0.5.1/pacrunner/c/pacops.c +498 -0
- pacrunner-0.5.1/pacrunner/c/pacops.h +210 -0
- pacrunner-0.5.1/pacrunner/c/uirvm.c +408 -0
- pacrunner-0.5.1/pacrunner/c/uirvm.h +165 -0
- pacrunner-0.5.1/pacrunner/c/umami.h +334 -0
- pacrunner-0.5.1/pacrunner/c/umami_finish.h +109 -0
- pacrunner-0.5.1/pacrunner/c/umami_pac.c +558 -0
- pacrunner-0.5.1/pacrunner/codegen/__init__.py +21 -0
- pacrunner-0.5.1/pacrunner/codegen/common.py +355 -0
- pacrunner-0.5.1/pacrunner/codegen/compile.py +245 -0
- pacrunner-0.5.1/pacrunner/codegen/compile_metal.py +246 -0
- pacrunner-0.5.1/pacrunner/codegen/compile_simd.py +1006 -0
- pacrunner-0.5.1/pacrunner/codegen/compile_split.py +443 -0
- pacrunner-0.5.1/pacrunner/codegen/compile_vm.py +236 -0
- pacrunner-0.5.1/pacrunner/kernels/__init__.py +18 -0
- pacrunner-0.5.1/pacrunner/kernels/kernel_c.py +744 -0
- pacrunner-0.5.1/pacrunner/kernels/kernel_msl.py +84 -0
- pacrunner-0.5.1/pacrunner/kernels/mir.py +368 -0
- pacrunner-0.5.1/pacrunner/simd/__init__.py +3 -0
- pacrunner-0.5.1/pacrunner/simd/elf.py +177 -0
- pacrunner-0.5.1/pacrunner/simd/handgen.py +235 -0
- pacrunner-0.5.1/pacrunner/simd/lib/closure_1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/closure_2.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/closure_3.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/closure_4.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/closure_5.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/closure_6.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/config.json +37 -0
- pacrunner-0.5.1/pacrunner/simd/lib/propagator_vector.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/propagator_weyl_a.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/propagator_weyl_b.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/vertex_tensor_vector_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/vertex_tensor_vector_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/vertex_three_vector_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/vertex_three_vector_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/vertex_vector_wedge_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/vertex_vector_wedge_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/vertex_weyl_vector_a_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/vertex_weyl_vector_a_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/vertex_weyl_vector_b_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/vertex_weyl_vector_b_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_dirac_anti_1_massive.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_dirac_anti_1_massless.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_dirac_anti_m1_massive.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_dirac_anti_m1_massless.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_dirac_part_1_massive.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_dirac_part_1_massless.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_dirac_part_m1_massive.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_dirac_part_m1_massless.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_gluon_1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_gluon_m1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_massive_vector_0.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_massive_vector_1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_massive_vector_m1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_weyl_anti_1_1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_weyl_anti_1_m1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_weyl_anti_m1_1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_weyl_anti_m1_m1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_weyl_part_1_1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_weyl_part_1_m1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_weyl_part_m1_1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib/wave_weyl_part_m1_m1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/closure_1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/closure_2.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/closure_3.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/closure_4.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/closure_5.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/closure_6.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/propagator_vector.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/propagator_weyl_a.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/propagator_weyl_b.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/vertex_tensor_vector_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/vertex_tensor_vector_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/vertex_three_vector_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/vertex_three_vector_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/vertex_vector_wedge_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/vertex_vector_wedge_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/vertex_weyl_vector_a_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/vertex_weyl_vector_a_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/vertex_weyl_vector_b_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx2/vertex_weyl_vector_b_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/closure_1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/closure_2.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/closure_3.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/closure_4.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/closure_5.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/closure_6.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/propagator_vector.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/propagator_weyl_a.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/propagator_weyl_b.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/vertex_tensor_vector_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/vertex_tensor_vector_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/vertex_three_vector_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/vertex_three_vector_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/vertex_vector_wedge_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/vertex_vector_wedge_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/vertex_weyl_vector_a_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/vertex_weyl_vector_a_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/vertex_weyl_vector_b_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_avx512/vertex_weyl_vector_b_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/closure_1.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/closure_2.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/closure_3.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/closure_4.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/closure_5.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/closure_6.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/propagator_vector.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/propagator_weyl_a.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/propagator_weyl_b.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/vertex_tensor_vector_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/vertex_tensor_vector_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/vertex_three_vector_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/vertex_three_vector_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/vertex_vector_wedge_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/vertex_vector_wedge_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/vertex_weyl_vector_a_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/vertex_weyl_vector_a_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/vertex_weyl_vector_b_add.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/lib_hand_neon/vertex_weyl_vector_b_set.json +1 -0
- pacrunner-0.5.1/pacrunner/simd/library.py +495 -0
- pacrunner-0.5.1/pacrunner/simd/mir.py +233 -0
- pacrunner-0.5.1/pacrunner/simd/split_kernel.py +308 -0
- pacrunner-0.5.1/pacrunner/uir/__init__.py +25 -0
- pacrunner-0.5.1/pacrunner/uir/encode.py +212 -0
- pacrunner-0.5.1/pacrunner/uir/export.py +482 -0
- pacrunner-0.5.1/pacrunner/uir/passes.py +69 -0
- pacrunner-0.5.1/pacrunner/uir/types.py +318 -0
- pacrunner-0.5.1/pacrunner/uir/validate.py +333 -0
- pacrunner-0.5.1/pacrunner/umami.py +636 -0
- pacrunner-0.5.1/pacrunner.egg-info/PKG-INFO +453 -0
- pacrunner-0.5.1/pacrunner.egg-info/SOURCES.txt +166 -0
- pacrunner-0.5.1/pacrunner.egg-info/dependency_links.txt +1 -0
- pacrunner-0.5.1/pacrunner.egg-info/requires.txt +5 -0
- pacrunner-0.5.1/pacrunner.egg-info/top_level.txt +1 -0
- pacrunner-0.5.1/pyproject.toml +59 -0
- pacrunner-0.5.1/setup.cfg +4 -0
pacrunner-0.5.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shahriar Iravanian
|
|
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.
|
pacrunner-0.5.1/PKG-INFO
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pacrunner
|
|
3
|
+
Version: 0.5.1
|
|
4
|
+
Summary: pyAmpliCol's LC recurrence programs as UMAMI libraries for MadGraph7/MadSpace (CPU, CUDA), from Python
|
|
5
|
+
Author: Shahriar Iravanian
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/shahriariravanian/pacrunner
|
|
8
|
+
Project-URL: Source, https://github.com/shahriariravanian/pacrunner
|
|
9
|
+
Project-URL: Issues, https://github.com/shahriariravanian/pacrunner/issues
|
|
10
|
+
Keywords: MadGraph7,MadSpace,pyAmpliCol,UMAMI,matrix elements,CUDA,SIMD,particle physics
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: C
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
License-File: pacrunner/c/UMAMI_LICENSE
|
|
23
|
+
Requires-Dist: numpy
|
|
24
|
+
Requires-Dist: symjit>=2.29.3
|
|
25
|
+
Provides-Extra: cuda
|
|
26
|
+
Requires-Dist: cupy-cuda13x; extra == "cuda"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# PacRunner
|
|
30
|
+
|
|
31
|
+
PacRunner is a compiler to convert [pyAmpliCol](https://github.com/MadGraphTeam/pyamplicol)'s recurrence
|
|
32
|
+
mode processes to UMAMI-compatible libraries for both CPU and GPU.
|
|
33
|
+
|
|
34
|
+
Unified MAtrix eleMent Interface (UMAMI) is a standard interface to bridge various matrix elements
|
|
35
|
+
generators and [MadGraph](https://github.com/MadGraphTeam/MadGraph7) ecosystem.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
1. Clone [MadGraph7](https://github.com/MadGraphTeam/MadGraph7/):
|
|
40
|
+
`git clone https://github.com/MadGraphTeam/MadGraph7.git`.
|
|
41
|
+
2. Build MadSpace and pyAmpliCol inside the checkout, either from the MadGraph7 prompt
|
|
42
|
+
(`./bin/madgraph`, then `install madspace` and `install pyamplicol`) or from the checkout's root:
|
|
43
|
+
```sh
|
|
44
|
+
python madspace/install.py --source -y
|
|
45
|
+
python pyamplicol/install.py --source -y
|
|
46
|
+
```
|
|
47
|
+
Do not pass `--system`: the builds go to `madspace/install` and `pyamplicol/install`.
|
|
48
|
+
3. Optional, for `device="cuda_full"` (MadSpace itself on the GPU): a CUDA build of MadSpace in
|
|
49
|
+
`madspace/install-cuda`, next to the CPU build of step 2 (whose build dependencies it uses):
|
|
50
|
+
```sh
|
|
51
|
+
cd madspace
|
|
52
|
+
PYTHONPATH=install python -m pip install --no-build-isolation --upgrade \
|
|
53
|
+
-Cbuild-dir=build-cuda --target=install-cuda \
|
|
54
|
+
-Ccmake.define.ENABLE_CUDA=ON -Ccmake.define.CMAKE_CUDA_ARCHITECTURES=120 \
|
|
55
|
+
-Ccmake.define.ENABLE_OPENBLAS=ON -Ccmake.build-type=Release .
|
|
56
|
+
```
|
|
57
|
+
`device="cuda"` does not need it (the matrix elements on the GPU, MadSpace on the CPU).
|
|
58
|
+
4. Install PacRunner from PyPI: `python -m pip install pacrunner`, or `python -m pip install "pacrunner[cuda]"`
|
|
59
|
+
for the CUDA devices (it adds CuPy). numpy and symjit (2.29.3 or later) come with it; to use conda-forge's
|
|
60
|
+
symjit, install it first (`conda install -c conda-forge 'symjit>=2.29.3'`) and pip keeps it.
|
|
61
|
+
5. Or, to work on PacRunner itself, install it from a clone, editable:
|
|
62
|
+
`git clone https://github.com/shahriariravanian/pacrunner`, `cd pacrunner`, then `python -m pip install -e .`
|
|
63
|
+
(the tests and the tutorial are in the clone, not in the PyPI package).
|
|
64
|
+
6. Point PacRunner at the MadGraph7 checkout: `export PACRUNNER_MADGRAPH7=/path/to/MadGraph7`, or
|
|
65
|
+
`pacrunner.configure(madgraph7="/path/to/MadGraph7")` before the first runtime. PacRunner then
|
|
66
|
+
imports MadSpace from `madspace/install-cuda` when it exists and from `madspace/install` otherwise
|
|
67
|
+
(`configure(cuda=False)`: the CPU build), and finds pyAmpliCol in `pyamplicol/install`. Do not put
|
|
68
|
+
these folders on `PYTHONPATH`: a MadSpace imported before PacRunner chooses its build cannot be
|
|
69
|
+
switched (`configure` then fails with "MadSpace is already loaded in this process"). Without
|
|
70
|
+
either setting, PacRunner uses the MadGraph7 an mg7 output was made with, or a `madspace`
|
|
71
|
+
installed in the python.
|
|
72
|
+
7. Optional tests, in a clone: `python -m unittest discover -s test/python` (see [Tests](#tests)).
|
|
73
|
+
8. Set `export NVCC=path/to/nvcc` (optional, should be needed only if CUDA is installed in a non-standard location).
|
|
74
|
+
|
|
75
|
+
You also need a C compiler (`cc`, or `CC`), and `nvcc` for the GPU devices.
|
|
76
|
+
|
|
77
|
+
## Quick Start
|
|
78
|
+
|
|
79
|
+
Before explaining how PacRunner works, let's run a simple example showcasing the interaction
|
|
80
|
+
between pyAmpliCol and MadGraph.
|
|
81
|
+
|
|
82
|
+
Start in a scratch folder. First, we generate a process by running
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
pyamplicol generate "u u~ > z g g" artifacts/zgg --color-accuracy lc --emit-api-bundle
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Now, `artifacts/zgg` is the artifact folder generated by pyAmpliCol for the "u u~ > z g g" process.
|
|
89
|
+
In addition, `artifacts/zgg/API/umami/` contains the source for the UMAMI wrapper. However, it is not
|
|
90
|
+
compiled yet. You can compile it as `make -C artifacts/zgg/API/umami/`, but PacRunner will compile it
|
|
91
|
+
on demand if not available. After this command is executed, the compiled UMAMI driver (`libumami.so`
|
|
92
|
+
or `libumami.dylib`) is placed in `artifacts/.pyamplicol-api-build/zgg/umami/`.
|
|
93
|
+
|
|
94
|
+
First, let's see how PacRunner's Python API works. The first example does not use PacRunner's
|
|
95
|
+
compiler and runs the stock matrix-element generator:
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
import pacrunner
|
|
99
|
+
|
|
100
|
+
a = pacrunner.Artifact("artifacts/zgg/") # a pyAmpliCol artifact
|
|
101
|
+
process, momenta = a.validation_points()[0]
|
|
102
|
+
batch = momenta[None, :, :] # a batch of one event
|
|
103
|
+
provider_stock = a.stock() # pyAmpliCol's own provider (libumami.so beside the artifact)
|
|
104
|
+
rt_stock = provider_stock.runtime() # a pacrunner.Runtime of its channel 0
|
|
105
|
+
print(rt_stock(batch, 0).matrix_element) # should print [2.43239313e-05]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Some terminology: An `Artifact` is the output folder of pyAmpliCol or a sub-process of MadMatrix.
|
|
109
|
+
A `Provider` is a unit of computation and `Runtime` means `madspace.Runtime`. The general program
|
|
110
|
+
flow is `Artifact -> Provider -> Runtime`. In the previous example, we used the stock provider. Next
|
|
111
|
+
example shows how to generate a CPU provider using PacRunner:
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
import pacrunner
|
|
115
|
+
|
|
116
|
+
a = pacrunner.Artifact("artifacts/zgg/") # a pyAmpliCol artifact
|
|
117
|
+
process, momenta = a.validation_points()[0]
|
|
118
|
+
batch = momenta[None, :, :] # a batch of one event
|
|
119
|
+
provider_cpu = a.compile(device="cpu") # PacRunner's provider on the CPU
|
|
120
|
+
rt_cpu = provider_cpu.runtime() # a pacrunner.Runtime of its channel 0
|
|
121
|
+
print(rt_cpu(batch, 0).matrix_element) # should print [2.43239313e-05]
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The main change is using `a.compile(device="cpu")` instead of `a.stock()`. This function does the
|
|
125
|
+
following operations:
|
|
126
|
+
|
|
127
|
+
1. Creating a folder `artifacts/.pacrunner-build/zgg/p0-cpu/`.
|
|
128
|
+
2. Exporting the recurrence program using `pyamplicol --export-recurrence` and saving it as `artifacts/.pacrunner-build/zgg/p0-cpu/export.json`.
|
|
129
|
+
3. Writing the source files for the CPU provider using `export.json` and the meta data in `artifacts/zgg`.
|
|
130
|
+
4. The source files are written to `artifacts/.pacrunner-build/zgg/p0-cpu/programs/0000`.
|
|
131
|
+
5. The source folder is compiled to generate `libumami_pac.so`.
|
|
132
|
+
|
|
133
|
+
We will discuss the files in the source folder below.
|
|
134
|
+
|
|
135
|
+
The SIMD devices build a faster CPU provider: each program becomes one symjit kernel (PacRunner's library of
|
|
136
|
+
the UIR operations in `pacrunner/simd/`, spliced by `codegen/compile_simd.py`), compiled by symjit's JIT for one
|
|
137
|
+
instruction set:
|
|
138
|
+
|
|
139
|
+
| Device | Machine | Events per kernel call (f64 / split) |
|
|
140
|
+
|---|---|---|
|
|
141
|
+
| `simd-avx2` | x86-64 with AVX2 and FMA | 4 / 8 |
|
|
142
|
+
| `simd-avx512` | x86-64 with AVX-512 (F, DQ) | 8 / 16 |
|
|
143
|
+
| `simd-neon` | aarch64 (Linux, macOS) | 2 / 4 |
|
|
144
|
+
|
|
145
|
+
`simd` is this machine's: `simd-avx512` where the CPU has AVX-512, else `simd-avx2`, and `simd-neon` on
|
|
146
|
+
aarch64. A SIMD device builds on a machine whose CPU runs it (symjit's JIT compiles the kernels for it), and its
|
|
147
|
+
library checks the CPU when it loads. PacRunner writes the machine code as object files (`pacrunner/simd/elf.py`:
|
|
148
|
+
an ELF object on x86-64, an assembler file on aarch64; the kernels call no functions, so they need no
|
|
149
|
+
relocations) and links them with the UMAMI layer. The values are the `cpu` provider's bit for bit; it needs
|
|
150
|
+
nothing beyond symjit and `cc`.
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
provider_simd = a.compile(device="simd") # PacRunner's SIMD provider on the CPU
|
|
154
|
+
rt_simd = provider_simd.runtime(0)
|
|
155
|
+
print(rt_simd(batch, 0).matrix_element) # should print [2.43239313e-05], as the cpu provider
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`compile(device="simd", precision="split")` (or the device names `simd-split`, `simd-avx2-split`,
|
|
159
|
+
`simd-avx512-split`, `simd-neon-split`) runs each program as two kernels: kernel A in f64 computes what needs
|
|
160
|
+
f64 from the momenta (the forms, `1/k²` of the propagators, the sources' wavefunctions, the wide parts of the
|
|
161
|
+
model kernels: their denominators `k² − M²`), rounded to f32; kernel B computes the rest (vertices, propagators,
|
|
162
|
+
model kernels, amplitudes, the reduction) in f32 at twice the lanes. Kernel B is symjit's f32 twin of its f64
|
|
163
|
+
kernel (`dump(.., "simd-f32")`: the machine code rewritten instruction by instruction, symjit >= 2.29.2);
|
|
164
|
+
`codegen/compile_split.py` splits the program. The matrix element is within about 1e-6 of f64, and 1.2–1.9×
|
|
165
|
+
faster than f64 on x86-64 (more with model kernels and many propagators). The precision's former name, `mixed`,
|
|
166
|
+
is accepted on a SIMD device.
|
|
167
|
+
|
|
168
|
+
`compile(device="cpu-jit")` is the CPU runner made by symjit instead of the C compiler: the SIMD device's kernel
|
|
169
|
+
of each program (the application of `simd-avx2` on x86-64, of `simd-neon` on aarch64: the same fragments,
|
|
170
|
+
subroutines and chained runs) as symjit's scalar code, one event per kernel call, in the same UMAMI layer. f64,
|
|
171
|
+
the `cpu` provider's bits; it builds where a SIMD device does. It runs fewer instructions than the C runner (no
|
|
172
|
+
generic `vertex()` and its dispatch) but its code is larger: on a Ryzen 9900X it is 0.8× of `cpu` for small
|
|
173
|
+
programs and 1.3× for large ones (`d d~ > z + 5 g`, one flow); on the M4 0.86–0.98× of `cpu`.
|
|
174
|
+
|
|
175
|
+
For now, let's continue with generating CUDA providers.
|
|
176
|
+
PacRunner currently supports two types of GPU backend: `compile(device="cuda")` and `compile(device="cuda_provider")`
|
|
177
|
+
(also called `device="cuda_full"`: everything on the GPU).
|
|
178
|
+
|
|
179
|
+
The first one is a hybrid provider, where the UMAMI library identifies itself as a "CPU" provider but actually runs CUDA
|
|
180
|
+
kernels. The second one is a full CUDA provider that identifies itself as "CUDA".
|
|
181
|
+
|
|
182
|
+
On macOS, `compile(device="metal")` builds the same kind of hybrid provider for an Apple GPU through
|
|
183
|
+
Metal; it always computes in mixed precision (f32 and double-f32), since Metal has no f64. For code
|
|
184
|
+
that runs on both, `compile(device="gpu")` picks `metal` on macOS and `cuda` elsewhere
|
|
185
|
+
(`pacrunner/c/metal/PLAN.md`: the Metal runner, its tests and results).
|
|
186
|
+
|
|
187
|
+
First, the `cuda` option:
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
import pacrunner
|
|
191
|
+
|
|
192
|
+
a = pacrunner.Artifact("artifacts/zgg/") # a pyAmpliCol artifact
|
|
193
|
+
process, momenta = a.validation_points()[0]
|
|
194
|
+
batch = momenta[None, :, :] # a batch of one event, in host memory
|
|
195
|
+
provider_cuda = a.compile(device="cuda") # PacRunner's provider on the GPU, called from the CPU
|
|
196
|
+
rt_cuda = provider_cuda.runtime() # a pacrunner.Runtime of its channel 0
|
|
197
|
+
print(rt_cuda(batch, 0).matrix_element) # should print [2.43239313e-05]
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
In this example, only the `device` option is changed. The source folder is now `artifacts/.pacrunner-build/zgg/p0-cuda/programs/0000`
|
|
201
|
+
and has additional files, which will be discussed below. Next, the `cuda_full` option (alias `cuda_provider`):
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
import pacrunner
|
|
205
|
+
import cupy as cp
|
|
206
|
+
|
|
207
|
+
a = pacrunner.Artifact("artifacts/zgg/") # a pyAmpliCol artifact
|
|
208
|
+
process, momenta = a.validation_points()[0]
|
|
209
|
+
batch = cp.array(momenta[None, :, :]) # a batch of one event, in GPU memory
|
|
210
|
+
provider_gpu = a.compile(device="cuda_full") # PacRunner's CUDA provider (alias: "cuda_provider")
|
|
211
|
+
rt_gpu = provider_gpu.runtime() # a pacrunner.Runtime of its channel 0, on a CUDA context
|
|
212
|
+
print(rt_gpu(batch, 0).matrix_element) # should print [2.43239313e-05]
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Note that for `device="cuda_full"`, we need to pass the momenta wrapped in a CuPy array.
|
|
216
|
+
|
|
217
|
+
## MadMatrix
|
|
218
|
+
|
|
219
|
+
The previous examples all used the pyAmpliCol directly to generate matrix elements. However, to find the cross-section, we need
|
|
220
|
+
Madspace. We start with generating the process:
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
$ mkdir -p processes
|
|
224
|
+
mg7> generate u u~ > z g g [amplicol]
|
|
225
|
+
mg7> output mg7 processes/zgg
|
|
226
|
+
mg7> output mg7 processes/zgg_gpu
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
`processes/` must exist: MadGraph7 creates no parent folders (it fails with a `FileNotFoundError`).
|
|
230
|
+
The second output, `processes/zgg_gpu`, is for the end-to-end GPU run below, which needs its own run
|
|
231
|
+
card.
|
|
232
|
+
|
|
233
|
+
We can load the resulting folder using `pacrunner.Output`. Each `Output` has a set of sub-processes,
|
|
234
|
+
which can be names using `names` or accessed using `subprocess(name)` or `subprocesses()`. Each
|
|
235
|
+
subprocess is a pyAmpliCol artifact with additional metadata. Therefore, we can adopt the same code
|
|
236
|
+
as above to generate matrix elements:
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
import numpy as np
|
|
240
|
+
import pacrunner
|
|
241
|
+
|
|
242
|
+
out = pacrunner.Output("processes/zgg")
|
|
243
|
+
a = out.subprocess("A1_uux_zgg")
|
|
244
|
+
|
|
245
|
+
momenta = np.array([
|
|
246
|
+
[500., 0., 0., 500.],
|
|
247
|
+
[500., 0., 0., -500.],
|
|
248
|
+
[142.22002372, -53.10090083, 59.0409804, -74.87149502],
|
|
249
|
+
[380.350097, -268.20692462, 256.15852034, -84.34485361],
|
|
250
|
+
[477.42987928, 321.30782545, -315.19950074, 159.21634863]])
|
|
251
|
+
|
|
252
|
+
batch = momenta[None, :, :] # a batch of one event
|
|
253
|
+
provider_cpu = a.compile(device="cpu") # PacRunner's provider, at the param card's parameters
|
|
254
|
+
rt_cpu = provider_cpu.runtime() # a pacrunner.Runtime of its channel 0
|
|
255
|
+
print(rt_cpu(batch, 0).matrix_element) # should print [2.43239313e-05]
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
We can use Madspace to calculate a process cross-section:
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
import pacrunner
|
|
262
|
+
|
|
263
|
+
out = pacrunner.Output("processes/zgg")
|
|
264
|
+
a = out.subprocess("A1_uux_zgg")
|
|
265
|
+
|
|
266
|
+
# the matrix elements on the GPU, MadSpace on the CPU: the output's default run card works
|
|
267
|
+
provider_cuda = a.compile(device="cuda")
|
|
268
|
+
print(provider_cuda.run().cross_section) # should print about 75.3 (pb, ± 0.2: the default card draws a new seed each run)
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Note that passing `cuda` uses the hybrid mode with a CPU interface; therefore, it works with the
|
|
272
|
+
CPU-only build of Madspace and the output's default run card. The default card draws a new random
|
|
273
|
+
seed for each run (`seed = -1`), so the cross section differs from run to run within its error (about
|
|
274
|
+
0.2 pb here); set `seed` in `Cards/run_card.toml` for a reproducible one.
|
|
275
|
+
|
|
276
|
+
We can do an end-to-end GPU run by passing `device="cuda_full"` (or its alias `"cuda_provider"`),
|
|
277
|
+
assuming Madspace is built for CUDA ([Installation](#installation), step 3). MadSpace then runs on the GPU too, which needs the run card's
|
|
278
|
+
`device = ["cuda"]`, and leading colour (`color_accuracy = "lc"`): the full-colour correction is a CPU
|
|
279
|
+
library. Hence the second output:
|
|
280
|
+
|
|
281
|
+
```python
|
|
282
|
+
import re
|
|
283
|
+
from pathlib import Path
|
|
284
|
+
import pacrunner
|
|
285
|
+
|
|
286
|
+
# everything on the GPU (MadSpace's CUDA build): the run card needs run.device = ["cuda"] and leading
|
|
287
|
+
# colour (the full-colour correction is a CPU library), so a second output, processes/zgg_gpu
|
|
288
|
+
card = Path("processes/zgg_gpu/Cards/run_card.toml")
|
|
289
|
+
text = re.sub(r'(?m)^device = .*$', 'device = ["cuda"]', card.read_text())
|
|
290
|
+
text = re.sub(r'(?m)^color_accuracy = .*$', 'color_accuracy = "lc"', text)
|
|
291
|
+
card.write_text(text)
|
|
292
|
+
|
|
293
|
+
out = pacrunner.Output("processes/zgg_gpu")
|
|
294
|
+
a = out.subprocess("A1_uux_zgg")
|
|
295
|
+
provider_gpu = a.compile(device="cuda_full") # alias of "cuda_provider"
|
|
296
|
+
print(provider_gpu.run().cross_section) # should print about 94.4 (pb, ± 0.2: leading colour, so above the full-colour 75.3)
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
The leading-colour cross section is larger than the full-colour one (about 94.4 against 75.5 pb for
|
|
300
|
+
this process): the colour approximation, not a GPU difference.
|
|
301
|
+
|
|
302
|
+
## Benchmarks
|
|
303
|
+
|
|
304
|
+
The scripts that measure these are in [`bench/`](https://github.com/shahriariravanian/pacrunner/blob/main/bench/README.md): `bench/bench_full.sh` (every CPU, SIMD
|
|
305
|
+
and GPU variant this machine runs) and `bench/bench_cpu.sh` (without the GPU), on five processes.
|
|
306
|
+
|
|
307
|
+
`u u~ > z g g g g`, one MadGraph7 `generate_events` run of 100k events per mode, on three machines.
|
|
308
|
+
|
|
309
|
+
**Wall clock (s)**
|
|
310
|
+
|
|
311
|
+
| Mode | Precision | RTX 5060 + Ryzen 9900X | H100 + EPYC 9334 | M4 Mac mini |
|
|
312
|
+
| --- | --- | ---: | ---: | ---: |
|
|
313
|
+
| stock (pyAmpliCol) | f64 | 95.4 | 126.4 | 129.9 |
|
|
314
|
+
| `cpu` | f64 | 44.4 | 48.5 | 58.4 |
|
|
315
|
+
| `simd` (AVX-512) | f64 | 21.4 | 25.0 | — |
|
|
316
|
+
| `simd` (AVX2) | f64 | 26.0 | 26.7 | — |
|
|
317
|
+
| `gpu` (cuda / metal) | f64 | 28.6 | 11.6 | — |
|
|
318
|
+
| `gpu` (cuda / metal) | mixed | 15.6 | 11.2 | 24.9 |
|
|
319
|
+
| `cuda_full` | f64 | 38.1 | 6.78 | — |
|
|
320
|
+
| `cuda_full` | mixed | 15.3 | 5.31 | — |
|
|
321
|
+
|
|
322
|
+
**Matrix element per point (µs)**: the time inside the matrix-element library per event, summed over
|
|
323
|
+
MadSpace's threads.
|
|
324
|
+
|
|
325
|
+
| Mode | Precision | RTX 5060 + Ryzen 9900X | H100 + EPYC 9334 | M4 Mac mini |
|
|
326
|
+
| --- | --- | ---: | ---: | ---: |
|
|
327
|
+
| stock (pyAmpliCol) | f64 | 61.6 | 80.9 | 42.0 |
|
|
328
|
+
| `cpu` | f64 | 23.6 | 23.3 | 15.7 |
|
|
329
|
+
| `simd` (AVX-512) | f64 | 6.50 | 10.2 | — |
|
|
330
|
+
| `simd` (AVX2) | f64 | 10.2 | 11.3 | — |
|
|
331
|
+
| `gpu` (cuda / metal) | f64 | 15.1 | 0.889 | — |
|
|
332
|
+
| `gpu` (cuda / metal) | mixed | 1.08 | 0.550 | 2.54 |
|
|
333
|
+
| `cuda_full` | f64 | 1.18\* | 0.158\* | — |
|
|
334
|
+
| `cuda_full` | mixed | 0.254\* | 0.091\* | — |
|
|
335
|
+
|
|
336
|
+
- Wall times: the fastest of 3 untimed runs (RTX 5060, H100); one untimed run after a warm-up (M4).
|
|
337
|
+
- `simd`: one symjit kernel per program, 8 events per call with AVX-512 (`simd-avx512`) and 4 with AVX2
|
|
338
|
+
(`simd-avx2`); the `cpu` provider's bits (the events of the two runs are identical). RTX 5060 machine: the fastest
|
|
339
|
+
of 2 runs, measured beside a fresh `cpu` run (44.7 s, 23.6 µs/pt); H100 machine: from the CPU benchmark below.
|
|
340
|
+
- `gpu` is CUDA on the RTX 5060 and H100, Metal on the M4 (mixed precision only; no `cuda_full`
|
|
341
|
+
counterpart).
|
|
342
|
+
- Per-point times for `gpu` include threads waiting for the shared GPU. \* `cuda_full`: measured
|
|
343
|
+
outside mg7 in synchronized 64k-event batches.
|
|
344
|
+
- MadSpace threads: 24 (RTX 5060, H100), 10 (M4). MadGraph7 2079d93; fixed scales, NNPDF23, seed 7,
|
|
345
|
+
64k batches, leading colour.
|
|
346
|
+
|
|
347
|
+
**The CPU modes on four processes**: stock, `cpu` and `simd`, wall clock (s, the fastest of 3 runs) and the
|
|
348
|
+
matrix element per point (µs, as above), 100k events, 24 threads; pacrunner 8dd5aeb, MadGraph7 2079d93.
|
|
349
|
+
`simd`'s events are those of `cpu`, bit for bit, in every row.
|
|
350
|
+
|
|
351
|
+
Ryzen 9 9900X (Zen 5):
|
|
352
|
+
|
|
353
|
+
| Process | stock | `cpu` | `simd` AVX-512 | `simd` AVX2 | ME stock | ME `cpu` | ME AVX-512 | ME AVX2 |
|
|
354
|
+
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
|
|
355
|
+
| `p p > z j j` | 39.8 | 6.72 | 5.58 | 5.76 | 31.5 | 2.62 | 0.831 | 1.07 |
|
|
356
|
+
| `p p > j j j` | 34.7 | 14.5 | 13.8 | 14.0 | 17.7 | 1.61 | 0.875 | 1.10 |
|
|
357
|
+
| `g g > t t~ g g` (full colour) | 44.1 | 25.5 | 16.2 | 17.4 | 38.1 | 15.6 | 2.95 | 4.34 |
|
|
358
|
+
| `u u~ > z g g g g` | 96.3 | 44.0 | 21.2 | 26.0 | 61.4 | 23.5 | 6.47 | 10.2 |
|
|
359
|
+
|
|
360
|
+
EPYC 9334 (Zen 4, the H100 machine's 24 vCPUs at 2.0 GHz):
|
|
361
|
+
|
|
362
|
+
| Process | stock | `cpu` | `simd` AVX-512 | `simd` AVX2 | ME stock | ME `cpu` | ME AVX-512 | ME AVX2 |
|
|
363
|
+
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
|
|
364
|
+
| `p p > z j j` | 47.1 | 6.18 | 4.62 | 4.65 | 32.2 | 2.90 | 0.993 | 1.08 |
|
|
365
|
+
| `p p > j j j` | 35.1 | 8.83 | 7.52 | 7.65 | 18.1 | 1.67 | 0.902 | 0.921 |
|
|
366
|
+
| `g g > t t~ g g` (full colour) | 64.0 | 35.9 | 25.4 | 25.5 | 53.4 | 20.6 | 5.44 | 5.98 |
|
|
367
|
+
| `u u~ > z g g g g` | 124.3 | 48.8 | 25.0 | 26.7 | 79.6 | 24.7 | 10.2 | 11.3 |
|
|
368
|
+
|
|
369
|
+
- `simd` gains most where the matrix element dominates (`g g > t t~ g g`, `u u~ > z g g g g`: 1.4–2.1× the
|
|
370
|
+
wall of `cpu`); for the light processes MadSpace's own work is most of the wall.
|
|
371
|
+
- Zen 4 runs 512-bit vectors as two 256-bit halves: AVX2 is within 1–10% of AVX-512 there, against
|
|
372
|
+
up to 1.6× slower on Zen 5.
|
|
373
|
+
|
|
374
|
+
## pyAmpliCol 1.0.x: RustiCol's recurrence export
|
|
375
|
+
|
|
376
|
+
pyAmpliCol 1.0.x writes an LC artifact's programs itself: `pyamplicol export-recurrence LC_DIR -o
|
|
377
|
+
capture.json`; the format is its `docs/reference/recurrence-export.md`).
|
|
378
|
+
|
|
379
|
+
## The compiled folder
|
|
380
|
+
|
|
381
|
+
| File | What it is |
|
|
382
|
+
| --- | --- |
|
|
383
|
+
| `runner.c` | the program: `int run(double *out, double *p, const double *momenta)` for one point |
|
|
384
|
+
| `runner.h` | its prototype and sizes: `RUNNER_LEGS`, `RUNNER_OUTPUTS`, `RUNNER_ARENA_SIZE` (the scratch `p`) |
|
|
385
|
+
| `pacops.c`, `pacops.h` | the sources and instructions |
|
|
386
|
+
| `Makefile` | `make` (`runner.o`, `pacops.o`, `testing`), `make clean`; `CC`, `CFLAGS` may be set |
|
|
387
|
+
|
|
388
|
+
With `interpreter=True`, `runner.c` holds the program as data (the encoded words, sources first, the
|
|
389
|
+
edge table and the tables they index, as one `uir_program`) and includes `uirvm.c`, the UIR
|
|
390
|
+
interpreter, copied next to it with `uirvm.h`. `run()`, `runner.h` and the values are the same, bit
|
|
391
|
+
for bit. The straight-line C is the CPU runner (about twice as fast); the interpreter is the GPU's,
|
|
392
|
+
and its CPU build is its test. The interpreter reads each row's fields straight from its word (the
|
|
393
|
+
`UIR_` macros of `uirvm.h`) and takes one-word rows only: a program with a wide row (an index beyond
|
|
394
|
+
the one-word fields) is refused.
|
|
395
|
+
|
|
396
|
+
The interpreter's `runner.c` also builds with nvcc: `make gpu` gives `runner_gpu.o` with
|
|
397
|
+
`int run_gpu(double *out, const double *momenta, size_t points)` (`uirvm.h`), every point on the GPU,
|
|
398
|
+
one thread each, momenta and outputs point by point on the host. Every function of `pacops`, `uirvm`
|
|
399
|
+
and the kernels is then a device function too (`PAC_FN`), and the tables are `__device__` data
|
|
400
|
+
(`UIR_DATA`). The outputs are the CPU build's bit for bit (`--fmad=false`, as `-ffp-contract=off`).
|
|
401
|
+
|
|
402
|
+
## Building libraries directly
|
|
403
|
+
|
|
404
|
+
`Artifact.compile` and `SubProcess.compile` export the programs and build the libraries for you. To
|
|
405
|
+
build from a recurrence export you already have, call `pacrunner.umami.umami_libraries`, or run it
|
|
406
|
+
from the command line (e.g. from another Python, such as MadGraph7's):
|
|
407
|
+
|
|
408
|
+
```sh
|
|
409
|
+
python -m pacrunner.umami EXPORT.json ARTIFACT/API/umami/metadata.json OUT --device cpu
|
|
410
|
+
python -m pacrunner.umami EXPORT.json METADATA OUT --device cuda_provider --precision mixed --cuda-arch sm_90
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
`OUT/umami_pac.json` then lists the libraries and each channel's flavours, for MadSpace;
|
|
414
|
+
`python -m pacrunner.umami --help` lists the options. Beneath it are the modules `pacrunner.uir` (the
|
|
415
|
+
export read into UIR programs, the passes, the 8-byte encoding), `pacrunner.kernels` (the symjit
|
|
416
|
+
kernels' MIR and their C) and `pacrunner.codegen` (a program as a compiled folder):
|
|
417
|
+
|
|
418
|
+
```python
|
|
419
|
+
from pacrunner import codegen, uir
|
|
420
|
+
|
|
421
|
+
programs = uir.load_recurrence_export("export.json") # one uir.Lowered per program
|
|
422
|
+
codegen.compile("folder", uir.optimize(programs[0])) # runner.c, runner.h, pacops.c, Makefile
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Indices are 0-based throughout, and an absent one is `None`.
|
|
426
|
+
|
|
427
|
+
## Tests
|
|
428
|
+
|
|
429
|
+
```sh
|
|
430
|
+
python -m unittest discover -s test/python
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
Without external tools this checks the export reader, the passes, the encoding, the kernels' C and the
|
|
434
|
+
compiled folders against pac-julia's outputs (`test/data/goldens`, byte for byte), and, with a C
|
|
435
|
+
compiler, that the fixture's compiled folders pass `make test` (RustiCol's reference values, bit for
|
|
436
|
+
bit).
|
|
437
|
+
The kernels' tests need symjit ≥ 2.29. The larger golden corpus (`tools/goldens`) is used when it is
|
|
438
|
+
at `PACRUNNER_GOLDENS` (default `~/symjit-data/pacrunner-goldens`). More tests run when their tools are
|
|
439
|
+
set:
|
|
440
|
+
|
|
441
|
+
| Variable | What it enables |
|
|
442
|
+
| --- | --- |
|
|
443
|
+
| `PACRUNNER_MADGRAPH7` | a MadGraph7 checkout with MadSpace: the runtime tests |
|
|
444
|
+
| `PACRUNNER_TEST_ARTIFACT`, `PACRUNNER_PYAMPLICOL` | an LC artifact and the pyAmpliCol that made it: export and compile |
|
|
445
|
+
| `PACRUNNER_TEST_MG7_OUTPUT`, `PACRUNNER_TEST_CUDA_OUTPUT`, `PACRUNNER_TEST_MG7_MULTI` | mg7 outputs: end-to-end runs against stock |
|
|
446
|
+
| `PACRUNNER_TEST_TUTORIAL=1` | the tutorial's snippets (`tutorial/`), about 3 minutes |
|
|
447
|
+
|
|
448
|
+
Symbolica (pyAmpliCol) needs a writable `XDG_RUNTIME_DIR`. The scripts in `test/` (`umami_check.py`,
|
|
449
|
+
`umami_check_gpu.py`, `test_libraries.py`, `mg7_run.py`, ...) compare built libraries against
|
|
450
|
+
pyAmpliCol's stock ones through MadSpace; each says how to run it.
|
|
451
|
+
|
|
452
|
+
The C must be built with `-ffp-contract=off` (nvcc: `--fmad=false`): the values are bit for bit only
|
|
453
|
+
without contracted multiply-adds.
|