mstar.utils.host_copy#
Large host copies split over threads of their own.
The API server sizes torch’s intra-op pool for its small per-request ops
(entrypoint.default_preprocess_threads), and one numpy memcpy runs on one
core. Most of a large copy into a fresh allocation is the destination’s
first-touch page faults, which a copy split into slices takes in parallel too.
numpy releases the GIL while it copies, so slices on a pool of their own run in
parallel without resizing the intra-op pool.
Classes
|
Copies flat uint8 host arrays into fresh torch allocations, a large one in slices on |
- class mstar.utils.host_copy.HostCopier(workers, min_slice_bytes=None)[source]#
Bases:
objectCopies flat uint8 host arrays into fresh torch allocations, a large one in slices on
workersthreads. The caller views and reshapes the bytes.The destination is torch’s, never
np.empty: numpy madvises large arrays for huge pages, and under THPdefrag=madvisetheir first-touch faults can stall in compaction.