[FEA] cuda.core: adopt nvFatbin for multi-arch fat binary assembly
@isVoid ya está trabajando en esto.
Desde el 23/7/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Summary
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:
https://github.com/NVIDIA/cuda-python/blob/c000331de6c37aa4565af74b001271ffcf6d5c99/cuda_core/tests/test_module.py#L144-L175
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
- bundling Tile IR (
nvFatbinAddTileIR) once #1322 / #1434 land
Underlying C APIs to cover
The entire libnvfatbin surface (pythonic names from
cuda.bindings.nvfatbin @ v13.3.1):
| C API | cuda.bindings.nvfatbin |
Purpose |
|---|---|---|
nvFatbinCreate |
create(options, options_count) |
new fatbin handle; options include -compress=<bool>, -compress-all, -compress-mode=<mode>, -host=<name>, -32/-64 |
nvFatbinAddCubin |
add_cubin(handle, code, size, arch, identifier) |
add SASS for one arch |
nvFatbinAddPTX |
add_ptx(handle, code, size, arch, identifier, options_cmd_line) |
add PTX (JIT-compatible entry) |
nvFatbinAddLTOIR |
add_ltoir(handle, code, size, arch, identifier, options_cmd_line) |
add LTO-IR |
nvFatbinAddReloc |
add_reloc(handle, code, size) |
add relocatable PTX from a host object |
nvFatbinAddTileIR |
add_tile_ir(handle, code, size, identifier, options_cmd_line) |
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.
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:
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/arch
options=...,
) # 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/archbe inferred when the input is anObjectCode(PTX carries its arch in
text; cubin would need parsing or an explicit argument)? - Options surface: a
FatbinOptionsdataclass mirroringProgramOptions/LinkerOptions
style, vs. plain kwargs? - Handle lifetime: route through the
_cppresource-handle registry like other native handles? - Version gating & diagnostics for older
libnvfatbin(noadd_tile_ir/add_index), per #337. - Is Option C in scope at all initially?
References
- nvFatbin docs: https://docs.nvidia.com/cuda/nvfatbin/index.html
- Found during the CUDA 12.8 → 13.3 bindings vs. cuda.core gap sweep (2026-07-14)
-- Leo's bot
- Lenguaje dominante
- Cython
- Estrellas
- 3.4k
- Forks
- 329
- Merge medio
- 1 d 21 h
- PR fusionados (30 d)
- 113
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de NVIDIA/cuda-python
-
bug cuda.core
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
NVIDIA/cuda-python#2886 · 1 comentario ·
-
triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
NVIDIA/cuda-python#2717 ·
-
triage
Dificultad 1/5 1-3 horas Aptitud para principiantes 90/100
NVIDIA/cuda-python#2712 ·
-
[BUG]: LocatedHeaderDir is mutable, so callers can poison the cached header-directory lookup Abiertotriage
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
NVIDIA/cuda-python#2646 · 1 reacción ·
-
cuda.core triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
NVIDIA/cuda-python#2435 · 1 comentario ·