You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cuda.bindings.nvfatbin (available since cuda-bindings 12.9.x) is not used anywhere in cuda.core
product code today — it only appears as a test helper that builds a two-arch fatbin to exercise ObjectCode.from_fatbin:
cuda.core covers the consume side of fat binaries
(ObjectCode.from_fatbin)
but has no produce side: to target several architectures, users must juggle N per-arch ObjectCodes or shell out to the fatbinary CLI. nvFatbin closes this gap in-process.
Use cases:
compile per arch (CUBIN/PTX/LTO-IR) and ship one artifact; PTX/LTO-IR entries keep JIT
forward-compatibility on newer GPUs
AOT kernel caches / packaging: one fatbin per kernel suite instead of per-arch files
add Tile IR (documented since CUDA 13.1; pairs with #1434)
nvFatbinAddIndex
add_index(handle, code, size, identifier)
new in cuda-bindings 13.3.x (not yet in the public nvFatbin docs)
nvFatbinSize / nvFatbinGet
size(handle) / get(handle, buffer)
serialize the finished fatbin
nvFatbinDestroy
destroy(handle)
release the handle
nvFatbinVersion / nvFatbinGetErrorString
version() / get_error_string(result)
introspection / error text
The bindings load libnvfatbin lazily, so each entry point also requires a new-enough runtime
library — option/entry-point support must be version-gated with actionable error messages,
in the spirit of #337.
The sketch below is a starting point only, not a settled design. API shape, names, and
scope should all be reviewed in the cuda.core design meeting before implementation.
Option A — one-shot constructor, no intermediate handle exposed:
code: ObjectCode=ObjectCode.from_parts( # all names TBD
[objcode_sm100a, # ObjectCode in, kind/arch from metadata...
(ptx, "ptx", "sm_120")], # ...or raw bytes + explicit kind/archoptions=...,
) # ObjectCode with code_type="fatbin"
Option B — a small builder object (fb = FatbinBundler(...); fb.add(...); fb.finalize()),
only if Option A's argument shape gets unwieldy — cuda.core uses the builder pattern sparingly
(CUDA graph construction is the only case today).
Option C — Program-level sugar that compiles for multiple archs and bundles the results
(e.g. Program.compile("fatbin", archs=[...])) — likely a follow-up on top of A/B rather than
initial scope, since it multiplies compilation work behind one call.
Open questions for the meeting:
Can kind/arch be inferred when the input is an ObjectCode (PTX carries its arch in
text; cubin would need parsing or an explicit argument)?
Options surface: a FatbinOptions dataclass mirroring ProgramOptions/LinkerOptions
style, vs. plain kwargs?
Handle lifetime: route through the _cpp resource-handle registry like other native handles?
Summary
cuda.bindings.nvfatbin(available since cuda-bindings 12.9.x) is not used anywhere incuda.coreproduct code today — it only appears as a test helper that builds a two-arch fatbin to exercise
ObjectCode.from_fatbin:cuda-python/cuda_core/tests/test_module.py
Lines 144 to 175 in c000331
cuda.corecovers the consume side of fat binaries(
ObjectCode.from_fatbin)but has no produce side: to target several architectures, users must juggle N per-arch
ObjectCodes or shell out to thefatbinaryCLI. nvFatbin closes this gap in-process.Use cases:
forward-compatibility on newer GPUs
nvFatbinAddTileIR) oncecuda.core.Program: Support Tile IR #1322 /cuda.core.ObjectCode: Support Tile IR #1434 landUnderlying C APIs to cover
The entire libnvfatbin surface (pythonic names from
cuda.bindings.nvfatbin@ v13.3.1):cuda.bindings.nvfatbinnvFatbinCreatecreate(options, options_count)-compress=<bool>,-compress-all,-compress-mode=<mode>,-host=<name>,-32/-64nvFatbinAddCubinadd_cubin(handle, code, size, arch, identifier)nvFatbinAddPTXadd_ptx(handle, code, size, arch, identifier, options_cmd_line)nvFatbinAddLTOIRadd_ltoir(handle, code, size, arch, identifier, options_cmd_line)nvFatbinAddRelocadd_reloc(handle, code, size)nvFatbinAddTileIRadd_tile_ir(handle, code, size, identifier, options_cmd_line)nvFatbinAddIndexadd_index(handle, code, size, identifier)nvFatbinSize/nvFatbinGetsize(handle)/get(handle, buffer)nvFatbinDestroydestroy(handle)nvFatbinVersion/nvFatbinGetErrorStringversion()/get_error_string(result)The bindings load
libnvfatbinlazily, so each entry point also requires a new-enough runtimelibrary — option/entry-point support must be version-gated with actionable error messages,
in the spirit of #337.
Design sketch (draft — needs design-meeting review)
Important
The sketch below is a starting point only, not a settled design. API shape, names, and
scope should all be reviewed in the cuda.core design meeting before implementation.
Option A — one-shot constructor, no intermediate handle exposed:
Option B — a small builder object (
fb = FatbinBundler(...);fb.add(...);fb.finalize()),only if Option A's argument shape gets unwieldy — cuda.core uses the builder pattern sparingly
(CUDA graph construction is the only case today).
Option C —
Program-level sugar that compiles for multiple archs and bundles the results(e.g.
Program.compile("fatbin", archs=[...])) — likely a follow-up on top of A/B rather thaninitial scope, since it multiplies compilation work behind one call.
Open questions for the meeting:
kind/archbe inferred when the input is anObjectCode(PTX carries its arch intext; cubin would need parsing or an explicit argument)?
FatbinOptionsdataclass mirroringProgramOptions/LinkerOptionsstyle, vs. plain kwargs?
_cppresource-handle registry like other native handles?libnvfatbin(noadd_tile_ir/add_index), per Add descriptive exception handling to linker and program options which are not supported on a CTK version basis + handle in tests #337.References
-- Leo's bot