TECHNOLOGY

Query file-specific alignment before direct model-file reads

In this article
THE QUICK TAKE

Query supported file-specific direct-I/O alignment and validate buffer, offset and length; accepted reads can still require fallback-path verification.

A custom model loader switches to direct reads and receives invalid-argument errors on some files. Another filesystem appears to accept the same requests. O_DIRECT alignment is not one universal constant: memory address, file offset and transfer length have applicable file-specific requirements. Inspect supported alignment information and actual behavior before calling either result proof of faster uncached storage access.

Identify the real file path

Record the open flags, filesystem, file identity and kernel context used by the worker. A raw block-device experiment does not automatically describe a regular file on a layered filesystem. Also establish whether the loader or library requested direct I/O at all. A benchmark configuration cannot change the separate application’s file-opening behavior merely because both read the same checkpoint.

Request supported alignment information

Statx provides documented alignment fields when supported, and its returned mask indicates which requested information was supplied. An absent result must not be interpreted as a valid unconstrained alignment. Preserve the returned mask and values together. Filesystem and kernel support vary, so use a documented fallback qualification when the preferred query cannot establish the requirement for this file.

Check every request component

Validate buffer address, file offset and segment length against the applicable constraints. A correctly aligned allocation does not fix a misaligned subrange inside that buffer or a short final read request. Current documentation also distinguishes available read-specific alignment information. Keep the actual fields supported by the installed environment rather than substituting a familiar filesystem block-size label for every component.

Interpret acceptance cautiously

Linux documents that misaligned direct I/O can fail or fall back to buffered behavior depending on the filesystem and context. A successful read therefore does not alone prove the intended path. Preserve errors and relevant observations, and handle short successful reads under the read contract. Do not silently compare a buffered fallback against a verified direct path while describing both with one direct flag.

Verify the loader’s objective

Compare complete correct loading under the intended cache and concurrency conditions after establishing the API path. Direct I/O is a mechanism, not a guarantee of lower readiness time. Keep CPU preparation and device transfer visible. A useful conclusion states supported alignment, observed behavior and fallback policy; it does not promise a universal block size or infer model-serving improvement from one accepted low-level read.

Primary references

Linux File-Specific Direct I/O Alignment.

Linux Open File Descriptions and Directory Handles.

Linux read Result and Alignment Errors.

Related reading: Choose vLLM safetensors loading strategies for local disks and NFS; LLM loading: read-latency tails beyond one SSD speed.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles