Skip to content

Commit aa31dc7

Browse files
author
Andrey Cheptsov
committed
Preserve Tenstorrent shim compatibility
1 parent 56fcf36 commit aa31dc7

4 files changed

Lines changed: 56 additions & 8 deletions

File tree

mkdocs/docs/examples/accelerators/tenstorrent.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,17 @@ If you run it via `dstack apply`, it will output the URL to access it via your d
201201

202202
`resources.gpu` uses the usual `name:count` format. For Tenstorrent, `count`
203203
is the number of devices reported from the TT-SMI topology. On Galaxy systems,
204-
this corresponds to chips. For PCIe cards and workstations, use the card count
205-
shown in the examples below.
204+
this corresponds to chips. On PCIe systems, this is usually the card count, but
205+
dual-chip cards can also be reported as per-chip devices.
206206

207207
```yaml
208208
resources:
209209
gpu: tt-galaxy-wh:32 # Galaxy Wormhole, 32 chips
210210
# gpu: tt-galaxy-bh:32 # Galaxy Blackhole, 32 chips
211211
# gpu: n300:4 # TT-LoudBox or TT-QuietBox Wormhole, 4 n300 cards
212212
# gpu: p150:4 # TT-QuietBox Blackhole, 4 p150 cards
213-
# gpu: p300:2 # TT-QuietBox 2 Blackhole, 2 p300 cards
213+
# gpu: p300:64GB:2 # TT-QuietBox 2 Blackhole, 2 p300 cards
214+
# gpu: p300:32GB:4 # TT-QuietBox 2 Blackhole, if exposed per chip
214215
```
215216

216217
Use `tt:<count>` only when the workload can run on any Tenstorrent device type.

runner/internal/shim/host/gpu.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,13 @@ func splitTtBoardType(boardType string) (name string, suffix string) {
248248
}
249249

250250
func ttBoardVramMib(name string) int {
251-
switch name {
252-
case "n150", "n300", "tt-galaxy-wh":
251+
switch {
252+
case strings.HasPrefix(name, "n150"),
253+
strings.HasPrefix(name, "n300"),
254+
strings.HasPrefix(name, "tt-galaxy-wh"):
253255
return 12 * 1024
256+
}
257+
switch name {
254258
case "p100a":
255259
return 28 * 1024
256260
case "p150", "p300", "tt-galaxy-bh":
@@ -317,7 +321,7 @@ func getGpusFromTtSmiSnapshot(snapshot *ttSmiSnapshot) []GpuInfo {
317321
// and add memory to the first "L" device we find with that board_id
318322
for _, key := range gpuKeys {
319323
gpu := gpuMap[key]
320-
if gpu.ID == boardID && gpu.Name == name {
324+
if gpu.ID == boardID && (gpu.Name == name || !isTtBlackholeBoard(name)) {
321325
// Add memory to the "L" device
322326
gpu.Vram += ttBoardVramMib(name)
323327
break // Only add to the first matching "L" device
@@ -358,7 +362,7 @@ func getGpusFromTtSmiSnapshot(snapshot *ttSmiSnapshot) []GpuInfo {
358362
existingGpu := false
359363
for _, key := range gpuKeys {
360364
gpu := gpuMap[key]
361-
if gpu.ID == boardID && gpu.Name == name {
365+
if gpu.ID == boardID {
362366
gpu.Vram += baseVram
363367
existingGpu = true
364368
break

runner/internal/shim/host/gpu_test.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,28 @@ func TestGetGpusFromTtSmiSnapshotMultipleDevices(t *testing.T) {
239239
}
240240
}
241241

242+
func TestGetGpusFromTtSmiSnapshotWormholePrefixMemoryCompatibility(t *testing.T) {
243+
snapshot := &ttSmiSnapshot{
244+
DeviceInfo: []ttDeviceInfo{
245+
{BoardInfo: ttBoardInfo{BoardType: "n150-custom L", BoardID: "100018000000001"}},
246+
{BoardInfo: ttBoardInfo{BoardType: "n300-custom L", BoardID: "100014000000001"}},
247+
{BoardInfo: ttBoardInfo{BoardType: "n300-custom R", BoardID: "100014000000001"}},
248+
{BoardInfo: ttBoardInfo{BoardType: "tt-galaxy-wh-custom L", BoardID: "100035000000001"}},
249+
},
250+
}
251+
252+
gpus := getGpusFromTtSmiSnapshot(snapshot)
253+
254+
expected := []GpuInfo{
255+
{Vendor: gpu.GpuVendorTenstorrent, Name: "n150-custom", Vram: 12 * 1024, ID: "100018000000001", Index: "0"},
256+
{Vendor: gpu.GpuVendorTenstorrent, Name: "n300-custom", Vram: 24 * 1024, ID: "100014000000001", Index: "1"},
257+
{Vendor: gpu.GpuVendorTenstorrent, Name: "tt-galaxy-wh-custom", Vram: 12 * 1024, ID: "100035000000001", Index: "2"},
258+
}
259+
if !reflect.DeepEqual(gpus, expected) {
260+
t.Errorf("getGpusFromTtSmiSnapshot() = %v, want %v", gpus, expected)
261+
}
262+
}
263+
242264
func TestGetGpusFromTtSmiSnapshotGalaxy(t *testing.T) {
243265
data, err := loadTestData("tenstorrent/galaxy.json")
244266
if err != nil {
@@ -329,7 +351,8 @@ func TestGetGpusFromTtSmiSnapshotBlackholeRevisions(t *testing.T) {
329351
}
330352

331353
func TestGetGpusFromTtSmiSnapshotBlackholeSourceFixtures(t *testing.T) {
332-
// Derived from TT-Metal UMD Blackhole board descriptors.
354+
// Synthetic tt-smi snapshot derived from TT-SMI board name mappings and
355+
// TT-Metal UMD Blackhole board descriptors.
333356
data, err := loadTestData("tenstorrent/blackhole_boards.json")
334357
if err != nil {
335358
t.Fatalf("Failed to load test data: %v", err)
@@ -355,6 +378,7 @@ func TestGetGpusFromTtSmiSnapshotBlackholeSourceFixtures(t *testing.T) {
355378

356379
func TestGetGpusFromTtSmiSnapshotBlackholeEightP150(t *testing.T) {
357380
// Derived from TT-Metal UMD blackhole_8xP150 cluster descriptor.
381+
// The p150b name follows TT-SMI's board ID to board type mapping.
358382
data, err := loadTestData("tenstorrent/blackhole_8xp150.json")
359383
if err != nil {
360384
t.Fatalf("Failed to load test data: %v", err)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Tenstorrent fixtures
2+
3+
The Wormhole fixtures are captured `tt-smi -s` snapshots used by the existing
4+
Tenstorrent tests.
5+
6+
The Blackhole fixtures are source-derived compatibility fixtures:
7+
8+
- `blackhole_boards.json` covers `tt-smi` Blackhole board names and P300
9+
same-board dual-MMIO behavior. Board names are based on
10+
`tt_smi/utils.py::get_board_type` and UMD board type mappings.
11+
- `blackhole_8xp150.json` is derived from UMD's
12+
`blackhole_8xP150.yaml` cluster descriptor. The board IDs and PCI bus IDs are
13+
from that descriptor; the `p150b` board name follows the UPI mapping used by
14+
`tt-smi`.
15+
- `blackhole_galaxy.json` is derived from the Blackhole Galaxy example in the
16+
`tt-smi` README, which shows a 32-ASIC Galaxy reporting `tt-galaxy-bh`.
17+
18+
These fixtures are not substitutes for live hardware smoke tests. They preserve
19+
the `tt-smi` JSON shapes and UMD topology cases that we can verify from source.

0 commit comments

Comments
 (0)