Skip to content

Instantly share code, notes, and snippets.

View rreece's full-sized avatar
🙈
doing things

Ryan Reece rreece

🙈
doing things
View GitHub Profile
@karpathy
karpathy / microgpt.py
Last active February 15, 2026 20:42
microgpt
"""
The most atomic way to train and inference a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@emschwartz
emschwartz / README.md
Last active February 15, 2026 19:45
The Most Popular Blogs of Hacker News in 2025

This is an OPML version of the HN Popularity Contest results for 2025, for importing into RSS feed readers.

Plug: if you want to find content related to your interests from thousands of obscure blogs and noisy sources like HN Newest, check out Scour. It's a free, personalized content feed I work on where you define your interests in your own words and it ranks content based on how closely related it is to those topics.

@rasbt
rasbt / llama-vs-gemma.py
Created March 13, 2025 15:51
Compute memory usage for various LLMs like Gemma, Llama, etc.
# Sebastian Raschka 2025
#
#
# Usage:
# python llama-vs-gemma.py \
# --auth_token hf_... \
# --model_name meta-llama/Llama-3.2-1B \
# --prompt medium
import argparse
@awni
awni / l3min.py
Last active January 25, 2025 21:30
A minimal, fast implementation of Llama 3.1 in MLX.
"""
A minimal, fast example generating text with Llama 3.1 in MLX.
To run, install the requirements:
pip install -U mlx transformers fire
Then generate text with:
python l3min.py "How tall is K2?"
@kratsg
kratsg / ATLASSUSY_ReproducibleSummaryPlots.ipynb
Last active December 7, 2023 10:59
ATLAS SUSY Reproducible Summary Plots
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pyhf
pyhf.set_backend('pytorch', 'minuit')
nSig = 4.166929245
errSig = 4.166929245
nBkg = 0.11
errBkgUp = 0.20
errBkgDown = 0.11
model_json = {
@ebarsoum
ebarsoum / gpu_memory_overhead_pycuda.py
Created October 26, 2019 00:24
GPU memory overhead for PyCUDA
import numpy as np
from pynvml.smi import nvidia_smi
import pycuda.gpuarray as ga
import pycuda.driver as cuda
nvsmi = nvidia_smi.getInstance()
def getGPUMemoryUsage(gpu_index=0):
return nvsmi.DeviceQuery("memory.used")["gpu"][gpu_index]['fb_memory_usage']['used']
@johnhw
johnhw / umap_sparse.py
Last active May 11, 2025 07:18
1 million prime UMAP layout
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
@HarshTrivedi
HarshTrivedi / pad_packed_demo.py
Last active November 7, 2025 15:47 — forked from Tushar-N/pad_packed_demo.py
Minimal tutorial on packing (pack_padded_sequence) and unpacking (pad_packed_sequence) sequences in pytorch.
import torch
from torch import LongTensor
from torch.nn import Embedding, LSTM
from torch.autograd import Variable
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
## We want to run LSTM on a batch of 3 character sequences ['long_str', 'tiny', 'medium']
#
# Step 1: Construct Vocabulary
# Step 2: Load indexed data (list of instances, where each instance is list of character indices)
@blepfo
blepfo / TensorFlow-Best-Practices-Q1-2018.md
Last active December 13, 2018 10:22
TensorFlow Best Practices as of Q1 2018

TensorFlow Best Practices as of Q1 2018

By Adam Anderson

adam.b.anderson.96@gmail.com

Preface

This write-up assumes you have an general understanding of the TensorFlow programming model, but maybe you haven't kept up to date with the latest library features/standard practices.