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

counter_of(uuid)

entity_index(entity_id)

Stable small integer for an entity that mints tensor uuids.

owner_index(uuid)

Which entity minted uuid — for debugging and assertions.

Classes

TensorUuidMinter(entity_id)

Hands out this entity's tensor uuids.

class mstar.communication.tensor_uuid.TensorUuidMinter(entity_id)[source]#

Bases: object

Hands 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)

mint()[source]#
Return type:

int

mstar.communication.tensor_uuid.counter_of(uuid)[source]#
Parameters:

uuid (int)

Return type:

int

mstar.communication.tensor_uuid.entity_index(entity_id)[source]#

Stable small integer for an entity that mints tensor uuids.

Parameters:

entity_id (str)

Return type:

int

mstar.communication.tensor_uuid.owner_index(uuid)[source]#

Which entity minted uuid — for debugging and assertions.

Parameters:

uuid (int)

Return type:

int