Skip to content

vllm.distributed.kv_transfer.kv_connector.v1.hf3fs.hf3fs_client

Classes:

Hf3fsClient

Methods:

  • __init__ –

    Initialize the HF3FS client with hf3fs_fuse.

  • batch_read –

    Read data from the file at specified offsets into tensors.

  • batch_write –

    Write data from tensors to the file at specified offsets.

  • close –

    Close the client and clean up resources.

  • flush –

    Flush any pending writes to disk.

  • get_size –

    Get the total size of the storage file.

__init__(path, size, bytes_per_page, entries, device=None)

Initialize the HF3FS client with hf3fs_fuse.

Parameters:

  • path

    (str) –

    Path to the file used for storage

  • size

    (int) –

    Total size of the storage file in bytes

  • bytes_per_page

    (int) –

    Size of each page in bytes

  • entries

    (int) –

    Maximum number of concurrent operations

  • device

    (device | None, default: None ) –

    Accelerator device the copy stream is created on (defaults to the current device)

_byte_view(t) staticmethod

Flat uint8 view over a contiguous tensor's storage.

_read_shm(tensors)

Copy packed pages from the read shm into tensors.

shm -> pinned host buffer -> device. The pinned -> device copies are issued asynchronously on self.stream, but the method blocks until they complete. The sync is required: the H2D copies must finish before rlock is released and the next batch_read reuses r_pinned/shm_r. self.stream does not wait on other streams: the caller must ensure no pending device work still touches tensors.

_release_resources()

Release all acquired resources safely.

_write_shm(tensors, event)

Pack tensors into the write shm once event has completed.

device -> pinned host buffer -> shm. The device -> pinned copies are issued asynchronously on self.stream, but the method blocks until they complete. The sync is required: the D2H copies must finish before w_pinned is packed into shm.

batch_read(offsets, tensors)

Read data from the file at specified offsets into tensors.

Parameters:

  • offsets

    (list[int]) –

    List of byte offsets to read from

  • tensors

    (list[Tensor]) –

    List of tensors to read data into

Returns:

  • list[int] –

    List of operation results (0 for success, non-zero for error)

batch_write(offsets, tensors, event)

Write data from tensors to the file at specified offsets.

Parameters:

  • offsets

    (list[int]) –

    List of byte offsets to write to

  • tensors

    (list[Tensor]) –

    List of tensors containing data to write

  • event

    (Event) –

    Accelerator event to wait on before reading the tensors

Returns:

  • list[int] –

    List of operation results (0 for success, non-zero for error)

close()

Close the client and clean up resources.

flush()

Flush any pending writes to disk.

get_size()

Get the total size of the storage file.

Returns:

  • int –

    Size of the file in bytes

_load_cuda_shm_ops() cached

JIT-build the CUDA shm copy extension (utils/hf3fs_utils.cpp).

CUDA only. Built on first use rather than at import time so that importing this module works on every platform.