
    h                     \    S SK r S SKJs  Jr  S SKJr  S SKJr  S\ R                  S\
4S jrg)    N)DTensor)Float8TrainingTensortensorreturnc                     [        U [        5      (       a  g[        U [        5      (       a  [        U R                  5      $ [        U [
        R                  5      (       a  [        U R                  5      $ g)z`
Check if the tensor is already casted to fp8, works if the local
tensor is wrapped in DTensor.
TF)
isinstancer   r   tensor_already_casted_to_fp8_local_tensorfuncolAsyncCollectiveTensorelem)r   s    Z/home/james-whalen/.local/lib/python3.13/site-packages/torchao/float8/distributed_utils.pyr	   r	      sX    
 &.//	FG	$	$+F,@,@AA	FF88	9	9+FKK88    )torch)torch.distributed._functional_collectivesdistributed_functional_collectivesr   torch.distributed._tensorr   %torchao.float8.float8_training_tensorr   Tensorboolr	    r   r   <module>r      s-     : : - F $ r   