compressed_tensors.offload.cache.disk_utils
Functions:
-
disk_load_context–Hold safetensors file handles open for the duration of the block.
disk_load_context
Hold safetensors file handles open for the duration of the block.
safe_open parses a header describing every tensor in the file, so the cost
of opening is proportional to the number of tensors the file holds. Opening
once per tensor therefore makes a group of N reads from one shard O(N**2).
Reusing the handle makes the same group linear.
This is opt in. Outside the context, DiskCache.onload opens and closes per
read exactly as before, so nothing changes for callers that do not use it.
Nesting is allowed; handles are closed when the outermost context exits.
Example: with disk_load_context(): for subgraph in subgraphs: subgraph(batch)