Compare commits

..

No commits in common. "master" and "ttmetalfullinout" have entirely different histories.

15 changed files with 1315 additions and 714 deletions

View file

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

View file

@ -31,12 +31,15 @@
{ {
kmd = callPackages ./pkgs/kmd { inherit kernel; }; kmd = callPackages ./pkgs/kmd { inherit kernel; };
sfpi = callPackages ./pkgs/sfpi { }; sfpi = callPackages ./pkgs/sfpi { };
luwen = (callPackage ./pkgs/luwen { }).luwen; luwen = callPackage ./pkgs/luwen { };
pyluwen = (callPackage ./pkgs/luwen { }).pyluwen;
tools-common = callPackage ./pkgs/tools-common { }; tools-common = callPackage ./pkgs/tools-common { };
system-tools = callPackage ./pkgs/system-tools { }; system-tools = callPackage ./pkgs/system-tools { };
flash = callPackage ./pkgs/flash { }; flash = callPackage ./pkgs/flash {
smi = callPackage ./pkgs/smi { }; pyluwen = self.luwen.pyluwen_0_1;
};
smi = callPackage ./pkgs/smi {
pyluwen = self.luwen.pyluwen;
};
umd = callPackage ./pkgs/umd { }; umd = callPackage ./pkgs/umd { };
metal = callPackage ./pkgs/metal { }; metal = callPackage ./pkgs/metal { };
@ -49,11 +52,10 @@
udev-rules = scope.kmd.udev-rules; udev-rules = scope.kmd.udev-rules;
kmd-test = scope.kmd.test; kmd-test = scope.kmd.test;
sfpi = scope.sfpi.sfpi; sfpi = scope.sfpi.sfpi;
sfpi-prebuilt = scope.sfpi.prebuilt;
tt-gcc = scope.sfpi.tt-gcc; tt-gcc = scope.sfpi.tt-gcc;
smi = scope.smi; smi = scope.smi;
luwen = scope.luwen; luwen = scope.luwen.luwen;
pyluwen = scope.pyluwen; pyluwen = scope.luwen.pyluwen;
tools-common = scope.tools-common; tools-common = scope.tools-common;
system-tools = scope.system-tools; system-tools = scope.system-tools;
flash = scope.flash; flash = scope.flash;
@ -92,45 +94,17 @@
}) })
]; ];
kernelParams = [ 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" "iommu=pt"
]; ];
kernelModules = [ "tenstorrent" ]; kernelModules = [ "tenstorrent" ];
}; };
systemd = { services.udev.packages = [
# https://github.com/NixOS/nixpkgs/issues/81138 (pkgs.tt-udev-rules or self.packages.${pkgs.hostPlatform.system}.udev-rules)
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 { buildPythonPackage rec {
pname = "tt-flash"; pname = "tt-flash";
version = "3.1.1"; version = "unstable-2024-09-27";
src = pkgs.fetchFromGitHub { src = pkgs.fetchFromGitHub {
owner = "tenstorrent"; owner = "tenstorrent";
repo = "tt-flash"; repo = "tt-flash";
rev = "refs/tags/v${version}"; rev = "4002fee1da7edfcbf09093ba23612caeca071f23";
hash = "sha256-t2B1XEOKBKxE2eQiS7pc+EemBWomMgocyk4oRDt0Q78="; hash = "sha256-O6b/vS/zCjp/mrNzFEylWs0jtwdHY65nwkvn5GFridI=";
}; };
nativeBuildInputs = [ pythonRelaxDepsHook ]; nativeBuildInputs = [ pythonRelaxDepsHook ];

View file

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

View file

@ -1,12 +0,0 @@
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>

1037
pkgs/luwen/Cargo_0_1.lock Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,26 +1,16 @@
{ pkgs }: { 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 { luwen = pkgs.rustPlatform.buildRustPackage rec {
pname = "luwen"; pname = "luwen";
inherit version src; version = "unstable-2024-09-13";
src = pkgs.fetchFromGitHub {
owner = "tenstorrent";
repo = "luwen";
rev = "e4e10e95928f4b73d31ac4f41ea08cd6e3ef5573";
sha256 = "sha256-cScaqWAyjDuvy9M2EccMfUHfDq23IWniaKeq+upHzOg=";
};
postPatch = '' postPatch = ''
ln -s ${./Cargo_0_2.lock} Cargo.lock ln -s ${./Cargo_0_2.lock} Cargo.lock
@ -32,7 +22,14 @@ in
pyluwen = pkgs.python3.pkgs.buildPythonPackage rec { pyluwen = pkgs.python3.pkgs.buildPythonPackage rec {
pname = "pyluwen"; pname = "pyluwen";
inherit version src; version = "unstable-2024-09-13";
src = pkgs.fetchFromGitHub {
owner = "tenstorrent";
repo = "luwen";
rev = "e4e10e95928f4b73d31ac4f41ea08cd6e3ef5573";
sha256 = "sha256-cScaqWAyjDuvy9M2EccMfUHfDq23IWniaKeq+upHzOg=";
};
postPatch = '' postPatch = ''
ln -s ${./Cargo_0_2.lock} Cargo.lock ln -s ${./Cargo_0_2.lock} Cargo.lock
@ -55,4 +52,39 @@ in
"pyluwen" "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; llvmPackages = llvmPackages_17;
depsDir = "deps"; depsDir = "deps";
version = "0.53.0"; version = "unstable-2024-10-04";
metal-deps = metal.overrideAttrs (previousAttrs: { metal-deps = metal.overrideAttrs (previousAttrs: {
name = "tt-metal-deps-${version}.tar.gz"; name = "tt-metal-deps-${version}.tar.gz";
@ -63,8 +63,8 @@ let
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "tenstorrent"; owner = "tenstorrent";
repo = "tt-metal"; repo = "tt-metal";
rev = "154e6993aed78213446c59731e41c3617d83c1f1"; rev = "697ccc724048108e9f11a3c9ed5171a17ac9fd9c";
hash = "sha256-edtlE4CVsTO4BW0PKhkN0IxdV666Tu/Y1jgZ2Exljeo="; hash = "sha256-pBfJAtSyRKtU3iG2P3hVuo2LXHBFOU+3XmRkbDuDvDQ=";
fetchSubmodules = true; fetchSubmodules = true;
fetchLFS = true; fetchLFS = true;
}; };
@ -106,7 +106,7 @@ let
substituteInPlace tt_metal/hw/CMakeLists.txt \ substituteInPlace tt_metal/hw/CMakeLists.txt \
--replace-fail "FetchContent_MakeAvailable(sfpi)" "" --replace-fail "FetchContent_MakeAvailable(sfpi)" ""
mkdir -p runtime mkdir -p runtime
ln -s ${sfpi.prebuilt} runtime/sfpi ln -s ${sfpi.sfpi} runtime/sfpi
''; '';
ARCH_NAME = "wormhole_b0"; ARCH_NAME = "wormhole_b0";
@ -118,7 +118,6 @@ let
cmakeFlags = [ cmakeFlags = [
"-DCPM_SOURCE_CACHE=${depsDir}" "-DCPM_SOURCE_CACHE=${depsDir}"
"-DBUILD_PROGRAMMING_EXAMPLES=TRUE"
]; ];
postInstall = '' postInstall = ''
@ -133,11 +132,6 @@ let
sed -i "s|/build/source|/suild/source|g" "$f" sed -i "s|/build/source|/suild/source|g" "$f"
sed -i 's|$ORIGIN/build/lib:|$ORIGIN/suild/lib:|g' "$f" sed -i 's|$ORIGIN/build/lib:|$ORIGIN/suild/lib:|g' "$f"
done 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; dontPatchELF = true;

View file

@ -103,14 +103,6 @@ let
--replace-fail '$ENV{TT_METAL_HOME}/build/lib' '${metal}/lib ${metal}/build/lib' --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 = [ cmakeFlags = [
"-DCPM_SOURCE_CACHE=${depsDir}" "-DCPM_SOURCE_CACHE=${depsDir}"
]; ];

View file

@ -27,32 +27,5 @@ 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; }; tt-gcc = import ./tt-gcc.nix { inherit pkgs; };
} }

View file

@ -8,13 +8,13 @@ with pkgs.python3Packages;
buildPythonPackage rec { buildPythonPackage rec {
pname = "tt-smi"; pname = "tt-smi";
version = "3.0.5"; version = "unstable-2024-09-27";
src = pkgs.fetchFromGitHub { src = pkgs.fetchFromGitHub {
owner = "tenstorrent"; owner = "tenstorrent";
repo = "tt-smi"; repo = "tt-smi";
rev = "refs/tags/v${version}"; rev = "052f1ce49b94581710744a91939121e01c24b5f2";
hash = "sha256-+Dw6F9aupe4VTWQFiNWGKMDOTmxwCW2bHuDQxWxluUc="; hash = "sha256-IA60unZpSWVnMnDjDIC31QtURi9nIr/F7s7PGZilPcw=";
}; };
format = "pyproject"; format = "pyproject";
@ -39,6 +39,7 @@ buildPythonPackage rec {
propagatedBuildInputs = [ propagatedBuildInputs = [
setuptools setuptools
requests requests
textual
black black
distro distro
elasticsearch elasticsearch
@ -50,14 +51,5 @@ buildPythonPackage rec {
importlib-resources importlib-resources
pkgs.pre-commit pkgs.pre-commit
tools-common 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,8 +33,7 @@ stdenv.mkDerivation rec {
runHook preInstall runHook preInstall
install -Dm444 -t $out/lib/systemd/system/ "tenstorrent-hugepages.service" install -Dm444 -t $out/lib/systemd/system/ "tenstorrent-hugepages.service"
# Defined in the module install -Dm444 -t $out/lib/systemd/system/ 'dev-hugepages\x2d1G.mount'
#install -Dm444 -t $out/lib/systemd/system/ 'dev-hugepages\x2d1G.mount'
install -Dm555 -t $out/libexec/ "hugepages-setup.sh" install -Dm555 -t $out/libexec/ "hugepages-setup.sh"
runHook postInstall runHook postInstall
@ -44,17 +43,14 @@ stdenv.mkDerivation rec {
substituteInPlace "$out/lib/systemd/system/tenstorrent-hugepages.service" \ substituteInPlace "$out/lib/systemd/system/tenstorrent-hugepages.service" \
--replace-fail "/opt/tenstorrent/bin/hugepages-setup.sh" "$out/libexec/hugepages-setup.sh" --replace-fail "/opt/tenstorrent/bin/hugepages-setup.sh" "$out/libexec/hugepages-setup.sh"
mv "$out/libexec/hugepages-setup.sh" "$out/libexec/.hugepages-setup.sh-wrapped" wrapProgram "$out/libexec/hugepages-setup.sh" \
makeWrapper ${bash}/bin/bash "$out/libexec/hugepages-setup.sh" \
--prefix PATH : ${ --prefix PATH : ${
lib.makeBinPath [ lib.makeBinPath [
coreutils coreutils
pciutils pciutils
gawk gawk
] ]
} \ }
--add-flags "-x $out/libexec/.hugepages-setup.sh-wrapped"
# add -x easier debugging
''; '';
meta = { meta = {

View file

@ -1,37 +1,21 @@
{ fetchFromGitHub, python3Packages }: { pkgs }:
let with pkgs.python3Packages;
# 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
python3Packages.buildPythonPackage rec { buildPythonPackage rec {
pname = "tools-common"; pname = "tools-common";
# https://github.com/tenstorrent/tt-smi/blob/main/pyproject.toml#L31 version = "unstable-2024-09-27";
version = "1.4.11";
src = fetchFromGitHub { src = pkgs.fetchFromGitHub {
owner = "tenstorrent"; owner = "tenstorrent";
repo = "tt-tools-common"; repo = "tt-tools-common";
rev = "refs/tags/v${version}"; rev = "a89b2db6d086698ab0351a820ea689b4809429a3";
sha256 = "sha256-Q5GpT6B3pamY6bUjPbvNJ11npiR4q/6QMjRxovQ/MZ0="; sha256 = "sha256-xeiJQkWsg9p8re2XJai0mNWuP7LwJ9faj3+Z3U/KvzI=";
}; };
format = "pyproject"; format = "pyproject";
nativeBuildInputs = with python3Packages; [ pythonRelaxDepsHook ]; nativeBuildInputs = [ pythonRelaxDepsHook ];
pythonRelaxDeps = [ pythonRelaxDeps = [
"distro" "distro"
@ -44,14 +28,14 @@ python3Packages.buildPythonPackage rec {
"tqdm" "tqdm"
]; ];
propagatedBuildInputs = with python3Packages; [ propagatedBuildInputs = [
setuptools setuptools
distro distro
elasticsearch elasticsearch
psutil psutil
pyyaml pyyaml
rich rich
textual_0_82 textual
requests requests
jsons jsons
tqdm tqdm
@ -61,8 +45,4 @@ python3Packages.buildPythonPackage rec {
pythonImportsCheck = [ pythonImportsCheck = [
"tt_tools_common" "tt_tools_common"
]; ];
passthru = {
textual = textual_0_82;
};
} }