coreweave / tensorizer

Module, Model, and Tensor Serialization/Deserialization
MIT License
153 stars 24 forks source link

[3.0] Introduce a way to prioritize work in the ThreadPoolExecutor #162

Open bchess opened 2 weeks ago

bchess commented 2 weeks ago

Each stage (hash, encryption) submits a ton of work to the shared pool executor, one task per tensor. And because the Executor executes these tasks FIFO, we are unnecessarily delaying the ability to write a single tensor because it's subsequent chain-of-tasks are stuck behind all of the other processing of all of the other task items.

Create a variant of a ThreadPoolExecutor that uses a priority queue instead of a FIFO queue, and assign priorities per tensor such that all tensor 1 tasks are preferred as a group over all tensor 2 tasks, etc.