mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-06-13 00:15:35 +08:00
limit pickled objects [run_process_replay] (#5154)
* limit pickled objects * delete uop from the list * debug metal * need self.opts for TC * dont need device * [run_process_replay] * minor
This commit is contained in:
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
@@ -37,12 +37,11 @@ jobs:
|
||||
COMMIT_MESSAGE=$(printf '%q' "$RAW_COMMIT_MESSAGE")
|
||||
RAW_PR_TITLE="${{ github.event.pull_request.title }}"
|
||||
PR_TITLE=$(printf '%q' "$RAW_PR_TITLE")
|
||||
if { echo "$COMMIT_MESSAGE" | grep -q "run_process_replay" || \
|
||||
[ "${{ github.event.inputs.run_process_replay }}" == "true" ] || \
|
||||
echo "$PR_TITLE" | grep -q "run_process_replay"; } && [ "$GITHUB_REF_NAME" != "master" ]; then
|
||||
|
||||
if { echo "$COMMIT_MESSAGE" | grep -q "run_process_replay" || echo "$PR_TITLE" | grep -q "run_process_replay" || [ "${{ github.event.inputs.run_process_replay }}" = "true" ]; } && [ "$GITHUB_REF_NAME" != "master" ]; then
|
||||
echo "RUN_PROCESS_REPLAY=1" >> $GITHUB_OUTPUT
|
||||
echo "enabled process replay"
|
||||
if echo "$COMMIT_MESSAGE" | grep -q "no_assert"; then
|
||||
if { echo "$COMMIT_MESSAGE" | grep -q "no_assert" || echo "$PR_TITLE" | grep -q "no_assert"; }; then
|
||||
echo "ASSERT_PROCESS_REPLAY=0" >> $GITHUB_OUTPUT
|
||||
echo "running process replay in diff-only mode"
|
||||
else
|
||||
|
||||
14
test/external/process_replay/process_replay.py
vendored
14
test/external/process_replay/process_replay.py
vendored
@@ -2,7 +2,7 @@
|
||||
# compare kernels created by HEAD against master
|
||||
import difflib, pickle
|
||||
from tinygrad.codegen.linearizer import Linearizer
|
||||
from tinygrad.helpers import colored, db_connection, VERSION, getenv, to_function_name, tqdm
|
||||
from tinygrad.helpers import colored, db_connection, VERSION, getenv, tqdm
|
||||
|
||||
page_size = 100
|
||||
conn = db_connection()
|
||||
@@ -11,15 +11,15 @@ row_count = cur.execute(f"select count(*) from 'process_replay_{VERSION}'").fetc
|
||||
for offset in tqdm(range(0, row_count, page_size)):
|
||||
cur.execute(f"SELECT val FROM 'process_replay_{VERSION}' LIMIT ? OFFSET ?", (page_size, offset))
|
||||
for row in cur.fetchall():
|
||||
compare_k, compare_src = pickle.loads(row[0])
|
||||
k = Linearizer(*compare_k.ast, opts=compare_k.opts)
|
||||
for opt in compare_k.applied_opts: k.apply_opt(opt)
|
||||
good_src = k.opts.render(to_function_name(compare_k.name), k.linearize().uops)
|
||||
ast, opts, applied_opts, name, compare_src = pickle.loads(row[0])
|
||||
k = Linearizer(*ast, opts=opts)
|
||||
for opt in applied_opts: k.apply_opt(opt)
|
||||
good_src = k.opts.render(name, k.linearize().uops)
|
||||
try: assert compare_src == good_src
|
||||
except AssertionError as e:
|
||||
print("PROCESS REPLAY DETECTED CHANGE")
|
||||
print(compare_k.ast)
|
||||
print(compare_k.applied_opts)
|
||||
print(ast)
|
||||
print(applied_opts)
|
||||
diff = list(difflib.unified_diff(good_src.splitlines(), compare_src.splitlines()))
|
||||
for line in diff:
|
||||
print(colored(line, "red" if line.startswith("-") else "green" if line.startswith("+") else None))
|
||||
|
||||
@@ -519,8 +519,8 @@ class Linearizer(Kernel):
|
||||
def to_program(self) -> Program:
|
||||
self.linearize()
|
||||
info = get_lazyop_info(self.ast[0])
|
||||
src = self.opts.render(to_function_name(self.name), self.uops)
|
||||
if getenv("RUN_PROCESS_REPLAY"): diskcache_put("process_replay", id(self), (self, src))
|
||||
src = self.opts.render(name:=to_function_name(self.name), self.uops)
|
||||
if getenv("RUN_PROCESS_REPLAY"): diskcache_put("process_replay", id(self), (self.ast, self.opts, self.applied_opts, name, src))
|
||||
ops, mem = self.uops.flops_mem()
|
||||
run_count = prod((self.global_size if self.global_size else []) + (self.local_size if self.local_size else []))
|
||||
# NOTE: we use min here to ignore the indexing FLOPS
|
||||
|
||||
Reference in New Issue
Block a user