coreweave / tensorizer

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

[3.0] Document `max_tensors` #140

Open bchess opened 2 weeks ago

bchess commented 2 weeks ago

Write docs on how/when to set the max_tensors arg

Copied from PR:

max_tensors

Because the new file schema must know ahead of time where to start writing tensor data, there must be a certain amount of pre-allocated space for the metadata and headers. Thus you must specify max_tensors to TensorSerializer.init If you plan on callling tensor_write() more than once. This does a wild-ass-guess estimate on a good amount of header space to reserve. In some cases, like really long tensor names, it could still be an underestimate. You will get a RuntimeError() if you call write_tensor() and there isn't enough pre-allocated space.

You do not need to set max_tensors if you just call tensor_write() once.