Skip to navigation

nemo_automodel.components.optim.nvfp4_adam_cuda

View as MarkdownOpen in Claude

Source text of the Adam step of NVFP4 expert weights (CUDA) and its torch binding.

nvfp4_resident_adam hands these strings to torch.utils.cpp_extension.load_inline as cpp_sources = [HEADER, BINDING] and cuda_sources = [HEADER, KERNEL], so the wheel ships Python files only. The header is inlined into both translation units (there is no file to #include), which is why it carries no #pragma once.

Both kernels return the bits of the Transformer Engine kernel they stand in for. The Adam arithmetic is written as explicit PTX operations for that reason: Transformer Engine builds its Adam kernel with --use_fast_math, and the result depends on which operations the compiler then emits.

Module Contents

Data

BINDING

HEADER

KERNEL

_LICENSE

API

nemo_automodel.components.optim.nvfp4_adam_cuda.BINDING = _LICENSE + '\n#include <torch/extension.h>\n#include <ATen/cuda/CUDAContext.h>\n...
nemo_automodel.components.optim.nvfp4_adam_cuda.HEADER = _LICENSE + '\n#include <cstdint>\n#include <cuda_runtime.h>\n\n// Tensors of one...
nemo_automodel.components.optim.nvfp4_adam_cuda.KERNEL = _LICENSE + '\n// Adam on FP32 master weights with FP32 moments and BF16 gradient...
nemo_automodel.components.optim.nvfp4_adam_cuda._LICENSE = '// Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.\n// Licensed un...