Skip to content

Instantly share code, notes, and snippets.

class ApplyCudaGraphs(torch.fx.Interpreter):
def call_module(self, target, args, kwargs):
assert not kwargs
submod = self.module.get_submodule(target)
self.module.delete_submodule(target)
mutated_inputs = FindInputMutations(submod)(*args)
self.module.add_submodule(target, CudaGraphModule(submod, mutated_inputs))
r = super().call_module(target, args, kwargs)
return r
1 aten._pack_padded_sequence.default
1 aten.bitwise_xor.Tensor
1 aten.div_.Tensor
1 aten.empty_like.default
1 aten.fmod.Scalar
1 aten.ge.Tensor
1 aten.le.Tensor
1 aten.logical_not.default
1 aten.mse_loss.default
1 aten.randperm.default

How to record data from Python fast, if pickle is too slow

  • JSON xxxxxx
    • jq is pretty fast
    • Serde for rust level
    • nb: use json lines
  • CSV xxxx
  • use pickle anyway xxx
    • plus compression
  • python-pickle in Haskell
@ezyang
ezyang / gist:2fe72ebb73a2c4c348bbe2cac1cbcd32
Created January 22, 2022 01:38
CSCI-UA.490: Special Topics in Programming Languages - 2022 syllabus
Mon, Jan 24 - Introduction / JavaScript
Wed, Jan 26 - Haskell Basics
Mon, Jan 31 - Haskell Basics 2 (HW1 basic)
Wed, Jan 2 - Algebraic Data Types / QuickCheck
Mon, Jan 7 - Lambda Calculus (HW2 calculator)
Wed, Feb 9 - Flex Slot for Haskell
Mon, Feb 14 - Type Classes (HW3 lambda)
ezyang-mbp:labs ezyang$ cat a.kk
fun reuse( g : list<int> -> int, x : list<int>) : (int, int) {
(match(x) {
Nil() -> 0
Cons(_, _) -> 1
}
, g(x))
}
ezyang-mbp:labs ezyang$ koka -O2 -l -c --showcore a.kk
compile: a.kk
ezyang-mbp:labs ezyang$ cat a.kk
fun f(x: list<int>) : int {
match(x) {
Nil() -> 0
Cons(_, _) -> 1
}
}
fun reuse( g : list<int> -> int, x : list<int>) : (int, int) {
(f(x), g(x))
ezyang-mbp:labs ezyang$ cat a.kk
fun f(x: list<int>) : int {
length(x)
}
fun reuse( g : list<int> -> int, x : list<int>) : (int, int) {
(f(x), g(x))
}
ezyang-mbp:labs ezyang$ koka -O2 -l -c --showcore a.kk
compile: a.kk
from dataclasses import dataclass
from typing import List, Tuple, Union, Dict, Iterator, Optional
import sys
import itertools
Id = int
class UnionFind:
parents: List[Id]
% Solution to https://teammatehunt.com/puzzles/icebreaker
#script (python)
def main(ctl):
ctl.ground([("base", [])])
seen = set()
with ctl.solve(yield_=True) as h:
for m in h:
terms = m.symbols(shown=True)
terms.sort()
person(alice; bob; carol; david).
number(alice, 2).
number(bob, 3).
number(carol, 5).
number(david, 7).
distinct(A, B, C, D)
:- number(A, NA), number(B, NB), number(C, NC), number(D, ND),
NA * NB * NC * ND = 210.