Compare commits

..

16 commits

Author SHA1 Message Date
Artturin 65d7bef16d {smi,tools-common}: pin textual 2025-01-29 20:07:04 +02:00
Artturin 2245c9c5ea smi: Add test 2025-01-29 19:41:49 +02:00
Artturin f18aa5fee2 tools-common: Use version needed by tt-smi 2025-01-29 19:34:24 +02:00
Artturin 31f0cee50d {luwen,pyluwen,flash,smi}: Update and drop pyluwen_0_1 2025-01-29 19:03:14 +02:00
Artturin ba96c32479 {kmd,smi,tools-common}: Update 2025-01-29 03:53:16 +02:00
Artturin 24410845a0 flake.lock: Update
Flake lock file updates:

• Updated input 'flake-compat':
    'github:edolstra/flake-compat/0f9255e01c2351cc7d116c072cb317785dd33b33?narHash=sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U%3D' (2023-10-04)
  → 'github:edolstra/flake-compat/ff81ac966bb2cae68946d5ed5fc4994f96d0ffec?narHash=sha256-NeCCThCEP3eCl2l/%2B27kNNK7QrwZB1IJCrXfrbv5oqU%3D' (2024-12-04)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/06cf0e1da4208d3766d898b7fdab6513366d45b9?narHash=sha256-S5kVU7U82LfpEukbn/ihcyNt2%2BEvG7Z5unsKW9H/yFA%3D' (2024-09-29)
  → 'github:NixOS/nixpkgs/d70bd19e0a38ad4790d3913bf08fcbfc9eeca507?narHash=sha256-4EVBRhOjMDuGtMaofAIqzJbg4Ql7Ai0PSeuVZTHjyKQ%3D' (2024-12-19)
• Updated input 'utils':
    'github:numtide/flake-utils/c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a?narHash=sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ%3D' (2024-09-17)
  → 'github:numtide/flake-utils/11707dc2f618dd54ca8739b309ec4fc024de578b?narHash=sha256-l0KFg5HjrsfsO/JpG%2Br7fRrqm12kzFHyUHqHCVpMMbI%3D' (2024-11-13)
2024-12-23 22:03:32 +02:00
Artturin 8412c8bf22 smi: Disable test
Fails to build because it doens't find tests because there's none
2024-12-23 22:03:05 +02:00
Artturin c1b3fac31c metal: build examples and create dirs to bind mount to 2024-12-23 21:50:06 +02:00
Artturin fa8e1be058 metal.tests.template: Install sample_app 2024-12-17 22:26:08 +02:00
Artturin 9abd0fb916 Update metal to 0.53.0
Use prebuilt sfpi which is patched to work on NixOS and nix sandbox and
elsewhere.
2024-12-17 21:41:22 +02:00
Artturin 8f850c7c62 Define hugepages mount in module 2024-11-21 01:06:03 +02:00
Artturin 66bf540c3e Use udev-rules
See comment
2024-11-21 00:52:35 +02:00
Artturin e5c7215b90 Make /dev/tenstorrent owned by the tenstorrent group
Hopefully to make the device useable without running docker with
--privileged
2024-11-21 00:23:56 +02:00
Artturin 441f4dc464 Add wantedBy to services 2024-11-20 23:47:34 +02:00
Artturin 1ae7313fad Add -x to hugepages-setup.sh 2024-11-20 23:33:37 +02:00
Artturin be924e4600 Use system-tools 2024-11-20 23:08:43 +02:00
15 changed files with 716 additions and 1317 deletions

View file

@ -57,3 +57,8 @@ Testing /dev/tenstorrent/1 @ 0000:76:00.0
```
As far as I can tell, these failures are exercised by the tests, and a clean `stdout` means there is no issue.
# TODO
- [ ] Better update system

View file

@ -3,11 +3,11 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"lastModified": 1733328505,
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"type": "github"
},
"original": {
@ -18,11 +18,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1727634051,
"narHash": "sha256-S5kVU7U82LfpEukbn/ihcyNt2+EvG7Z5unsKW9H/yFA=",
"lastModified": 1734649271,
"narHash": "sha256-4EVBRhOjMDuGtMaofAIqzJbg4Ql7Ai0PSeuVZTHjyKQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "06cf0e1da4208d3766d898b7fdab6513366d45b9",
"rev": "d70bd19e0a38ad4790d3913bf08fcbfc9eeca507",
"type": "github"
},
"original": {
@ -59,11 +59,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {

View file

@ -31,15 +31,12 @@
{
kmd = callPackages ./pkgs/kmd { inherit kernel; };
sfpi = callPackages ./pkgs/sfpi { };
luwen = callPackage ./pkgs/luwen { };
luwen = (callPackage ./pkgs/luwen { }).luwen;
pyluwen = (callPackage ./pkgs/luwen { }).pyluwen;
tools-common = callPackage ./pkgs/tools-common { };
system-tools = callPackage ./pkgs/system-tools { };
flash = callPackage ./pkgs/flash {
pyluwen = self.luwen.pyluwen_0_1;
};
smi = callPackage ./pkgs/smi {
pyluwen = self.luwen.pyluwen;
};
flash = callPackage ./pkgs/flash { };
smi = callPackage ./pkgs/smi { };
umd = callPackage ./pkgs/umd { };
metal = callPackage ./pkgs/metal { };
@ -52,10 +49,11 @@
udev-rules = scope.kmd.udev-rules;
kmd-test = scope.kmd.test;
sfpi = scope.sfpi.sfpi;
sfpi-prebuilt = scope.sfpi.prebuilt;
tt-gcc = scope.sfpi.tt-gcc;
smi = scope.smi;
luwen = scope.luwen.luwen;
pyluwen = scope.luwen.pyluwen;
luwen = scope.luwen;
pyluwen = scope.pyluwen;
tools-common = scope.tools-common;
system-tools = scope.system-tools;
flash = scope.flash;
@ -94,17 +92,45 @@
})
];
kernelParams = [
# TODO: Use the scripts instead https://github.com/tenstorrent/tt-system-tools they work regardless of how many devices there are
# https://github.com/tenstorrent/tt-system-tools/blob/main/hugepages-setup.sh#L31
"hugepagesz=1G"
"hugepages=4"
"iommu=pt"
];
kernelModules = [ "tenstorrent" ];
};
services.udev.packages = [
(pkgs.tt-udev-rules or self.packages.${pkgs.hostPlatform.system}.udev-rules)
];
systemd = {
# https://github.com/NixOS/nixpkgs/issues/81138
services.tenstorrent-hugepages.wantedBy = [ "sysinit.target" ];
# Define https://github.com/tenstorrent/tt-system-tools/blob/29ba4dc6049eef3cee4314c53720417823ffc667/dev-hugepages%5Cx2d1G.mount
# because it has bad start ordering relations with tenstorrent-hugepages.service
# or it may be that the `wantedBy` does not work correctly in mounts like it does't work in serices.
mounts = [
{
description = "Mount hugepages at /dev/hugepages-1G for Tenstorrent ASICs";
what = "hugetlbfs";
where = "/dev/hugepages-1G";
type = "hugetlbfs";
options = "pagesize=1G,mode=0777,nosuid,nodev";
wantedBy = [ "sysinit.target" ];
after = [ "tenstorrent-hugepages.service" ];
unitConfig = {
DefaultDependencies = false;
ConditionPathExists = "/sys/kernel/mm/hugepages/hugepages-1048576kB";
ConditionCapability = "CAP_SYS_ADMIN";
};
}
];
packages = [
(pkgs.tt-system-tools or self.packages.${pkgs.hostPlatform.system}.system-tools)
];
};
services.udev = {
packages = [ (pkgs.tt-udev-rules or self.packages.${pkgs.hostPlatform.system}.udev-rules) ];
# NOTE: passing just the group does not work currently for docker so unneeded for now so use the udev-rules package for now
# TT_METAL_HOME=$PWD docker run -v $PWD:/host --workdir /host -v /dev/hugepages-1G:/dev/hugepages-1G -v /dev/tenstorrent:/dev/tenstorrent -u :994 -v /etc/group:/etc/group:ro -it tt-metal bash
# extraRules = ''
# KERNEL=="tenstorrent*", MODE="0666", OWNER="root", GROUP="tenstorrent"
# '';
};
# users.groups.tenstorrent = { };
};
};

View file

@ -8,13 +8,13 @@ with pkgs.python3Packages;
buildPythonPackage rec {
pname = "tt-flash";
version = "unstable-2024-09-27";
version = "3.1.1";
src = pkgs.fetchFromGitHub {
owner = "tenstorrent";
repo = "tt-flash";
rev = "4002fee1da7edfcbf09093ba23612caeca071f23";
hash = "sha256-O6b/vS/zCjp/mrNzFEylWs0jtwdHY65nwkvn5GFridI=";
rev = "refs/tags/v${version}";
hash = "sha256-t2B1XEOKBKxE2eQiS7pc+EemBWomMgocyk4oRDt0Q78=";
};
nativeBuildInputs = [ pythonRelaxDepsHook ];

View file

@ -4,10 +4,10 @@ let
src = pkgs.fetchFromGitHub {
owner = "tenstorrent";
repo = "tt-kmd";
rev = "715a5d76e5dbb6d8972d4aa92e8cbe3434986b9f";
hash = "sha256-OCnGhvIDIqkQJXlIpOVnP0O9cA9J7/bz1JPAOpeDNYQ=";
rev = "refs/tags/ttkmd-${version}";
hash = "sha256-TTd+SXUQ/RwsZB7YIc0QsE9zHBCYO3NRrCub7/K1rP4=";
};
version = "unstable-2024-09-06";
version = "1.31";
in
{
kmd = pkgs.stdenv.mkDerivation {
@ -41,6 +41,9 @@ in
test = pkgs.stdenv.mkDerivation {
pname = "tt-kmd-test";
# https://github.com/tenstorrent/tt-kmd/pull/37
patches = ./limits.patch;
inherit src version;
nativeBuildInputs = [ pkgs.gnumake ];

12
pkgs/kmd/limits.patch Normal file
View file

@ -0,0 +1,12 @@
diff --git a/test/query_mappings.cpp b/test/query_mappings.cpp
index 0721485..7fe7ae4 100644
--- a/test/query_mappings.cpp
+++ b/test/query_mappings.cpp
@@ -16,6 +16,7 @@
#include <set>
#include <string>
#include <cstddef>
+#include <limits>
#include <cstdint>
#include <sys/ioctl.h>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,16 +1,26 @@
{ pkgs }:
let
# Upstream does not vendor a lock file so one has to created manually
# `cargo generate-lockfile`
# Use verson needed by tt-smi
# https://github.com/tenstorrent/tt-smi/blob/main/pyproject.toml#L30
version = "0.4.9";
src = pkgs.fetchFromGitHub {
owner = "tenstorrent";
repo = "luwen";
rev = "refs/tags/v${version}";
sha256 = "sha256-K68PjccE2fBkU4RvKv8X6jKRPYqsVhKB6jU92aajLgo=";
};
in
{
luwen = pkgs.rustPlatform.buildRustPackage rec {
pname = "luwen";
version = "unstable-2024-09-13";
src = pkgs.fetchFromGitHub {
owner = "tenstorrent";
repo = "luwen";
rev = "e4e10e95928f4b73d31ac4f41ea08cd6e3ef5573";
sha256 = "sha256-cScaqWAyjDuvy9M2EccMfUHfDq23IWniaKeq+upHzOg=";
};
inherit version src;
postPatch = ''
ln -s ${./Cargo_0_2.lock} Cargo.lock
@ -22,14 +32,7 @@
pyluwen = pkgs.python3.pkgs.buildPythonPackage rec {
pname = "pyluwen";
version = "unstable-2024-09-13";
src = pkgs.fetchFromGitHub {
owner = "tenstorrent";
repo = "luwen";
rev = "e4e10e95928f4b73d31ac4f41ea08cd6e3ef5573";
sha256 = "sha256-cScaqWAyjDuvy9M2EccMfUHfDq23IWniaKeq+upHzOg=";
};
inherit version src;
postPatch = ''
ln -s ${./Cargo_0_2.lock} Cargo.lock
@ -52,39 +55,4 @@
"pyluwen"
];
};
pyluwen_0_1 = pkgs.python3.pkgs.buildPythonPackage rec {
pname = "pyluwen";
version = "v0.1.0";
src = pkgs.fetchFromGitHub {
owner = "tenstorrent";
repo = "luwen";
rev = "${version}";
sha256 = "sha256-MyOzm3dfEkL7MsVzV51DaO+Op3+QhUzsYCTDsvYsvpk=";
};
postPatch = ''
ln -s ${./Cargo_0_1.lock} Cargo.lock
'';
buildAndTestSubdir = "crates/pyluwen";
format = "pyproject";
cargoDeps = pkgs.rustPlatform.fetchCargoTarball {
inherit src postPatch;
name = "${pname}-${version}";
hash = "sha256-ZXcj/pzQ/tAROdmi2w+AWYBvLSEZFayizxw+BmNDj70=";
};
nativeBuildInputs = [
pkgs.rustPlatform.cargoSetupHook
pkgs.rustPlatform.maturinBuildHook
];
pythonImportsCheck = [
"pyluwen"
];
};
}

View file

@ -21,7 +21,7 @@ let
llvmPackages = llvmPackages_17;
depsDir = "deps";
version = "unstable-2024-10-04";
version = "0.53.0";
metal-deps = metal.overrideAttrs (previousAttrs: {
name = "tt-metal-deps-${version}.tar.gz";
@ -63,8 +63,8 @@ let
src = fetchFromGitHub {
owner = "tenstorrent";
repo = "tt-metal";
rev = "697ccc724048108e9f11a3c9ed5171a17ac9fd9c";
hash = "sha256-pBfJAtSyRKtU3iG2P3hVuo2LXHBFOU+3XmRkbDuDvDQ=";
rev = "154e6993aed78213446c59731e41c3617d83c1f1";
hash = "sha256-edtlE4CVsTO4BW0PKhkN0IxdV666Tu/Y1jgZ2Exljeo=";
fetchSubmodules = true;
fetchLFS = true;
};
@ -106,7 +106,7 @@ let
substituteInPlace tt_metal/hw/CMakeLists.txt \
--replace-fail "FetchContent_MakeAvailable(sfpi)" ""
mkdir -p runtime
ln -s ${sfpi.sfpi} runtime/sfpi
ln -s ${sfpi.prebuilt} runtime/sfpi
'';
ARCH_NAME = "wormhole_b0";
@ -118,6 +118,7 @@ let
cmakeFlags = [
"-DCPM_SOURCE_CACHE=${depsDir}"
"-DBUILD_PROGRAMMING_EXAMPLES=TRUE"
];
postInstall = ''
@ -132,6 +133,11 @@ let
sed -i "s|/build/source|/suild/source|g" "$f"
sed -i 's|$ORIGIN/build/lib:|$ORIGIN/suild/lib:|g' "$f"
done
# Using tt-metal tries to write to <storepath>/built
# Create the built dir so a writable dir can be bind mounted to it
mkdir $out/built
mkdir $out/generated
'';
dontPatchELF = true;

View file

@ -103,6 +103,14 @@ let
--replace-fail '$ENV{TT_METAL_HOME}/build/lib' '${metal}/lib ${metal}/build/lib'
'';
# No default install target
installPhase = ''
runHook preInstall
pwd
install -D sources/examples/sample_app/sample_app $out/bin/sample_app
runHook postInstall
'';
cmakeFlags = [
"-DCPM_SOURCE_CACHE=${depsDir}"
];

View file

@ -27,5 +27,32 @@ rec {
'';
};
prebuilt = pkgs.stdenv.mkDerivation rec {
pname = "tt-gcc";
version = "5.0.0";
src = pkgs.fetchzip {
url = "https://github.com/tenstorrent/sfpi/releases/download/v5.0.0/sfpi-release.tgz";
hash = "sha256-RBhJ6BWmvB06zWoELTumpzroHDMpNXU0/WC6elgAkW0=";
};
nativeBuildInputs = with pkgs; [
autoPatchelfHook
];
buildInputs = with pkgs; [
libmpc
mpfr
gmp
zlib
expat
];
installPhase = ''
cp -r . $out
'';
};
tt-gcc = import ./tt-gcc.nix { inherit pkgs; };
}

View file

@ -8,13 +8,13 @@ with pkgs.python3Packages;
buildPythonPackage rec {
pname = "tt-smi";
version = "unstable-2024-09-27";
version = "3.0.5";
src = pkgs.fetchFromGitHub {
owner = "tenstorrent";
repo = "tt-smi";
rev = "052f1ce49b94581710744a91939121e01c24b5f2";
hash = "sha256-IA60unZpSWVnMnDjDIC31QtURi9nIr/F7s7PGZilPcw=";
rev = "refs/tags/v${version}";
hash = "sha256-+Dw6F9aupe4VTWQFiNWGKMDOTmxwCW2bHuDQxWxluUc=";
};
format = "pyproject";
@ -39,7 +39,6 @@ buildPythonPackage rec {
propagatedBuildInputs = [
setuptools
requests
textual
black
distro
elasticsearch
@ -51,5 +50,14 @@ buildPythonPackage rec {
importlib-resources
pkgs.pre-commit
tools-common
tools-common.textual
];
dontUsePytestCheck = true; # no tests
installCheckPhase = ''
output=$($out/bin/tt-smi || true)
echo "tt-smi output: $output"
echo $output | grep -q "No Tenstorrent driver detected"
'';
}

View file

@ -33,7 +33,8 @@ stdenv.mkDerivation rec {
runHook preInstall
install -Dm444 -t $out/lib/systemd/system/ "tenstorrent-hugepages.service"
install -Dm444 -t $out/lib/systemd/system/ 'dev-hugepages\x2d1G.mount'
# Defined in the module
#install -Dm444 -t $out/lib/systemd/system/ 'dev-hugepages\x2d1G.mount'
install -Dm555 -t $out/libexec/ "hugepages-setup.sh"
runHook postInstall
@ -43,14 +44,17 @@ stdenv.mkDerivation rec {
substituteInPlace "$out/lib/systemd/system/tenstorrent-hugepages.service" \
--replace-fail "/opt/tenstorrent/bin/hugepages-setup.sh" "$out/libexec/hugepages-setup.sh"
wrapProgram "$out/libexec/hugepages-setup.sh" \
mv "$out/libexec/hugepages-setup.sh" "$out/libexec/.hugepages-setup.sh-wrapped"
makeWrapper ${bash}/bin/bash "$out/libexec/hugepages-setup.sh" \
--prefix PATH : ${
lib.makeBinPath [
coreutils
pciutils
gawk
]
}
} \
--add-flags "-x $out/libexec/.hugepages-setup.sh-wrapped"
# add -x easier debugging
'';
meta = {

View file

@ -1,21 +1,37 @@
{ pkgs }:
{ fetchFromGitHub, python3Packages }:
with pkgs.python3Packages;
let
# Can be unpinned once https://github.com/tenstorrent/tt-tools-common/blob/main/pyproject.toml#L32
# is v1
textual_0_82 = python3Packages.textual.overridePythonAttrs (old: rec {
version = "0.82.0";
src = fetchFromGitHub {
owner = "Textualize";
repo = "textual";
rev = "refs/tags/v${version}";
hash = "sha256-belpoXQ+CkTchK+FjI/Ur8v4cNgzX39xLdNfPCwaU6E=";
};
disabledTests = old.disabledTests ++ [
"test_selection"
];
});
in
buildPythonPackage rec {
python3Packages.buildPythonPackage rec {
pname = "tools-common";
version = "unstable-2024-09-27";
# https://github.com/tenstorrent/tt-smi/blob/main/pyproject.toml#L31
version = "1.4.11";
src = pkgs.fetchFromGitHub {
src = fetchFromGitHub {
owner = "tenstorrent";
repo = "tt-tools-common";
rev = "a89b2db6d086698ab0351a820ea689b4809429a3";
sha256 = "sha256-xeiJQkWsg9p8re2XJai0mNWuP7LwJ9faj3+Z3U/KvzI=";
rev = "refs/tags/v${version}";
sha256 = "sha256-Q5GpT6B3pamY6bUjPbvNJ11npiR4q/6QMjRxovQ/MZ0=";
};
format = "pyproject";
nativeBuildInputs = [ pythonRelaxDepsHook ];
nativeBuildInputs = with python3Packages; [ pythonRelaxDepsHook ];
pythonRelaxDeps = [
"distro"
@ -28,14 +44,14 @@ buildPythonPackage rec {
"tqdm"
];
propagatedBuildInputs = [
propagatedBuildInputs = with python3Packages; [
setuptools
distro
elasticsearch
psutil
pyyaml
rich
textual
textual_0_82
requests
jsons
tqdm
@ -45,4 +61,8 @@ buildPythonPackage rec {
pythonImportsCheck = [
"tt_tools_common"
];
passthru = {
textual = textual_0_82;
};
}