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='', literal_table=False, embedded_profile=None, emit_form=None, linalg_form=None, wide_form=None, launch_bounds=None)[source]#
Build every kernel into
directoryand write ONEmanifest.jsonover them. Anemit_form/linalg_form/wide_form/launch_boundsleft unset is the ambienthawk.emit.policy.using()value (the default:"auto", no bound); an explicit argument wins.emit_formis how a product, dot, sum or norm is spelled (hawk.emit.policy):"auto"unrolls a site of at most 16 elements and writes a longer one as a loop,"static"unrolls every site,"rolled"writes every site as a loop, the fast-compile mode (the compiler does no per-element work).linalg_formis how per-lane linear algebra is worked:"auto"keeps one thread per matrix up ton = 32and uses a team of threads per matrix above it,"team"uses a team at every size,"thread"refuses a matrix above 32 by name (hawk.ir.team).wide_formis where a per-lane value wider than a thread’s registers lives:"auto"builds a kernel as a warp per lane when every target is a device and the kernel has a rule in that form (hawk.ir.lane, folds of 128 elements or more), else places the value (hawk.ir.wide) – a bundle with a host target keeps the placed form, as the host has no warp;"thread"keeps every value in the lane’s registers and local memory (the text before the pass);"team"asks for the warp form (device targets only).launch_bounds=(threads, blocks_per_sm)compiles every device kernel with__launch_bounds__(threads, blocks_per_sm)and recordslaunch.block = threadsin the sidecar, so a launch runs that block size (threadsa multiple of 32,threads * blocks_per_smat most 2048; the values do not change). 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
Bundlealways names a directory that genuinely holds the unit.derivativenames each derivative kernel’s primal, per kernel:{kernel_name: primal_name}, or leave it (None) to use ahawk.diff.vjp()/jvp()kernel’s own recorded primal. A primal outside this bundle is named by{kernel_name: (primal_name, primal_unit_digest)}via itsBundle.digest— needed when the primal and its scattering VJP can’t share one manifest.host_profilepicks the host code-gen profile (hawk.compile.toolchain.HOST_PROFILES):"native-vector-math"(default on x86-64 with a GCC host compiler, and on arm64) 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, elsehawk.compile.toolchain.default_host_profile().opt_levelpicks 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, elsehawk.compile.toolchain.DEFAULT_OPT_LEVEL("O3").literal_table(defaultFalse) makes the device source read itsdoubleliterals from one__constant__table per translation unit instead of as operand immediates: the same bits, fewer constant-move instructions on architectures that issue a move pair per literal (sm_90), unchanged on the others. Off, the device code is byte-identical to a build without the option. Afloat32build ignores it, and the host build is not affected."c"intargetsadds each kernel’s standalone MISRA C unit (hawk.embedded:<name>.c,<name>.h,<name>.embedded.json, audited and toolchain-checked) underembedded_profile(hawk.embedded.EmbeddedProfilewhenNone). It never enters the manifest or a sidecar: those describe the native targets only, and a unit built for("c",)alone writes neither (Bundle.manifestisNone).- Return type:
- Parameters:
mode (str)
device_arch (str)
name (str | None)
derivative (Mapping[str, str] | None)
host_profile (str)
opt_level (str)
literal_table (bool)
emit_form (str | None)
linalg_form (str | None)
wide_form (str | None)
launch_bounds (tuple[int, int] | None)