def download_thread_target(queue: Optional[queue.Queue]):
            """Thread target to wait for the model to be downloaded."""
            device = get_device(None)

            status = 0

            done_tensor = device.tensor_to_device(
                torch.tensor(
                    [status],
                    dtype=torch.int,
                ),
            )

            dist.broadcast(done_tensor, src=0)
            all_done = done_tensor.item()

            while not all_done:
                # On rank 0, queue exists, and the presence of an item indicates completion
                # On all other ranks, the queue object does not exist
                if queue is not None and not queue.empty():
                    status = 1
                done_tensor.fill_(status)
                dist.broadcast(done_tensor, src=0)
                all_done = done_tensor.item()
                time.sleep(1)
Thread target to wait for the model to be downloaded.
llmfoundry/models/hf/hf_base.py