hawk.artifact.build_bundle

Contents

hawk.artifact.build_bundle#

hawk.artifact.build_bundle(kernels, directory, *, mode='float64', targets=('cuda', 'host'), kind=None, layout_sizes_override=None, defines=(), cache_dir=None, device_arch='', name=None, derivative=None, host_profile='', opt_level='')[source]#

Build every kernel into directory and write ONE manifest.json over them. Every member must agree on the execution axis (a manifest-level, not per-entry, declaration) — a set that doesn’t agree is two bundles.

This is the DEPLOYMENT UNIT: publishing is content-addressed (see the module docstring) — a repeat build of an already-published definition recompiles nothing, copying files into a different directory if asked, so the returned Bundle always names a directory that genuinely holds the unit.

derivative names each derivative kernel’s primal, per kernel: {kernel_name: primal_name}, or leave it (None) to use a hawk.diff.vjp()/jvp() kernel’s own recorded primal. A primal outside this bundle is named by {kernel_name: (primal_name, primal_unit_digest)} via its Bundle.digest — needed when the primal and its scattering VJP can’t share one manifest.

host_profile picks the host code-gen profile (hawk.compile.toolchain.HOST_PROFILES): "native-vector-math" (default on x86-64 with a GCC host compiler) or "native" (libm bit-identity) for a bundle built on the machine that runs it, "portable" for one that’s prebuilt and shipped. Empty means $HAWK_HOST_PROFILE, else hawk.compile.toolchain.default_host_profile().

opt_level picks the optimisation level (hawk.compile.toolchain.OPT_LEVELS: "O0"..``”O3”), the same way for every target this bundle builds: ``-O<n> on the host build and on an AOT nvcc device build (nvcc’s own -O<n> plus -Xptxas -O<n>); NVRTC device compiles always optimise and ignore it. Empty means $HAWK_OPT_LEVEL, else hawk.compile.toolchain.DEFAULT_OPT_LEVEL ("O3").

Return type:

Bundle

Parameters:
  • mode (str)

  • device_arch (str)

  • name (str | None)

  • derivative (Mapping[str, str] | None)

  • host_profile (str)

  • opt_level (str)