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
@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 April 17, 2025 01:26 — 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

[email protected]

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.

@mra1385
mra1385 / S&P500vsRealGDP.ipynb
Created February 6, 2018 04:11
S&P 500 Returns vs. Real GDP Growth
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@LucaCappelletti94
LucaCappelletti94 / Firing up LaTex on macOS.md
Last active March 24, 2025 14:43
Firing up Latex on macOS

Firing up LaTex on macOS 🔥

As I'm writing this small tutorial, I assume you've read my previous one about setting up macOS, so if for any tool I'll use without explanation, look to that other article.

MacTex

The full version IS NOT MANDATORY, as in the tutorial that follows I installed the smaller version of MacTeX and proceded installing every needed dependency. Installing the complete package is about ~3.5GB of download and ~5GB on disk, the smaller one is just about 80MBs.

Click here to download the complete version or here to download the smaller version.

Gnuplot