mstar.communication.tensor_uuid#
Tensor uuids as integers.
A tensor uuid used to be str(uuid4()): globally unique by construction,
but 36 bytes on every wire frame, a fresh allocation per output tensor, and a
string hash on every store/lookup. The replacement is one u64:
(entity_index << 48) | counter
The entity prefix is what keeps it globally unique. A bare per-process counter
would not be: the receiving worker keys its own maps
(TensorStore.per_req_tensors, read_finished, _shm_files,
_arena_locs, uuid_to_shard_dim) by the sender’s uuid, so two
senders both minting 5 would collide and silently hand back the wrong tensor.
The production entities – worker_{rank} and the api-server data worker –
get stable indices, because those uuids cross process boundaries and two
peers have to agree. Anything else (tests, fixtures) is assigned from a
process-local pool above the production range: collision-free within a process,
not stable across them, which is fine because a synthetic entity never has a
peer in another process. Deliberately not a hash of the name – a hash can
collide, and a uuid collision corrupts data silently rather than failing.
Functions
|
|
|
Stable small integer for an entity that mints tensor uuids. |
|
Which entity minted |
Classes
|
Hands out this entity's tensor uuids. |
- class mstar.communication.tensor_uuid.TensorUuidMinter(entity_id)[source]#
Bases:
objectHands out this entity’s tensor uuids. Not thread-safe by design: the call sites are all on the worker’s main thread, and a lock here would sit on the output path of every forward pass.
- Parameters:
entity_id (str)