Skip to content

Instantly share code, notes, and snippets.

View KeAWang's full-sized avatar

Alex Wang KeAWang

View GitHub Profile
import numpy as np
import os
import time
import warnings
import pickle
# from accimage import Image
from PIL import Image
import io
try:
@rwightman
rwightman / image_folder_tar.py
Created July 24, 2019 05:01
PyTorch ImageFolder style dataset for reading directly from tarfile
import torch.utils.data as data
import os
import re
import torch
import tarfile
from PIL import Image
IMG_EXTENSIONS = ['.png', '.jpg', '.jpeg']
@BioSciEconomist
BioSciEconomist / ex VAR.py
Created February 23, 2021 18:05
Example VAR model for python
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex VAR.py
# | DATE: 2/23/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: source: https://www.machinelearningplus.com/time-series/vector-autoregression-examples-python/
# *----------------------------------------------------------------
# see also my blog post: http://econometricsense.blogspot.com/2011/05/vector-autoregressions-and-bayesian.html
import torch
import torch.utils.dlpack
import jax
import jax.dlpack
# A generic mechanism for turning a JAX function into a PyTorch function.
def j2t(x_jax):
x_torch = torch.utils.dlpack.from_dlpack(jax.dlpack.to_dlpack(x_jax))
return x_torch
from __future__ import annotations
from contextlib import contextmanager
from typing import NamedTuple, Callable, Optional, Any
import numpy as np
Array = Any
class Node(NamedTuple):
vjp: Optional[Callable]
parents: List[Node]
import torch
from torch.utils._python_dispatch import TorchDispatchMode
from torch.utils._pytree import tree_map
import itertools
# cribbed from https://github.com/albanD/subclass_zoo/blob/main/logging_mode.py
class Lit:
def __init__(self, s):
self.s = s
@Chillee
Chillee / 1-pw_op_fusion.py
Last active September 30, 2025 14:00
PT 2.0 Benchmarks
import torch
import torch._inductor.config
import time
torch._inductor.config.triton.cudagraphs = False
torch.set_float32_matmul_precision('high')
def bench(f, name=None, iters=100, warmup=5, display=True, profile=False):
for _ in range(warmup):
f()
@VictorTaelin
VictorTaelin / gpt4_abbreviations.md
Last active August 12, 2025 23:31
Notes on the GPT-4 abbreviations tweet

Notes on this tweet.

  • The screenshots were taken on different sessions.

  • The entire sessions are included on the screenshots.

  • I lost the original prompts, so I had to reconstruct them, and still managed to reproduce.

  • The "compressed" version is actually longer! Emojis and abbreviations use more tokens than common words.

Hermes is a piece of non-deterministic software that performs informal reasoning steps in collaboration with the user. Each step is prepended with some syntax to tell the software what it should be/do. Like so:
HERO [Albert Einstein, Op: Objection], That's not correct. Nothing can travel faster than the speed of light.
Hermes allows the user to call upon any hero in history or myth and use them as a reasoning step. Or have them talk to each other about something. The user can freely mix together their cognition and the simulated cognition of other minds. New operations and syntax can be created at will and Hermes will do its best to respond to and use them.
The user writes down their own cognition as a series of subagents, like so:
USER [A: EMPATHY], I completely agree! It's wonderful. Like the difference between the true duet of Scarborough Fair and the nonsense one.
USER [A: 343], It's funny. In order to save the world rationalists finetune the human priors out of themselves, humans are dreamers not max