Skip to content

Add cufile bindings #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
48074ce
Draft: Add cufile bindings(Not building currently)
sourabgupta3 Jun 6, 2025
5fc09cc
make the project buildable
leofang Jun 6, 2025
01990c0
try to build cufile in the CI
leofang Jun 6, 2025
5fed951
fix multiple issues at once
leofang Jun 18, 2025
338f3df
regenerate with latest codegen
leofang Jun 22, 2025
70837af
skip fetching cufile on windows
leofang Jun 22, 2025
71f6fbb
skip building cufile bindings on Windows
leofang Jun 22, 2025
571f60b
Merge branch 'main' into sg_cufile_bindings
leofang Jun 22, 2025
77dbde4
fix
leofang Jun 22, 2025
a3d62f2
glob pattern needs to be expanded manually
leofang Jun 22, 2025
8746ee8
after expanding glob we expect a certain structure
leofang Jun 23, 2025
5ff2f4e
clean up extern/cimport; fix redefinition warning
leofang Jun 23, 2025
c6f3c50
Update tests to include handle/buf register and sync read/write
sourabgupta3 Jun 25, 2025
a85ede2
enhance error msg
leofang Jun 26, 2025
5ac262f
WAR: patch the wrong dtype for now
leofang Jun 26, 2025
ea2b045
ensure we can get size of nested POD members
leofang Jun 27, 2025
a9214d6
Merge branch 'main' into sg_cufile_bindings
leofang Jun 27, 2025
e37ca88
Add Async Tests
sourabgupta3 Jun 26, 2025
bddca47
Merge conflict
sourabgupta3 Jun 30, 2025
6cea3a1
Add batch tests
sourabgupta3 Jun 30, 2025
31213d2
Add get/set tests
sourabgupta3 Jun 30, 2025
ed165ad
add docs
leofang Jul 2, 2025
e159519
Pre-commit fixes
sourabgupta3 Jul 2, 2025
03970b8
add cufile wheel dependency
leofang Jul 2, 2025
fac4100
fix fetch_ctk failure
leofang Jul 2, 2025
a734679
Add skipif checks
sourabgupta3 Jul 2, 2025
70c4358
cufile wheel only available on linux
leofang Jul 2, 2025
5948758
Review Comments
sourabgupta3 Jul 2, 2025
824fe0d
fix cuFile API ref not rendered
leofang Jul 3, 2025
fbb4cdb
pre commit fixes
sourabgupta3 Jul 2, 2025
dae5893
point to cufile C docs
leofang Jul 3, 2025
f469124
Merge branch 'main' into sg_cufile_bindings
leofang Jul 3, 2025
053a62b
skip tests on windows
leofang Jul 3, 2025
20dfdc2
fix api refs
leofang Jul 3, 2025
eaa8d6b
fix linter
leofang Jul 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions .github/actions/fetch_ctk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,37 @@ inputs:
description: "A list of the CTK components to install as a comma-separated list. e.g. 'cuda_nvcc,cuda_nvrtc,cuda_cudart'"
required: false
type: string
default: "cuda_nvcc,cuda_cudart,cuda_nvrtc,cuda_profiler_api,cuda_cccl,libnvjitlink"
default: "cuda_nvcc,cuda_cudart,cuda_nvrtc,cuda_profiler_api,cuda_cccl,libnvjitlink,libcufile"

runs:
using: composite
steps:
- name: Set up CTK cache variable
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
HASH=$(echo -n "${{ inputs.cuda-components }}" | sha256sum | awk '{print $1}')
# Pre-process the component list to ensure hash uniqueness
CTK_CACHE_COMPONENTS=${{ inputs.cuda-components }}
# Conditionally strip out libnvjitlink for CUDA versions < 12
CUDA_MAJOR_VER="$(cut -d '.' -f 1 <<< ${{ inputs.cuda-version }})"
if [[ "$CUDA_MAJOR_VER" -lt 12 ]]; then
CTK_CACHE_COMPONENTS="${CTK_CACHE_COMPONENTS//libnvjitlink/}"
fi
# Conditionally strip out libcufile since it does not support Windows
if [[ "${{ inputs.host-platform }}" == win-* ]]; then
CTK_CACHE_COMPONENTS="${CTK_CACHE_COMPONENTS//libcufile/}"
fi
# Conditionally strip out libcufile for CUDA versions < 12.2.0 + aarch64 (redist not available)
CUDA_MINOR_VER="$(cut -d '.' -f 2 <<< ${{ inputs.cuda-version }})"
if [[ ("$CUDA_MAJOR_VER" -lt 12 || "$CUDA_MINOR_VER" -lt 2) && "${{ inputs.host-platform }}" == "linux-aarch64" ]]; then
CTK_CACHE_COMPONENTS="${CTK_CACHE_COMPONENTS//libcufile/}"
fi
# Cleanup stray commas after removing components
CTK_CACHE_COMPONENTS="${CTK_CACHE_COMPONENTS//,,/,}"

HASH=$(echo -n "${CTK_CACHE_COMPONENTS}" | sha256sum | awk '{print $1}')
echo "CTK_CACHE_KEY=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}-$HASH" >> $GITHUB_ENV
echo "CTK_CACHE_FILENAME=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}-$HASH.tar.gz" >> $GITHUB_ENV
echo "CTK_CACHE_COMPONENTS=${{ inputs.cuda-components }}" >> $GITHUB_ENV
echo "CTK_CACHE_COMPONENTS=${CTK_CACHE_COMPONENTS}" >> $GITHUB_ENV

- name: Install dependencies
uses: ./.github/actions/install_unix_deps
Expand Down Expand Up @@ -94,12 +113,6 @@ runs:
rm $CTK_COMPONENT_COMPONENT_FILENAME
}

# Conditionally strip out libnvjitlink for CUDA versions < 12
if [[ "$(cut -d '.' -f 1 <<< ${{ inputs.cuda-version }})" -lt 12 ]]; then
CTK_CACHE_COMPONENTS="${CTK_CACHE_COMPONENTS//libnvjitlink/}"
fi
# Cleanup stray commas after removing components
CTK_CACHE_COMPONENTS="${CTK_CACHE_COMPONENTS//,,/,}"
# Get headers and shared libraries in place
for item in $(echo $CTK_CACHE_COMPONENTS | tr ',' ' '); do
populate_cuda_path "$item"
Expand Down
43 changes: 43 additions & 0 deletions cuda_bindings/cuda/bindings/_internal/cufile.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
#
# This code was automatically generated with version 12.9.0. Do not modify it directly.

from ..cycufile cimport *


###############################################################################
# Wrapper functions
###############################################################################

cdef CUfileError_t _cuFileHandleRegister(CUfileHandle_t* fh, CUfileDescr_t* descr) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef void _cuFileHandleDeregister(CUfileHandle_t fh) except* nogil
cdef CUfileError_t _cuFileBufRegister(const void* bufPtr_base, size_t length, int flags) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileBufDeregister(const void* bufPtr_base) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef ssize_t _cuFileRead(CUfileHandle_t fh, void* bufPtr_base, size_t size, off_t file_offset, off_t bufPtr_offset) except* nogil
cdef ssize_t _cuFileWrite(CUfileHandle_t fh, const void* bufPtr_base, size_t size, off_t file_offset, off_t bufPtr_offset) except* nogil
cdef CUfileError_t _cuFileDriverOpen() except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileDriverClose_v2() except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef long _cuFileUseCount() except* nogil
cdef CUfileError_t _cuFileDriverGetProperties(CUfileDrvProps_t* props) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileDriverSetPollMode(cpp_bool poll, size_t poll_threshold_size) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileDriverSetMaxDirectIOSize(size_t max_direct_io_size) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileDriverSetMaxCacheSize(size_t max_cache_size) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileDriverSetMaxPinnedMemSize(size_t max_pinned_size) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileBatchIOSetUp(CUfileBatchHandle_t* batch_idp, unsigned nr) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileBatchIOSubmit(CUfileBatchHandle_t batch_idp, unsigned nr, CUfileIOParams_t* iocbp, unsigned int flags) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileBatchIOGetStatus(CUfileBatchHandle_t batch_idp, unsigned min_nr, unsigned* nr, CUfileIOEvents_t* iocbp, timespec* timeout) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileBatchIOCancel(CUfileBatchHandle_t batch_idp) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef void _cuFileBatchIODestroy(CUfileBatchHandle_t batch_idp) except* nogil
cdef CUfileError_t _cuFileReadAsync(CUfileHandle_t fh, void* bufPtr_base, size_t* size_p, off_t* file_offset_p, off_t* bufPtr_offset_p, ssize_t* bytes_read_p, CUstream stream) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileWriteAsync(CUfileHandle_t fh, void* bufPtr_base, size_t* size_p, off_t* file_offset_p, off_t* bufPtr_offset_p, ssize_t* bytes_written_p, CUstream stream) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileStreamRegister(CUstream stream, unsigned flags) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileStreamDeregister(CUstream stream) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileGetVersion(int* version) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileGetParameterSizeT(CUFileSizeTConfigParameter_t param, size_t* value) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileGetParameterBool(CUFileBoolConfigParameter_t param, cpp_bool* value) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileGetParameterString(CUFileStringConfigParameter_t param, char* desc_str, int len) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileSetParameterSizeT(CUFileSizeTConfigParameter_t param, size_t value) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileSetParameterBool(CUFileBoolConfigParameter_t param, cpp_bool value) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
cdef CUfileError_t _cuFileSetParameterString(CUFileStringConfigParameter_t param, const char* desc_str) except?<CUfileError_t>CUFILE_LOADING_ERROR nogil
Loading
Loading