Compare commits
21 commits
try-packag
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
65d7bef16d | ||
![]() |
2245c9c5ea | ||
![]() |
f18aa5fee2 | ||
![]() |
31f0cee50d | ||
![]() |
ba96c32479 | ||
![]() |
24410845a0 | ||
![]() |
8412c8bf22 | ||
![]() |
c1b3fac31c | ||
![]() |
fa8e1be058 | ||
![]() |
9abd0fb916 | ||
![]() |
8f850c7c62 | ||
![]() |
66bf540c3e | ||
![]() |
e5c7215b90 | ||
![]() |
441f4dc464 | ||
![]() |
1ae7313fad | ||
![]() |
be924e4600 | ||
![]() |
31b3aa6fdc | ||
![]() |
d937e5c7fa | ||
![]() |
29dc8c01e2 | ||
![]() |
bfee5bc0ff | ||
![]() |
c280cd3a8f |
|
@ -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.
|
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
|
||||||
|
|
18
flake.lock
18
flake.lock
|
@ -3,11 +3,11 @@
|
||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1696426674,
|
"lastModified": 1733328505,
|
||||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
|
||||||
"owner": "edolstra",
|
"owner": "edolstra",
|
||||||
"repo": "flake-compat",
|
"repo": "flake-compat",
|
||||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -18,11 +18,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727634051,
|
"lastModified": 1734649271,
|
||||||
"narHash": "sha256-S5kVU7U82LfpEukbn/ihcyNt2+EvG7Z5unsKW9H/yFA=",
|
"narHash": "sha256-4EVBRhOjMDuGtMaofAIqzJbg4Ql7Ai0PSeuVZTHjyKQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "06cf0e1da4208d3766d898b7fdab6513366d45b9",
|
"rev": "d70bd19e0a38ad4790d3913bf08fcbfc9eeca507",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -59,11 +59,11 @@
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726560853,
|
"lastModified": 1731533236,
|
||||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
56
flake.nix
56
flake.nix
|
@ -31,15 +31,12 @@
|
||||||
{
|
{
|
||||||
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 = (callPackage ./pkgs/luwen { }).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 { };
|
||||||
pyluwen = self.luwen.pyluwen_0_1;
|
smi = callPackage ./pkgs/smi { };
|
||||||
};
|
|
||||||
smi = callPackage ./pkgs/smi {
|
|
||||||
pyluwen = self.luwen.pyluwen;
|
|
||||||
};
|
|
||||||
umd = callPackage ./pkgs/umd { };
|
umd = callPackage ./pkgs/umd { };
|
||||||
metal = callPackage ./pkgs/metal { };
|
metal = callPackage ./pkgs/metal { };
|
||||||
|
|
||||||
|
@ -52,10 +49,11 @@
|
||||||
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;
|
luwen = scope.luwen;
|
||||||
pyluwen = scope.luwen.pyluwen;
|
pyluwen = scope.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;
|
||||||
|
@ -94,17 +92,45 @@
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
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" ];
|
||||||
};
|
};
|
||||||
services.udev.packages = [
|
systemd = {
|
||||||
(pkgs.tt-udev-rules or self.packages.${pkgs.hostPlatform.system}.udev-rules)
|
# 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 = { };
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,13 +8,13 @@ with pkgs.python3Packages;
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
pname = "tt-flash";
|
pname = "tt-flash";
|
||||||
version = "unstable-2024-09-27";
|
version = "3.1.1";
|
||||||
|
|
||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchFromGitHub {
|
||||||
owner = "tenstorrent";
|
owner = "tenstorrent";
|
||||||
repo = "tt-flash";
|
repo = "tt-flash";
|
||||||
rev = "4002fee1da7edfcbf09093ba23612caeca071f23";
|
rev = "refs/tags/v${version}";
|
||||||
hash = "sha256-O6b/vS/zCjp/mrNzFEylWs0jtwdHY65nwkvn5GFridI=";
|
hash = "sha256-t2B1XEOKBKxE2eQiS7pc+EemBWomMgocyk4oRDt0Q78=";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ pythonRelaxDepsHook ];
|
nativeBuildInputs = [ pythonRelaxDepsHook ];
|
||||||
|
|
|
@ -4,10 +4,10 @@ let
|
||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchFromGitHub {
|
||||||
owner = "tenstorrent";
|
owner = "tenstorrent";
|
||||||
repo = "tt-kmd";
|
repo = "tt-kmd";
|
||||||
rev = "715a5d76e5dbb6d8972d4aa92e8cbe3434986b9f";
|
rev = "refs/tags/ttkmd-${version}";
|
||||||
hash = "sha256-OCnGhvIDIqkQJXlIpOVnP0O9cA9J7/bz1JPAOpeDNYQ=";
|
hash = "sha256-TTd+SXUQ/RwsZB7YIc0QsE9zHBCYO3NRrCub7/K1rP4=";
|
||||||
};
|
};
|
||||||
version = "unstable-2024-09-06";
|
version = "1.31";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
kmd = pkgs.stdenv.mkDerivation {
|
kmd = pkgs.stdenv.mkDerivation {
|
||||||
|
@ -41,6 +41,9 @@ 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 ];
|
||||||
|
|
12
pkgs/kmd/limits.patch
Normal file
12
pkgs/kmd/limits.patch
Normal 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
|
@ -1,17 +1,27 @@
|
||||||
{ pkgs }:
|
{ pkgs }:
|
||||||
|
|
||||||
{
|
let
|
||||||
luwen = pkgs.rustPlatform.buildRustPackage rec {
|
|
||||||
pname = "luwen";
|
# Upstream does not vendor a lock file so one has to created manually
|
||||||
version = "unstable-2024-09-13";
|
# `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 {
|
src = pkgs.fetchFromGitHub {
|
||||||
owner = "tenstorrent";
|
owner = "tenstorrent";
|
||||||
repo = "luwen";
|
repo = "luwen";
|
||||||
rev = "e4e10e95928f4b73d31ac4f41ea08cd6e3ef5573";
|
rev = "refs/tags/v${version}";
|
||||||
sha256 = "sha256-cScaqWAyjDuvy9M2EccMfUHfDq23IWniaKeq+upHzOg=";
|
sha256 = "sha256-K68PjccE2fBkU4RvKv8X6jKRPYqsVhKB6jU92aajLgo=";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
luwen = pkgs.rustPlatform.buildRustPackage rec {
|
||||||
|
pname = "luwen";
|
||||||
|
inherit version src;
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
ln -s ${./Cargo_0_2.lock} Cargo.lock
|
ln -s ${./Cargo_0_2.lock} Cargo.lock
|
||||||
'';
|
'';
|
||||||
|
@ -22,14 +32,7 @@
|
||||||
|
|
||||||
pyluwen = pkgs.python3.pkgs.buildPythonPackage rec {
|
pyluwen = pkgs.python3.pkgs.buildPythonPackage rec {
|
||||||
pname = "pyluwen";
|
pname = "pyluwen";
|
||||||
version = "unstable-2024-09-13";
|
inherit version src;
|
||||||
|
|
||||||
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
|
||||||
|
@ -52,39 +55,4 @@
|
||||||
"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"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,21 +12,23 @@
|
||||||
sfpi,
|
sfpi,
|
||||||
hwloc,
|
hwloc,
|
||||||
libz,
|
libz,
|
||||||
|
runCommand,
|
||||||
|
libexecinfo,
|
||||||
|
callPackage,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
llvmPackages = llvmPackages_17;
|
llvmPackages = llvmPackages_17;
|
||||||
depsDir = "deps";
|
depsDir = "deps";
|
||||||
|
|
||||||
version = "unstable-2024-10-04";
|
version = "0.53.0";
|
||||||
|
|
||||||
metal-deps = metal.overrideAttrs (previousAttrs: {
|
metal-deps = metal.overrideAttrs (previousAttrs: {
|
||||||
name = "tt-metal-deps-${version}.tar.gz";
|
name = "tt-metal-deps-${version}.tar.gz";
|
||||||
|
|
||||||
dontBuild = true;
|
dontBuild = true;
|
||||||
|
|
||||||
outputHash = "sha256-UOBBqIP2KKEn2pfv7l5v2Of9RoZY0+3TCEu94MQUVYo=";
|
outputHash = "sha256-hhLjEssXID+uiPQ3kexMCOVB6DB9m/eAVmfr2OleGXc=";
|
||||||
outputHashAlgo = "sha256";
|
outputHashAlgo = "sha256";
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
|
@ -51,7 +53,9 @@ let
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
postInstall = "";
|
||||||
});
|
});
|
||||||
|
|
||||||
# NOTE: When changing something remember to make sure the outputHash above doesn't change, or if it changes then update it.
|
# NOTE: When changing something remember to make sure the outputHash above doesn't change, or if it changes then update it.
|
||||||
metal = llvmPackages.libcxxStdenv.mkDerivation {
|
metal = llvmPackages.libcxxStdenv.mkDerivation {
|
||||||
pname = "tt-metal";
|
pname = "tt-metal";
|
||||||
|
@ -59,12 +63,16 @@ let
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "tenstorrent";
|
owner = "tenstorrent";
|
||||||
repo = "tt-metal";
|
repo = "tt-metal";
|
||||||
rev = "0fb4249a94a99714de8f91d93d338832694c09e0";
|
rev = "154e6993aed78213446c59731e41c3617d83c1f1";
|
||||||
# this takes a while and we don't need all of them
|
hash = "sha256-edtlE4CVsTO4BW0PKhkN0IxdV666Tu/Y1jgZ2Exljeo=";
|
||||||
fetchSubmodules = true;
|
fetchSubmodules = true;
|
||||||
hash = "sha256-0tcIwaJzM75S7SFKCJ2UbfElwASpFwdySmzt2LUTT4A=";
|
fetchLFS = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
./rpath.patch
|
||||||
|
];
|
||||||
|
|
||||||
env.NIX_CFLAGS_COMPILE = "-Wno-unused-command-line-argument";
|
env.NIX_CFLAGS_COMPILE = "-Wno-unused-command-line-argument";
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
|
@ -78,11 +86,9 @@ let
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
numactl
|
numactl
|
||||||
|
|
||||||
# umd
|
# umd
|
||||||
hwloc
|
hwloc
|
||||||
libz
|
libz
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
postUnpack = ''
|
postUnpack = ''
|
||||||
|
@ -92,28 +98,56 @@ let
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
cp ${cpm-cmake}/share/cpm/CPM.cmake cmake/CPM.cmake
|
cp ${cpm-cmake}/share/cpm/CPM.cmake cmake/CPM.cmake
|
||||||
rm -rf tt_metal/third_party/sfpi/compiler
|
|
||||||
ln -s ${sfpi.tt-gcc} tt_metal/third_party/sfpi/compiler
|
substituteInPlace tt_metal/CMakeLists.txt ttnn/CMakeLists.txt \
|
||||||
|
--replace-fail "REPLACETHIS\"" "$out/lib\"" \
|
||||||
|
--replace-warn "REPLACETHIS1" "$out/build/lib"
|
||||||
|
|
||||||
|
substituteInPlace tt_metal/hw/CMakeLists.txt \
|
||||||
|
--replace-fail "FetchContent_MakeAvailable(sfpi)" ""
|
||||||
|
mkdir -p runtime
|
||||||
|
ln -s ${sfpi.prebuilt} runtime/sfpi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
ARCH_NAME = "wormhole_b0";
|
||||||
|
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
export ARCH_NAME=wormhole_b0
|
|
||||||
export TT_METAL_HOME=$(pwd)
|
export TT_METAL_HOME=$(pwd)
|
||||||
export PYTHONPATH=$(pwd)
|
export PYTHONPATH=$(pwd)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
"-DCPM_SOURCE_CACHE=${depsDir}"
|
"-DCPM_SOURCE_CACHE=${depsDir}"
|
||||||
|
"-DBUILD_PROGRAMMING_EXAMPLES=TRUE"
|
||||||
];
|
];
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
pwd
|
# Have to do this until cpp-ttnn-project-template is fixed
|
||||||
mkdir -p $out/lib
|
# ttnn-template> ninja: error: '/nix/store/-tt-metal-unstable-2024-10-04/build/lib/_ttnn.so', needed by 'sources/examples/sample_app/sample_app', missing and no known rule to make it
|
||||||
cp lib/{_ttnn.so,libtt_metal.so} $out/lib
|
cp -r ../ $out
|
||||||
|
rm -rf $out/.cpmcache
|
||||||
|
ln -s $out/build/deps $out/.cpmcache
|
||||||
|
|
||||||
|
# Nix checks for references to /build/source so these should be different but not a different size to prevent corruption
|
||||||
|
find "$out" -type f -print0 | while IFS= read -r -d $'\0' f; do
|
||||||
|
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;
|
||||||
|
dontStrip = true;
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit metal-deps;
|
inherit metal-deps;
|
||||||
|
tests = {
|
||||||
|
template = callPackage ./ttnn-template.nix { inherit metal; };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
28
pkgs/metal/rpath.patch
Normal file
28
pkgs/metal/rpath.patch
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
diff --git a/tt_metal/CMakeLists.txt b/tt_metal/CMakeLists.txt
|
||||||
|
index cba3743fbc..e580f6696c 100644
|
||||||
|
--- a/tt_metal/CMakeLists.txt
|
||||||
|
+++ b/tt_metal/CMakeLists.txt
|
||||||
|
@@ -55,7 +55,7 @@ set_target_properties(
|
||||||
|
tt_metal
|
||||||
|
PROPERTIES
|
||||||
|
INSTALL_RPATH
|
||||||
|
- "${PROJECT_BINARY_DIR}/lib"
|
||||||
|
+ "REPLACETHIS"
|
||||||
|
ADDITIONAL_CLEAN_FILES
|
||||||
|
"${PROJECT_BINARY_DIR}/lib;${PROJECT_BINARY_DIR}/obj"
|
||||||
|
)
|
||||||
|
diff --git a/ttnn/CMakeLists.txt b/ttnn/CMakeLists.txt
|
||||||
|
index 45ee3dd8f8..4401f51b39 100644
|
||||||
|
--- a/ttnn/CMakeLists.txt
|
||||||
|
+++ b/ttnn/CMakeLists.txt
|
||||||
|
@@ -683,8 +683,8 @@ TT_ENABLE_UNITY_BUILD(ttnn)
|
||||||
|
#We move the library binaries to a different path rather than PROJECT_BINARY_DIR
|
||||||
|
#in the Python wheel
|
||||||
|
set(TTNN_INSTALL_RPATH
|
||||||
|
- "${PROJECT_BINARY_DIR}/lib"
|
||||||
|
- "$ORIGIN/build/lib"
|
||||||
|
+ "REPLACETHIS"
|
||||||
|
+ "REPLACETHIS1"
|
||||||
|
)
|
||||||
|
|
||||||
|
#Make sure library built is _ttnn.so and that it can find all it's linked libraries
|
119
pkgs/metal/ttnn-template.nix
Normal file
119
pkgs/metal/ttnn-template.nix
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
{
|
||||||
|
stdenv,
|
||||||
|
fetchFromGitHub,
|
||||||
|
metal,
|
||||||
|
cmake,
|
||||||
|
ninja,
|
||||||
|
git,
|
||||||
|
cacert,
|
||||||
|
python3,
|
||||||
|
numactl,
|
||||||
|
hwloc,
|
||||||
|
libz,
|
||||||
|
llvmPackages_17,
|
||||||
|
cpm-cmake,
|
||||||
|
sfpi,
|
||||||
|
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
version = "0";
|
||||||
|
llvmPackages = llvmPackages_17;
|
||||||
|
depsDir = "deps";
|
||||||
|
|
||||||
|
ttnn-template-deps = ttnn-template.overrideAttrs (previousAttrs: {
|
||||||
|
name = "ttnn-template-deps-deps-${version}.tar.gz";
|
||||||
|
|
||||||
|
dontBuild = true;
|
||||||
|
|
||||||
|
outputHash = "sha256-qt3PLKE3lwqiYQq6m06V1xk1qDOyHAtGj8lw0Q99qgE=";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
|
||||||
|
cmakeFlags = [
|
||||||
|
"-DCPM_DOWNLOAD_ALL=ON"
|
||||||
|
"-DCPM_SOURCE_CACHE=${depsDir}"
|
||||||
|
];
|
||||||
|
|
||||||
|
# Infinite recursion
|
||||||
|
postUnpack = "";
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
# Prune the `.git` directories
|
||||||
|
find ${depsDir} -name .git -type d -prune -exec rm -rf {} \;;
|
||||||
|
# Build a reproducible tar, per instructions at https://reproducible-builds.org/docs/archives/
|
||||||
|
tar --owner=0 --group=0 --numeric-owner --format=gnu \
|
||||||
|
--sort=name --mtime="@$SOURCE_DATE_EPOCH" \
|
||||||
|
-czf $out \
|
||||||
|
${depsDir} \
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
postInstall = "";
|
||||||
|
});
|
||||||
|
|
||||||
|
ttnn-template = llvmPackages.libcxxStdenv.mkDerivation {
|
||||||
|
pname = "ttnn-template";
|
||||||
|
version = "0";
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "tenstorrent";
|
||||||
|
repo = "cpp-ttnn-project-template";
|
||||||
|
rev = "702b453aa7000daa56692b7559ec77adf407828d";
|
||||||
|
hash = "sha256-NzcZCVujJCyHQgALAewJjoWj+6bQXncONO7nRK8zSx4=";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
cmake
|
||||||
|
#ninja
|
||||||
|
python3
|
||||||
|
# for cpm
|
||||||
|
git
|
||||||
|
cacert
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
numactl
|
||||||
|
# umd
|
||||||
|
hwloc
|
||||||
|
libz
|
||||||
|
];
|
||||||
|
|
||||||
|
ARCH_NAME = "wormhole_b0";
|
||||||
|
TT_METAL_HOME = metal;
|
||||||
|
|
||||||
|
postUnpack = ''
|
||||||
|
mkdir -p $sourceRoot/build
|
||||||
|
tar -xf ${ttnn-template-deps} -C $sourceRoot/build
|
||||||
|
'';
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
cp ${cpm-cmake}/share/cpm/CPM.cmake cmake/CPM.cmake
|
||||||
|
|
||||||
|
# Upstream changed these locations and removed libfmt but the template hasn't been updated yet
|
||||||
|
# https://github.com/tenstorrent/tt-metal/pull/13788
|
||||||
|
substituteInPlace sources/sample_lib/CMakeLists.txt \
|
||||||
|
--replace-fail '$ENV{TT_METAL_HOME}/build/lib/_ttnn.so' '${metal}/lib/_ttnn.so' \
|
||||||
|
--replace-fail '$ENV{TT_METAL_HOME}/build/lib/libdevice.so' '${metal}/lib/libdevice.so' \
|
||||||
|
--replace-fail '$ENV{TT_METAL_HOME}/build/lib/libfmt.so' "" \
|
||||||
|
--replace-fail '$ENV{TT_METAL_HOME}/build/lib/libnng.so.1' '${metal}/lib/libnng.so.1.8.0' \
|
||||||
|
|
||||||
|
substituteInPlace sources/sample_lib/CMakeLists.txt \
|
||||||
|
--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}"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
ttnn-template
|
|
@ -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; };
|
tt-gcc = import ./tt-gcc.nix { inherit pkgs; };
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,13 @@ with pkgs.python3Packages;
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
pname = "tt-smi";
|
pname = "tt-smi";
|
||||||
version = "unstable-2024-09-27";
|
version = "3.0.5";
|
||||||
|
|
||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchFromGitHub {
|
||||||
owner = "tenstorrent";
|
owner = "tenstorrent";
|
||||||
repo = "tt-smi";
|
repo = "tt-smi";
|
||||||
rev = "052f1ce49b94581710744a91939121e01c24b5f2";
|
rev = "refs/tags/v${version}";
|
||||||
hash = "sha256-IA60unZpSWVnMnDjDIC31QtURi9nIr/F7s7PGZilPcw=";
|
hash = "sha256-+Dw6F9aupe4VTWQFiNWGKMDOTmxwCW2bHuDQxWxluUc=";
|
||||||
};
|
};
|
||||||
|
|
||||||
format = "pyproject";
|
format = "pyproject";
|
||||||
|
@ -39,7 +39,6 @@ buildPythonPackage rec {
|
||||||
propagatedBuildInputs = [
|
propagatedBuildInputs = [
|
||||||
setuptools
|
setuptools
|
||||||
requests
|
requests
|
||||||
textual
|
|
||||||
black
|
black
|
||||||
distro
|
distro
|
||||||
elasticsearch
|
elasticsearch
|
||||||
|
@ -51,5 +50,14 @@ 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"
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
fetchFromGitHub,
|
fetchFromGitHub,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
bash,
|
bash,
|
||||||
|
coreutils,
|
||||||
pciutils,
|
pciutils,
|
||||||
|
gawk,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
# NOTE: We might not use these files if we end up doing the things it does in nix instead if possible.
|
# NOTE: We might not use these files if we end up doing the things it does in nix instead if possible.
|
||||||
|
@ -31,7 +33,8 @@ 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"
|
||||||
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"
|
install -Dm555 -t $out/libexec/ "hugepages-setup.sh"
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
|
@ -41,12 +44,17 @@ 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"
|
||||||
|
|
||||||
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 : ${
|
--prefix PATH : ${
|
||||||
lib.makeBinPath [
|
lib.makeBinPath [
|
||||||
pciutils # for lspci
|
coreutils
|
||||||
|
pciutils
|
||||||
|
gawk
|
||||||
]
|
]
|
||||||
}
|
} \
|
||||||
|
--add-flags "-x $out/libexec/.hugepages-setup.sh-wrapped"
|
||||||
|
# add -x easier debugging
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
|
|
|
@ -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";
|
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";
|
owner = "tenstorrent";
|
||||||
repo = "tt-tools-common";
|
repo = "tt-tools-common";
|
||||||
rev = "a89b2db6d086698ab0351a820ea689b4809429a3";
|
rev = "refs/tags/v${version}";
|
||||||
sha256 = "sha256-xeiJQkWsg9p8re2XJai0mNWuP7LwJ9faj3+Z3U/KvzI=";
|
sha256 = "sha256-Q5GpT6B3pamY6bUjPbvNJ11npiR4q/6QMjRxovQ/MZ0=";
|
||||||
};
|
};
|
||||||
|
|
||||||
format = "pyproject";
|
format = "pyproject";
|
||||||
|
|
||||||
nativeBuildInputs = [ pythonRelaxDepsHook ];
|
nativeBuildInputs = with python3Packages; [ pythonRelaxDepsHook ];
|
||||||
|
|
||||||
pythonRelaxDeps = [
|
pythonRelaxDeps = [
|
||||||
"distro"
|
"distro"
|
||||||
|
@ -28,14 +44,14 @@ buildPythonPackage rec {
|
||||||
"tqdm"
|
"tqdm"
|
||||||
];
|
];
|
||||||
|
|
||||||
propagatedBuildInputs = [
|
propagatedBuildInputs = with python3Packages; [
|
||||||
setuptools
|
setuptools
|
||||||
distro
|
distro
|
||||||
elasticsearch
|
elasticsearch
|
||||||
psutil
|
psutil
|
||||||
pyyaml
|
pyyaml
|
||||||
rich
|
rich
|
||||||
textual
|
textual_0_82
|
||||||
requests
|
requests
|
||||||
jsons
|
jsons
|
||||||
tqdm
|
tqdm
|
||||||
|
@ -45,4 +61,8 @@ buildPythonPackage rec {
|
||||||
pythonImportsCheck = [
|
pythonImportsCheck = [
|
||||||
"tt_tools_common"
|
"tt_tools_common"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
passthru = {
|
||||||
|
textual = textual_0_82;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue