Skip to content

Instantly share code, notes, and snippets.

@shawwn
shawwn / _var_folders_8f_5fdgh9l120lfbrs2t8plgr7r0000gn_T_main-5e2147.sh
Created May 10, 2022 06:14
/var/folders/8f/5fdgh9l120lfbrs2t8plgr7r0000gn/T/main-5e2147.sh
# Crash reproducer for clang version 15.0.0 (https://github.com/llvm/llvm-project 53069de6aa4ce1e130aa58fc36b4be08a53d3aba)
# Driver args: "--driver-mode=g++" "-g" "-arch" "arm64" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk" "-mmacosx-version-min=11.6" "-std=gnu++20" "-o" "CMakeFiles/sg20crash.dir/main.cpp.o" "-c" "/Users/spresser/ml/sg20crash/main.cpp"
# Original command: "/Users/spresser/ml/llvm-project/build/bin/clang-15" "-cc1" "-triple" "arm64-apple-macosx11.6.0" "-Wundef-prefix=TARGET_OS_" "-Werror=undef-prefix" "-Wdeprecated-objc-isa-usage" "-Werror=deprecated-objc-isa-usage" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "main.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=non-leaf" "-ffp-contract=on" "-fno-rounding-math" "-funwind-tables=2" "-target-sdk-version=12.0" "-fcompatibility-qualified-id-block-type-checking" "-fvisibility-inlines-hidden-stati
@shawwn
shawwn / _var_folders_8f_5fdgh9l120lfbrs2t8plgr7r0000gn_T_main-5e2147.cpp
Created May 10, 2022 06:12
/var/folders/8f/5fdgh9l120lfbrs2t8plgr7r0000gn/T/main-5e2147.cpp
This file has been truncated, but you can view the full file.
# 1 "<built-in>"
# 1 "/Users/spresser/ml/sg20crash/main.cpp"
#if 0 /* expanded by -frewrite-includes */
#include <iostream>
#endif /* expanded by -frewrite-includes */
# 1 "/Users/spresser/ml/sg20crash/main.cpp"
# 1 "/Users/spresser/ml/llvm-project/build/bin/../include/c++/v1/iostream" 1 3
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
what's the best number?
<vibhav> <zequence> the one you want
<holstein> i just try and use whatever is easy
<holstein> and i usually just use the internal mic for everything
<holstein> but, i think i'll poke around in audacity
<holstein> just to see what it can do
<vibhav> <holstein> the audacity thing is for sound recording
<holstein> its got a sound playback thing too
<holstein> with a few effects
<vibhav> <holstein> I know
# Some cliff's notes on installing empy on a new machine. Haven't tested it yet.
pip3 install userpath
# install y
git clone https://github.com/shawwn/y ~/ml/y
# add y to PATH
userpath append ~/ml/y/bin
exec $SHELL
from typing import NamedTuple, Callable
class Primitive(NamedTuple):
name: str
add_p = Primitive('add')
mul_p = Primitive('mul')
neg_p = Primitive("neg")
sin_p = Primitive("sin")
cos_p = Primitive("cos")
@shawwn
shawwn / gist:d97b6b948d58111b51226f2012cbee30
Created November 11, 2021 17:17
How to dump XLA HLO pipelines in tensorflow
`XLA_FLAGS=--xla_dump_to=/tmp/xladump --xla_dump_hlo_pass_re=.*`
@shawwn
shawwn / What happens when you allocate a JAX tensor on a TPU.md
Last active April 15, 2023 04:11
JAX C++ stack trace walkthrough for TpuExecutor_Allocate
@shawwn
shawwn / libtpujesus.c
Created November 2, 2021 06:41
An example of building a custom "stub" libtpu.so library, with the ultimate goal of implementing your own "TPU" device for JAX.
/* libtpujesus.c
Copyright 2021 Shawn Presser
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@shawwn
shawwn / gist:2591c555ab918020d6be2ee121000c23
Created November 2, 2021 06:28
libtpujesus.so example output
/Users/spresser/ml/jax/jax/_src/lib/__init__.py:32: UserWarning: JAX on Mac ARM machines is experimental and minimally tested. Please see https://github.com/google/jax/issues/5501 in the event of problems.
warnings.warn("JAX on Mac ARM machines is experimental and minimally tested. "
2021-11-02 01:28:09.661877: I external/org_tensorflow/tensorflow/core/tpu/tpu_library_init_fns.inc:100] InitializeTpuStructFns...
2021-11-02 01:28:09.661949: I external/org_tensorflow/tensorflow/core/tpu/tpu_library_init_fns.inc:14] TFTPU_SET_FN(ops_api_fn, ...) starting...
2021-11-02 01:28:09.661994: I external/org_tensorflow/tensorflow/core/tpu/tpu_library_init_fns.inc:94] TFTPU_SET_FN(ops_api_fn, ...) finished
2021-11-02 01:28:09.661997: I external/org_tensorflow/tensorflow/core/tpu/tpu_executor_init_fns.inc:6] TFTPU_SET_FN(executor_fn, ...) starting...
2021-11-02 01:28:09.662064: I external/org_tensorflow/tensorflow/core/tpu/tpu_executor_init_fns.inc:163] TFTPU_SET_FN(executor_fn, ...) finished
2021-11-02 01:28:09.662067:
@shawwn
shawwn / jax_bazel_caching.diff
Created November 2, 2021 03:56
A diff to enable bazel caching. I have no idea why it works, or what the implications are of the various commands. In fact, I have no idea where I even got these commands from. Buyer beware.
diff --git a/build/build.py b/build/build.py
index 2a812632..a78b1d03 100755
--- a/build/build.py
+++ b/build/build.py
@@ -507,6 +507,9 @@ def main():
config_args += ["--config=rocm"]
config_args += ["--config=nonccl"]
+ # don't rebuild everything every time.
+ config_args.extend("--action_env=PATH --remote_accept_cached=true --spawn_strategy=standalone --remote_local_fallback=false --remote_timeout=600".split())