Download code/models/tt_transformers/tests/test_ccl_utils.py from DeAIafdeling/qwen38-flash-next: direct link, hf CLI and curl.
- Browser
- Download file 2.78 kB
-
https://huggingface.co/DeAIafdeling/qwen38-flash-next/resolve/main/code/models/tt_transformers/tests/test_ccl_utils.py
- Command line
-
hf download hf://DeAIafdeling/qwen38-flash-next/code/models/tt_transformers/tests/test_ccl_utils.py
-
curl -L -o test_ccl_utils.py https://huggingface.co/DeAIafdeling/qwen38-flash-next/resolve/main/code/models/tt_transformers/tests/test_ccl_utils.py
2.78 kB
| # SPDX-FileCopyrightText: © 2026 Tenstorrent USA, Inc. | |
| # | |
| # SPDX-License-Identifier: Apache-2.0 | |
| from types import SimpleNamespace | |
| import pytest | |
| import ttnn | |
| from models.common.modules import tt_ccl as common_tt_ccl | |
| from models.tt_transformers.tt import ccl as tt_transformers_ccl | |
| class FakeMeshDevice: | |
| def __init__(self, global_num_devices, local_device_ids, dram_grid_x=8): | |
| self._global_num_devices = global_num_devices | |
| self._local_device_ids = local_device_ids | |
| self._dram_grid_size = SimpleNamespace(x=dram_grid_x) | |
| def get_num_devices(self): | |
| return self._global_num_devices | |
| def get_device_ids(self): | |
| return list(self._local_device_ids) | |
| def dram_grid_size(self): | |
| return self._dram_grid_size | |
| class FakeMeshDeviceGetDeviceIdsRaises(FakeMeshDevice): | |
| def get_device_ids(self): | |
| raise RuntimeError("debug assert from get_device_ids") | |
| def test_get_num_links_uses_host_local_device_count_for_multihost_wormhole(monkeypatch, ccl_module): | |
| monkeypatch.setattr(ttnn, "get_arch_name", lambda: "wormhole_b0") | |
| mesh_device = FakeMeshDevice(global_num_devices=64, local_device_ids=range(32)) | |
| assert ccl_module.get_num_links(mesh_device, cluster_axis=0) == 4 | |
| assert ccl_module.get_num_links(mesh_device, cluster_axis=1) == 4 | |
| assert ccl_module.get_num_links(mesh_device) == 4 | |
| def test_get_num_links_rejects_invalid_cluster_axis(monkeypatch, ccl_module): | |
| monkeypatch.setattr(ttnn, "get_arch_name", lambda: "wormhole_b0") | |
| mesh_device = FakeMeshDevice(global_num_devices=8, local_device_ids=range(8)) | |
| with pytest.raises(ValueError, match="Unsupported cluster_axis: 2"): | |
| ccl_module.get_num_links(mesh_device, cluster_axis=2) | |
| def test_get_num_links_requires_local_devices(monkeypatch, ccl_module): | |
| monkeypatch.setattr(ttnn, "get_arch_name", lambda: "wormhole_b0") | |
| mesh_device = FakeMeshDevice(global_num_devices=64, local_device_ids=[]) | |
| with pytest.raises(ValueError, match="requires at least one host-local device"): | |
| ccl_module.get_num_links(mesh_device) | |
| def test_get_num_links_normalizes_get_device_ids_failures(monkeypatch, ccl_module): | |
| monkeypatch.setattr(ttnn, "get_arch_name", lambda: "wormhole_b0") | |
| mesh_device = FakeMeshDeviceGetDeviceIdsRaises(global_num_devices=64, local_device_ids=[]) | |
| with pytest.raises(ValueError, match="requires at least one host-local device"): | |
| ccl_module.get_num_links(mesh_device) | |