python3Packages.tinygrad: 0.12.0 -> 0.13.0
Diff: https://github.com/tinygrad/tinygrad/compare/v0.12.0...v0.13.0 Changelog: https://github.com/tinygrad/tinygrad/releases/tag/v0.13.0
This commit is contained in:
@@ -17,10 +17,6 @@
|
||||
setuptools,
|
||||
|
||||
# optional-dependencies
|
||||
# arm
|
||||
unicorn,
|
||||
# triton
|
||||
triton,
|
||||
# testing_minimal
|
||||
hypothesis,
|
||||
numpy,
|
||||
@@ -28,7 +24,8 @@
|
||||
torch,
|
||||
z3-solver,
|
||||
# testing_unit
|
||||
ggml-python,
|
||||
capstone,
|
||||
gguf,
|
||||
openai,
|
||||
safetensors,
|
||||
tabulate,
|
||||
@@ -37,7 +34,6 @@
|
||||
blobfile,
|
||||
boto3,
|
||||
bottle,
|
||||
capstone,
|
||||
librosa,
|
||||
networkx,
|
||||
nibabel,
|
||||
@@ -64,14 +60,15 @@
|
||||
|
||||
buildPythonPackage (finalAttrs: {
|
||||
pname = "tinygrad";
|
||||
version = "0.12.0";
|
||||
version = "0.13.0";
|
||||
pyproject = true;
|
||||
__structuredAttrs = true;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "tinygrad";
|
||||
repo = "tinygrad";
|
||||
tag = "v${finalAttrs.version}";
|
||||
hash = "sha256-Lied19C1sAbislr2WznnCZEmOn5PA0OzMg2KOdWOYkA=";
|
||||
hash = "sha256-cGv+swFzaMjwz40/p9OyW3HpZts09kVax2T/xYKW8sE=";
|
||||
};
|
||||
|
||||
patches =
|
||||
@@ -110,13 +107,13 @@ buildPythonPackage (finalAttrs: {
|
||||
postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
|
||||
substituteInPlace tinygrad/runtime/autogen/opencl.py \
|
||||
--replace-fail \
|
||||
"dll = DLL('opencl', 'OpenCL')" \
|
||||
"dll = DLL('opencl', '${lib.getLib ocl-icd}/lib/libOpenCL.so')"
|
||||
"dll = c.DLL('opencl', 'OpenCL')" \
|
||||
"dll = c.DLL('opencl', '${lib.getLib ocl-icd}/lib/libOpenCL.so')"
|
||||
|
||||
substituteInPlace tinygrad/runtime/autogen/libc.py \
|
||||
--replace-fail \
|
||||
"dll = DLL('libc', 'c', use_errno=True)" \
|
||||
"dll = DLL('libc', '${lib.getLib stdenv.cc.libc}/lib/libc.so.6', use_errno=True)"
|
||||
"dll = c.DLL('libc', 'c', use_errno=True)" \
|
||||
"dll = c.DLL('libc', '${lib.getLib stdenv.cc.libc}/lib/libc.so.6', use_errno=True)"
|
||||
'';
|
||||
|
||||
__propagatedImpureHostDeps = lib.optional stdenv.hostPlatform.isDarwin "/usr/lib/libc.dylib";
|
||||
@@ -124,8 +121,6 @@ buildPythonPackage (finalAttrs: {
|
||||
build-system = [ setuptools ];
|
||||
|
||||
optional-dependencies = lib.fix (self: {
|
||||
arm = [ unicorn ];
|
||||
triton = [ triton ];
|
||||
testing_minimal = [
|
||||
hypothesis
|
||||
numpy
|
||||
@@ -134,7 +129,8 @@ buildPythonPackage (finalAttrs: {
|
||||
z3-solver
|
||||
];
|
||||
testing_unit = self.testing_minimal ++ [
|
||||
ggml-python
|
||||
capstone
|
||||
gguf
|
||||
openai
|
||||
safetensors
|
||||
tabulate
|
||||
@@ -144,7 +140,6 @@ buildPythonPackage (finalAttrs: {
|
||||
blobfile
|
||||
boto3
|
||||
bottle
|
||||
capstone
|
||||
librosa
|
||||
networkx
|
||||
nibabel
|
||||
@@ -188,8 +183,13 @@ buildPythonPackage (finalAttrs: {
|
||||
"test_backward_sum_acc_dtype"
|
||||
"test_failure_27"
|
||||
|
||||
# Fail on some CPUs
|
||||
# RuntimeError: DNNL does not support bf16/f16 backward on the platform with avx2_vnni_2
|
||||
"test_conv2d_fused_half"
|
||||
"test_conv2d_half"
|
||||
|
||||
# Flaky:
|
||||
# AssertionError: 2.1376906810000946 not less than 2.0
|
||||
# AssertionError: 2.1376906810000946 not less than 2.0
|
||||
"test_recursive_pad"
|
||||
|
||||
# Require internet access
|
||||
@@ -206,6 +206,7 @@ buildPythonPackage (finalAttrs: {
|
||||
"test_dataset_is_realized"
|
||||
"test_e2e_big"
|
||||
"test_fetch_small"
|
||||
"test_gguf_load_no_tensor_leak"
|
||||
"test_hevc_parser"
|
||||
"test_huggingface_enet_safetensors"
|
||||
"test_index_mnist"
|
||||
@@ -247,6 +248,7 @@ buildPythonPackage (finalAttrs: {
|
||||
"test_float_cast_to_unsigned_underflow"
|
||||
"test_int8"
|
||||
"test_int8_to_uint16_negative"
|
||||
"test_zero_copy_from_default_to_cpu"
|
||||
|
||||
# RuntimeError: Failed to initialize cpuinfo!
|
||||
"test_conv2d_fused_half"
|
||||
@@ -276,8 +278,9 @@ buildPythonPackage (finalAttrs: {
|
||||
|
||||
disabledTestPaths = [
|
||||
# Require internet access
|
||||
"test/amd/test_llvm.py"
|
||||
"test/amd/test_pdf.py"
|
||||
"test/models/test_mnist.py"
|
||||
"test/models/test_real_world.py"
|
||||
"test/testextra/test_lr_scheduler.py"
|
||||
|
||||
# Files under this directory are not considered as tests by upstream and should be skipped
|
||||
|
||||
@@ -1,37 +1,44 @@
|
||||
diff --git a/tinygrad/runtime/autogen/cuda.py b/tinygrad/runtime/autogen/cuda.py
|
||||
index 061c8d73f..65ec3ffd7 100644
|
||||
index 07b0abd2e..1308edce3 100644
|
||||
--- a/tinygrad/runtime/autogen/cuda.py
|
||||
+++ b/tinygrad/runtime/autogen/cuda.py
|
||||
@@ -1,7 +1,7 @@
|
||||
# mypy: ignore-errors
|
||||
import ctypes
|
||||
from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR
|
||||
-dll = DLL('cuda', 'cuda')
|
||||
+dll = DLL('cuda', '@driverLink@/lib/libcuda.so')
|
||||
cuuint32_t = ctypes.c_uint32
|
||||
cuuint64_t = ctypes.c_uint64
|
||||
CUdeviceptr_v2 = ctypes.c_uint64
|
||||
@@ -4,7 +4,7 @@ import ctypes
|
||||
from typing import Literal, TypeAlias
|
||||
from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR
|
||||
from tinygrad.runtime.support import c
|
||||
-dll = c.DLL('cuda', 'cuda')
|
||||
+dll = c.DLL('cuda', '@driverLink@/lib/libcuda.so')
|
||||
cuuint32_t: TypeAlias = ctypes.c_uint32
|
||||
cuuint64_t: TypeAlias = ctypes.c_uint64
|
||||
CUdeviceptr_v2: TypeAlias = ctypes.c_uint64
|
||||
diff --git a/tinygrad/runtime/autogen/nvrtc.py b/tinygrad/runtime/autogen/nvrtc.py
|
||||
index 88085c45b..90518d403 100644
|
||||
index b8e50c9fb..512d10a31 100644
|
||||
--- a/tinygrad/runtime/autogen/nvrtc.py
|
||||
+++ b/tinygrad/runtime/autogen/nvrtc.py
|
||||
@@ -2,7 +2,7 @@
|
||||
import ctypes
|
||||
from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR
|
||||
@@ -5,7 +5,7 @@ from typing import Literal, TypeAlias
|
||||
from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR
|
||||
from tinygrad.runtime.support import c
|
||||
import sysconfig
|
||||
-dll = DLL('nvrtc', 'nvrtc', f'/usr/local/cuda/targets/{sysconfig.get_config_vars().get("MULTIARCH", "").rsplit("-", 1)[0]}/lib')
|
||||
+dll = DLL('nvrtc','@cuda_nvrtc@/lib/libnvrtc.so')
|
||||
nvrtcResult = CEnum(ctypes.c_uint32)
|
||||
NVRTC_SUCCESS = nvrtcResult.define('NVRTC_SUCCESS', 0)
|
||||
NVRTC_ERROR_OUT_OF_MEMORY = nvrtcResult.define('NVRTC_ERROR_OUT_OF_MEMORY', 1)
|
||||
-dll = c.DLL('nvrtc', 'nvrtc', [f'/{pre}/cuda/targets/{tgt}/lib' for pre in ['opt', 'usr/local'] for tgt in [sysconfig.get_config_vars().get("MULTIARCH", "").rsplit("-", 1)[0], 'sbsa-linux']])
|
||||
+dll = c.DLL('nvrtc', '@cuda_nvrtc@/lib/libnvrtc.so')
|
||||
nvrtcResult: dict[int, str] = {(NVRTC_SUCCESS:=0): 'NVRTC_SUCCESS', (NVRTC_ERROR_OUT_OF_MEMORY:=1): 'NVRTC_ERROR_OUT_OF_MEMORY', (NVRTC_ERROR_PROGRAM_CREATION_FAILURE:=2): 'NVRTC_ERROR_PROGRAM_CREATION_FAILURE', (NVRTC_ERROR_INVALID_INPUT:=3): 'NVRTC_ERROR_INVALID_INPUT', (NVRTC_ERROR_INVALID_PROGRAM:=4): 'NVRTC_ERROR_INVALID_PROGRAM', (NVRTC_ERROR_INVALID_OPTION:=5): 'NVRTC_ERROR_INVALID_OPTION', (NVRTC_ERROR_COMPILATION:=6): 'NVRTC_ERROR_COMPILATION', (NVRTC_ERROR_BUILTIN_OPERATION_FAILURE:=7): 'NVRTC_ERROR_BUILTIN_OPERATION_FAILURE', (NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION:=8): 'NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION', (NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION:=9): 'NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION', (NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID:=10): 'NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID', (NVRTC_ERROR_INTERNAL_ERROR:=11): 'NVRTC_ERROR_INTERNAL_ERROR'}
|
||||
@dll.bind(c.POINTER[ctypes.c_char], ctypes.c_uint32)
|
||||
def nvrtcGetErrorString(result:ctypes.c_uint32) -> c.POINTER[ctypes.c_char]: ...
|
||||
@@ -52,4 +52,4 @@ def nvrtcGetProgramLog(prog:nvrtcProgram, log:c.POINTER[ctypes.c_char]) -> ctype
|
||||
def nvrtcAddNameExpression(prog:nvrtcProgram, name_expression:c.POINTER[ctypes.c_char]) -> ctypes.c_uint32: ...
|
||||
@dll.bind(ctypes.c_uint32, nvrtcProgram, c.POINTER[ctypes.c_char], c.POINTER[c.POINTER[ctypes.c_char]])
|
||||
def nvrtcGetLoweredName(prog:nvrtcProgram, name_expression:c.POINTER[ctypes.c_char], lowered_name:c.POINTER[c.POINTER[ctypes.c_char]]) -> ctypes.c_uint32: ...
|
||||
-__DEPRECATED__ = lambda msg: __attribute__((deprecated(msg))) # type: ignore
|
||||
\ No newline at end of file
|
||||
+__DEPRECATED__ = lambda msg: __attribute__((deprecated(msg))) # type: ignore
|
||||
diff --git a/tinygrad/runtime/support/compiler_cuda.py b/tinygrad/runtime/support/compiler_cuda.py
|
||||
index 8f71a9255..fdbf01bad 100644
|
||||
index 57c40a447..b95e7f91c 100644
|
||||
--- a/tinygrad/runtime/support/compiler_cuda.py
|
||||
+++ b/tinygrad/runtime/support/compiler_cuda.py
|
||||
@@ -43,7 +43,7 @@ def cuda_disassemble(lib:bytes, arch:str):
|
||||
class CUDACompiler(Compiler):
|
||||
def __init__(self, arch:str, cache_key:str="cuda"):
|
||||
self.arch, self.compile_options = arch, [f'--gpu-architecture={arch}']
|
||||
@@ -44,7 +44,7 @@ def cuda_disassemble(lib:bytes, arch:str, ptx=False):
|
||||
class NVRTCCompiler(Compiler):
|
||||
def __init__(self, arch:str, ptx=True, cache_key:str="cuda"):
|
||||
self.ptx, self.arch, self.compile_options = ptx, arch, [f'--gpu-architecture={arch}']
|
||||
- self.compile_options += [f"-I{CUDA_PATH}/include"] if CUDA_PATH else ["-I/usr/local/cuda/include", "-I/usr/include", "-I/opt/cuda/include"]
|
||||
+ self.compile_options += ["-I@cuda_cudart@/include"]
|
||||
nvrtc_check(nvrtc.nvrtcVersion((nvrtcMajor := ctypes.c_int()), (nvrtcMinor := ctypes.c_int())))
|
||||
|
||||
@@ -1,39 +1,53 @@
|
||||
diff --git a/tinygrad/runtime/autogen/libclang.py b/tinygrad/runtime/autogen/libclang.py
|
||||
index dbf22b6f5..4a5a097dc 100644
|
||||
index d6b5c69ec..c153e0453 100644
|
||||
--- a/tinygrad/runtime/autogen/libclang.py
|
||||
+++ b/tinygrad/runtime/autogen/libclang.py
|
||||
@@ -1,7 +1,7 @@
|
||||
# mypy: ignore-errors
|
||||
import ctypes
|
||||
from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR
|
||||
-dll = DLL('libclang', ['clang-20', 'clang'])
|
||||
+dll = DLL('libclang', '@libclang@')
|
||||
CXIndex = ctypes.c_void_p
|
||||
class struct_CXTargetInfoImpl(Struct): pass
|
||||
CXTargetInfo = ctypes.POINTER(struct_CXTargetInfoImpl)
|
||||
@@ -5,7 +5,7 @@ from typing import Literal, TypeAlias
|
||||
from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR
|
||||
from tinygrad.runtime.support import c
|
||||
from tinygrad.helpers import WIN, OSX
|
||||
-dll = c.DLL('libclang', 'C:\\Program Files\\LLVM\\bin\\libclang.dll' if WIN else ['/opt/homebrew/opt/llvm@21/lib/libclang.dylib', '/opt/homebrew/opt/llvm@20/lib/libclang.dylib', '/opt/homebrew/opt/llvm@19/lib/libclang.dylib', '/opt/homebrew/opt/llvm@18/lib/libclang.dylib', '/opt/homebrew/opt/llvm@17/lib/libclang.dylib', '/opt/homebrew/opt/llvm@16/lib/libclang.dylib', '/opt/homebrew/opt/llvm@15/lib/libclang.dylib', '/opt/homebrew/opt/llvm@14/lib/libclang.dylib'] if OSX else ['clang', 'clang-21', 'clang-20', 'clang-19', 'clang-18', 'clang-17', 'clang-16', 'clang-15', 'clang-14'])
|
||||
+dll = c.DLL('libclang', '@libclang@')
|
||||
CXIndex: TypeAlias = ctypes.c_void_p
|
||||
class struct_CXTargetInfoImpl(c.Struct): pass
|
||||
CXTargetInfo: TypeAlias = c.POINTER[struct_CXTargetInfoImpl]
|
||||
@@ -1016,4 +1016,4 @@ CINDEX_VERSION_MAJOR = 0
|
||||
CINDEX_VERSION_MINOR = 64
|
||||
CINDEX_VERSION_ENCODE = lambda major,minor: (((major)*10000) + ((minor)*1)) # type: ignore
|
||||
CINDEX_VERSION = CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
|
||||
-CINDEX_VERSION_STRINGIZE = lambda major,minor: CINDEX_VERSION_STRINGIZE_(major, minor) # type: ignore
|
||||
\ No newline at end of file
|
||||
+CINDEX_VERSION_STRINGIZE = lambda major,minor: CINDEX_VERSION_STRINGIZE_(major, minor) # type: ignore
|
||||
diff --git a/tinygrad/runtime/autogen/llvm.py b/tinygrad/runtime/autogen/llvm.py
|
||||
index 7d05224e7..54204f563 100644
|
||||
index 336010490..f43ca99f1 100644
|
||||
--- a/tinygrad/runtime/autogen/llvm.py
|
||||
+++ b/tinygrad/runtime/autogen/llvm.py
|
||||
@@ -2,7 +2,7 @@
|
||||
import ctypes
|
||||
from tinygrad.runtime.support.c import DLL, Struct, CEnum, _IO, _IOW, _IOR, _IOWR
|
||||
@@ -5,7 +5,7 @@ from typing import Literal, TypeAlias
|
||||
from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR
|
||||
from tinygrad.runtime.support import c
|
||||
from tinygrad.helpers import WIN, OSX
|
||||
-dll = DLL('llvm', 'C:\\Program Files\\LLVM\\bin\\LLVM-C.dll' if WIN else '/opt/homebrew/opt/llvm@20/lib/libLLVM.dylib' if OSX else ['LLVM', 'LLVM-21', 'LLVM-20', 'LLVM-19', 'LLVM-18', 'LLVM-17', 'LLVM-16', 'LLVM-15', 'LLVM-14'])
|
||||
+dll = DLL('llvm', '@libllvm@')
|
||||
intmax_t = ctypes.c_int64
|
||||
try: (imaxabs:=dll.imaxabs).restype, imaxabs.argtypes = intmax_t, [intmax_t]
|
||||
except AttributeError: pass
|
||||
-dll = c.DLL('llvm', 'C:\\Program Files\\LLVM\\bin\\LLVM-C.dll' if WIN else ['/opt/homebrew/opt/llvm@21/lib/libLLVM.dylib', '/opt/homebrew/opt/llvm@20/lib/libLLVM.dylib', '/opt/homebrew/opt/llvm@19/lib/libLLVM.dylib', '/opt/homebrew/opt/llvm@18/lib/libLLVM.dylib', '/opt/homebrew/opt/llvm@17/lib/libLLVM.dylib', '/opt/homebrew/opt/llvm@16/lib/libLLVM.dylib', '/opt/homebrew/opt/llvm@15/lib/libLLVM.dylib', '/opt/homebrew/opt/llvm@14/lib/libLLVM.dylib'] if OSX else ['LLVM', 'LLVM-21', 'LLVM-20', 'LLVM-19', 'LLVM-18', 'LLVM-17', 'LLVM-16', 'LLVM-15', 'LLVM-14'])
|
||||
+dll = c.DLL('llvm', '@libllvm@')
|
||||
intmax_t: TypeAlias = ctypes.c_int64
|
||||
@dll.bind(intmax_t, intmax_t)
|
||||
def imaxabs(__n:intmax_t) -> intmax_t: ...
|
||||
@@ -3188,4 +3188,4 @@ LLVM_BLAKE3_OUT_LEN = 32
|
||||
LLVM_BLAKE3_BLOCK_LEN = 64
|
||||
LLVM_BLAKE3_CHUNK_LEN = 1024
|
||||
LLVM_BLAKE3_MAX_DEPTH = 54
|
||||
-LTO_API_VERSION = 29
|
||||
\ No newline at end of file
|
||||
+LTO_API_VERSION = 29
|
||||
diff --git a/tinygrad/runtime/support/compiler_cpu.py b/tinygrad/runtime/support/compiler_cpu.py
|
||||
index 8b11f3af8..d8190fac3 100644
|
||||
index 5b6121ebb..18f66f8f7 100644
|
||||
--- a/tinygrad/runtime/support/compiler_cpu.py
|
||||
+++ b/tinygrad/runtime/support/compiler_cpu.py
|
||||
@@ -15,7 +15,7 @@ class ClangJITCompiler(Compiler):
|
||||
arch = {'x86_64': '-march=native', 'AMD64': '-march=native', 'riscv64': '-march=rv64g'}.get(platform.machine(), "-mcpu=native")
|
||||
args = [arch, f'--target={target}-none-unknown-elf', '-O2', '-fPIC', '-ffreestanding', '-fno-math-errno', '-nostdlib', '-fno-ident']
|
||||
arch_args = ['-ffixed-x18'] if target == 'arm64' else []
|
||||
- obj = subprocess.check_output([getenv("CC", 'clang'), '-c', '-x', 'c', *args, *arch_args, '-', '-o', '-'], input=src.encode('utf-8'))
|
||||
+ obj = subprocess.check_output(["@clang@", '-c', '-x', 'c', *args, *arch_args, '-', '-o', '-'], input=src.encode('utf-8'))
|
||||
return jit_loader(obj)
|
||||
@@ -20,7 +20,7 @@ class ClangJITCompiler(Compiler):
|
||||
def compile_to_obj(self, src:str) -> bytes:
|
||||
"""Compile C source to ELF object file (before linking)."""
|
||||
# -fno-math-errno is required for __builtin_sqrt to become an instruction instead of a function call
|
||||
- return subprocess.check_output([getenv("CC", 'clang'), '-c', '-x', 'c', '-O2', '-fPIC', '-ffreestanding', '-fno-math-errno', '-nostdlib',
|
||||
+ return subprocess.check_output(["@clang@", '-c', '-x', 'c', '-O2', '-fPIC', '-ffreestanding', '-fno-math-errno', '-nostdlib',
|
||||
'-fno-ident', f'--target={self.arch}-none-unknown-elf', *self.args, '-', '-o', '-'], input=src.encode('utf-8'))
|
||||
|
||||
def disassemble(self, lib:bytes): return capstone_flatdump(lib)
|
||||
def compile(self, src:str) -> bytes: return jit_loader(self.compile_to_obj(src))
|
||||
|
||||
Reference in New Issue
Block a user