Skip to main content

KvikIO: High Performance File IO

Summary

KvikIO (pronounced "kuh-VICK-eye-oh", see here for pronunciation of kvik) is a Python and C++ library for high performance file IO. It provides C++ and Python bindings to cuFile, which enables GPUDirect Storage (GDS). KvikIO also works efficiently when GDS isn't available and can read/write both host and device data seamlessly.

Features

  • Object oriented API of cuFile with C++/Python exception handling.
  • A Python Zarr backend for reading and writing GPU data to file seamlessly.
  • Concurrent reads and writes using an internal thread pool.
  • Non-blocking API.
  • Transparently handles reads and writes to/from memory on both host and device.

Documentation

Examples

Python

import cupy
import kvikio

def main(path):
    a = cupy.arange(100)
    f = kvikio.CuFile(path, "w")
    # Write whole array to file
    f.write(a)
    f.close()

    b = cupy.empty_like(a)
    f = kvikio.CuFile(path, "r")
    # Read whole array from file
    f.read(b)
    assert all(a == b)
    f.close()

    # Use contexmanager
    c = cupy.empty_like(a)
    with kvikio.CuFile(path, "r") as f:
        f.read(c)
    assert all(a == c)

    # Non-blocking read
    d = cupy.empty_like(a)
    with kvikio.CuFile(path, "r") as f:
        future1 = f.pread(d[:50])
        future2 = f.pread(d[50:], file_offset=d[:50].nbytes)
        # Note: must wait for futures before exiting block
        # at which point the file is closed.
        future1.get()  # Wait for first read
        future2.get()  # Wait for second read
    assert all(a == d)


if __name__ == "__main__":
    main("/tmp/kvikio-hello-world-file")

C++

#include <cstddef>
#include <future>
#include <cuda_runtime.h>
#include <kvikio/file_handle.hpp>

int main()
{
  // Create two arrays `a` and `b`
  constexpr std::size_t size = 100;
  void *a = nullptr;
  void *b = nullptr;
  cudaMalloc(&a, size);
  cudaMalloc(&b, size);

  // Write `a` to file
  kvikio::FileHandle fw("test-file", "w");
  std::size_t written = fw.write(a, size);
  fw.close();

  // Read file into `b`
  kvikio::FileHandle fr("test-file", "r");
  std::size_t read = fr.read(b, size);
  fr.close();

  // Read file into `b` in parallel using 16 threads
  kvikio::default_thread_pool::reset(16);
  {
    // FileHandles have RAII semantics
    kvikio::FileHandle f("test-file", "r");
    std::future<std::size_t> future = f.pread(b_dev, sizeof(a), 0);  // Non-blocking
    std::size_t read = future.get(); // Blocking
    // Notice, `f` closes automatically on destruction.
  }
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

libkvikio_cu12-26.8.0-py3-none-manylinux_2_28_x86_64.whl (2.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

libkvikio_cu12-26.8.0-py3-none-manylinux_2_28_aarch64.whl (2.7 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

File details

Details for the file libkvikio_cu12-26.8.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libkvikio_cu12-26.8.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8a5ce1328bdcaaa6e724a48b0dd8de237877838e766774e78d9b02f19d2a7921
MD5 a4372760f7ae58226664e8f201fb7085
BLAKE2b-256 f704e4bacaad29f157aaeb1be8de038a404c5629996529895cb87c25567e2acf

See more details on using hashes here.

File details

Details for the file libkvikio_cu12-26.8.0-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for libkvikio_cu12-26.8.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ef8910448153979c50280bd3fd12b7aacfa9e23b69b3d12119c12398c71d906c
MD5 67f739d5d65b261bda680553e7662a33
BLAKE2b-256 7fa1f2ddd6009a107c03cfd2e8588646cc1fe5f63f51e08c0eb9258c224a8c3e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

26.8.0 This release

2 files

26.6.0

2 files

26.4.0

2 files

26.2.0

2 files

25.12.0

2 files

25.10.0

2 files

25.8.0

2 files

25.6.0

2 files

25.4.0

2 files

25.2.1

2 files

25.2.0

2 files

24.12.1

2 files

24.12.0

2 files

24.10.0

1 file

24.8.2

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page