Skip to content

Instantly share code, notes, and snippets.

@cat-state
cat-state / ln_relu_expm1_log.txt
Created February 6, 2025 14:45
nanogpt slowrun
import os
import sys
with open(sys.argv[0]) as f:
code = f.read() # read the code of this file ASAP, for logging
import uuid
import time
import copy
from dataclasses import dataclass
from functools import lru_cache
from pathlib import Path
import torch
E = 5e6 # Young's modulus
nu = 0.4 # Poisson's ratio
mu = E / (2 * (1 + nu)) # Shear modulus
lambda_ = (E * nu) / ((1 + nu) * (1 - 2 * nu)) # Lame's first parameter
rest_x = torch.randn(N, 3).cuda()
rest_x = rest_x / rest_x.norm(dim=-1, keepdim=True)
rest_x = (rest_x - rest_x.mean(dim=0))
@cat-state
cat-state / moratten
Created October 16, 2024 23:24
Morton Code Attention
import torch
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
def quantize_coords(coords: torch.Tensor, bits: int = 21):
max_int = (1 << bits) - 1
coords = coords.clamp(0, 1)
return (coords * max_int).long()
@cat-state
cat-state / README.md
Created April 28, 2023 19:42
gradio + cluster inference

to use

HF_API_TOKEN=<token> sbatch hf-infer.sbatch

then run

HF_API_TOKEN=<token> HOSTNAME=<hostname of infernce server> python gradio-tgl.py

setup env following hf inference server instructions but chance /usr/local to path to conda env instead.

@cat-state
cat-state / trlx-nemo.sh
Last active January 16, 2023 19:20
`sbatch trlx-nemo.sh`. Note that you have to edit `num_nodes` in the model yml to match the number set in the this file
#!/bin/bash
#SBATCH --job-name=nemo-trlx
#SBATCH --partition=a100-cu117
#SBATCH --nodes=4
#SBATCH --gres=gpu:8
#SBATCH --ntasks-per-node=8
#SBATCH --output="%x.out"
#SBATCH --signal=B:INT@60
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cat-state
cat-state / optical-nn.md
Created September 8, 2022 18:56
optical nn

optical-nn

This repository for organising information as pertaining to the DIY construction of a non-linear optical neural network.

Module

          +------------SINGLE LAYER+--------------------------+
          |                                                   |
          |     +-----+ +--------------+ +-----+ +-------+    |
 +-----&gt; | W1 | | NON | | W2 | | μLENS | |