MACE Kokkos source layout¶
The MACE Kokkos evaluator is split into semantic translation units. Each
translation unit owns a disjoint family of MACEKokkos method definitions and
explicitly instantiates both supported precisions. This keeps implementation
edits local and lets expensive CPU and accelerator template work compile in
parallel.
Owners¶
Source |
Responsibility |
|---|---|
|
Construction, destruction, backend and plugin policy, workspace admission, diagnostics, observers, and parameter-gradient setup |
|
Streamed modes and schedules, prepared graph state, Cartesian/fractional geometry lifecycle and device mapping, active types, and factorized model preparation |
|
Factorized R1 forward execution and direct and non-compiled reverse execution |
|
Factorized operator benchmarking and parameter-gradient kernels |
|
Force reductions and ordinary and field evaluator entry points |
|
Analytic field response; includes |
|
R0, R1, spherical harmonics, A0 variants, and M0 |
|
H1, field H1, and Phi1 forward and reverse paths |
|
A1 variants, M1, H2, and readouts |
|
JSON model loading and model-contract validation |
The authoritative build list is the SYMMETRIX_KOKKOS source block in
libsymmetrix/CMakeLists.txt. The layout contract is enforced by
symmetrix/test/test_mace_kokkos_source_partitioning.py. Its order is a build
scheduling contract: with the current equal-priority Ninja graph, longer CUDA
owners are listed first so they enter the ready queue before shorter owners.
The MACE_Nonlinear (MH-1) partition¶
The MH-1 evaluator is partitioned the same way, and the same test covers it.
Three translation units instantiate MaceNonlinearKokkosT from one
implementation body:
Source |
Responsibility |
|---|---|
|
|
|
|
|
|
mace_nonlinear_kokkos_impl.tpp is an implementation body, not a shared
header: it is included only by those three owners, so it is listed in no build
file and carried by no shared layer.
mace_nonlinear_stage.hpp is the family’s stage description. The interaction
layer count, every layer’s edge and node forward and reverse profiling region name,
and the ordered forward and reverse execution schedules are its data, built
from a layer count, so an evaluator that admits a different interaction count
profiles and dispatches it through the same value instead of a compiled-in
two-layer table. The region spelling it emits is the one
benchmarks/analyze_rocprof_kernels.py decodes, so a description built for any
count keeps the profile contract readable. The evaluator holds one description
built from the validated model’s layer count and reads its regions and phase
ordinals from it.
The region symbols align with standard MACE while preserving MH-1 fusion:
R<layer>+A<layer> is the layer’s fused radial/edge-aggregation program and
M<layer>+H<layer + 1> is its fused product/node-update program. Thus MH-1 has
H1 work, but no separate H1 launch boundary. The legacy R<layer> and
M<layer> spellings remain accepted by the profile analyzer for existing
traces.
Diagnostic child ranges refine those composite regions without changing the
execution ABI: /conditioning, /radial, /message, /product, and
/readout are emitted around the corresponding existing launches. A generated
post-forward or post-reverse kernel that still combines product completion and
the head is reported as a fused readout range; the code does not pretend that
this is a separate H1 or readout launch. Nsight Systems can opt into direct
NVTX emission with SYMMETRIX_MH1_NVTX=1; ordinary runs retain only the
zero-fence Kokkos profiling calls.
Placement rules¶
Declare public and cross-owner members in
mace_kokkos.hpp; define each member in exactly one semantic owner.Place a new method with the state or kernel family it changes. Calls between owners use class declarations rather than source inclusion.
End every owner with exactly one
template class MACEKokkos<float>;and onetemplate class MACEKokkos<double>;. Do not add per-method orexterninstantiation as part of an unrelated change.Keep
mace_kokkos_response.tppincluded only bymace_kokkos_response.cpp. It is an implementation body, not a shared header.Add a private detail header only when multiple owners require the same complete type or inline helper. Keep its consumer set explicit and acyclic.
Keep the standard M0/R0 module bodies and launch profiles under
libsymmetrix/source/. Runtime-generated R1 code belongs to the JIT compiler and cache rather than a checked-in generated-source directory.A family-owned extension point on a shared class stays behind an opaque handle: the shared class declares the handle and the entry points, the family layer defines them and owns the state.
E3TensorProductKokkosT(e3nn_kokkos.hpp) holdsdirect_execution_plan_this way, with the plan layout and every kernel that reads it inmace_nonlinear_mh1_fast_path.{hpp,cpp}, andE3ProductBasisKokkosT(e3nn_product_kokkos.hpp) holdscompiled_host_plan_this way, with the frozen term plan and its accumulation kernels inmace_nonlinear_product_host_plan.cpp. Shared translation units and shared headers must not include family headers or carry family state, so a consumer that never installs a plan keeps the generic schedule.A family-owned specialization of a shared template lives with the family that owns the types it names:
device_backend.hppkeeps the host-neutral environment probes and the primaryDeviceBackendTraitstemplate, while the CUDA/HIP specializations and device-scope guards that alias the MACE JIT ABI packet structs and plugin classes live inmace_device_backend.{hpp,cpp}.
Rebuild expectations¶
Editing one .cpp owner should recompile that owner and relink its targets, but
must not recompile the other nine owners. Editing a private detail header should
recompile only the consumers listed above. Changes to mace_kokkos.hpp remain
class-wide and are expected to rebuild every owner.
After changing ownership or shared dependencies, run the source-partitioning
test, build at least one supported backend, and compare the normalized
MACEKokkos<float> and MACEKokkos<double> symbol inventory with the previous
layout. Backend-specific build and runtime coverage must be reported
separately.