etha.tensor_bus.commands
========================

.. py:module:: etha.tensor_bus.commands

.. autoapi-nested-parse::

   Command (Host to Tensor Bus) Definitions and State Structures.



Attributes
----------

.. autoapisummary::

   etha.tensor_bus.commands.Message


Classes
-------

.. autoapisummary::

   etha.tensor_bus.commands.BaseCommand
   etha.tensor_bus.commands.CleanupBatch
   etha.tensor_bus.commands.InitPair
   etha.tensor_bus.commands.QueryStatus
   etha.tensor_bus.commands.RegisterTensors
   etha.tensor_bus.commands.Transfer


Module Contents
---------------

.. py:class:: BaseCommand

   Bases: :py:obj:`msgspec.Struct`


   Base class for all Tensor Bus commands.

   Features:
   - Auto-tagging: Uses class name as type tag
   - Common timestamp field for all commands
   - Optional semaphore for completion notification


   .. py:attribute:: semaphore_name
      :type:  str | None
      :value: None



   .. py:attribute:: timestamp
      :type:  float | None
      :value: None



.. py:class:: CleanupBatch

   Bases: :py:obj:`BaseCommand`


   Cleanup a batch's state in the agent.


   .. py:attribute:: batch_id
      :type:  str


.. py:class:: InitPair

   Bases: :py:obj:`BaseCommand`


   Init a Device Mesh + Placement to Device Mesh + Placement pair.

   :param pair_name: Unique identifier for this pair (e.g., "obs", "action")
   :param local_name: Name of local peer (e.g., "inference", "training")
   :param expected_world_size: Number of ranks for local peer
   :param remote_name: Name of remote peer (explicit pairing)
   :param mesh_shape_payload: Serialized mesh shape tuple as memoryview
   :param placements_payload: Serialized placements tuple as memoryview


   .. py:attribute:: expected_world_size
      :type:  int


   .. py:attribute:: local_name
      :type:  str


   .. py:attribute:: mesh_shape_payload
      :type:  memoryview | None
      :value: None



   .. py:attribute:: pair_name
      :type:  str


   .. py:attribute:: placements_payload
      :type:  memoryview | None
      :value: None



   .. py:attribute:: remote_name
      :type:  str


.. py:class:: QueryStatus

   Bases: :py:obj:`BaseCommand`


   Query status for a batch.


   .. py:attribute:: batch_id
      :type:  str


   .. py:attribute:: state_name
      :type:  str


.. py:class:: RegisterTensors

   Bases: :py:obj:`BaseCommand`


   Register multiple tensors for zero-copy sharing between processes.

   Creates a new batch with a unique batch_id. Multiple tensors can be
   registered across different pairs in a single batch, enabling efficient
   cross-pair execution via flattened chunks/buckets.


   .. py:attribute:: batch_id
      :type:  str


   .. py:attribute:: bucket_size
      :type:  int | None
      :value: None



   .. py:attribute:: tensors
      :type:  list[tuple[str, memoryview]]


.. py:class:: Transfer

   Bases: :py:obj:`BaseCommand`


   Transfer tensor command for a specific batch.


   .. py:attribute:: batch_id
      :type:  str


   .. py:attribute:: transfer_type
      :type:  Literal['send', 'recv']


.. py:data:: Message

