Skip to content

Instantly share code, notes, and snippets.

View ToluClassics's full-sized avatar
🏠
Working from home

Ogundepo Odunayo ToluClassics

🏠
Working from home
View GitHub Profile
@willccbb
willccbb / grpo_demo.py
Last active September 18, 2025 08:22
GRPO Llama-1B
# train_grpo.py
#
# See https://github.com/willccbb/verifiers for ongoing developments
#
"""
citation:
@misc{brown2025grpodemo,
title={Granular Format Rewards for Eliciting Mathematical Reasoning Capabilities in Small Language Models},
author={Brown, William},
@fpaupier
fpaupier / vllm_init.sh
Created May 15, 2024 14:48
Initializes a GPU machine to start a vLLM server
#!/bin/bash
# This script initializes a GPU machine to start a vLLM server
# Ensure the script is run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
@younesbelkada
younesbelkada / bench-fa-2.py
Last active November 25, 2024 16:54
Benchmark FA2 + transformers integration
import torch
import os
import argparse
import matplotlib.pyplot as plt
from tqdm import tqdm
from transformers import AutoModelForCausalLM, AutoTokenizer
import seaborn as sns
def get_parser():
@mattiasarro
mattiasarro / rwkv.py
Last active March 30, 2025 15:06
RWKV MVP
# Taken from https://johanwind.github.io/2023/03/23/rwkv_details.html.
# I've added additional comments restructured it a tiny bit, which makes it clearer for me.
import numpy as np
from torch import load as torch_load # Only for loading the model weights
from tokenizers import Tokenizer
exp = np.exp
layer_norm = lambda x, w, b : (x - np.mean(x)) / np.std(x) * w + b
sigmoid = lambda x : 1/(1 + exp(-x))
"""
Download the latest wiki dump files for a language,
If from_date is passed, the latest before that date is downloaded
"""
import requests
from datetime import datetime
from datetime import timedelta
from string import Template
from tqdm import tqdm
@ToluClassics
ToluClassics / knn_elasticsearch.py
Last active February 17, 2023 08:47
KNN Nearest Neighbour Search in ElasticSearch
import os
import json
from tqdm import tqdm
import torch
import torch.nn.functional as F
from transformers import AutoTokenizer, AutoModel
from elasticsearch import Elasticsearch
class JsonlCollectionIterator:
@JosephCatrambone
JosephCatrambone / lib.rs
Last active March 8, 2024 01:32
Embedding GPT-2 in Godot via Rust
mod ml_thread;
use gdnative::prelude::{godot_print, methods, Method, NativeClass, Node as GDNode, InitHandle, godot_init};
use ml_thread::start_language_model_thread;
use std::sync::mpsc::{channel, Receiver, RecvError, Sender, SendError};
const MAX_INPUT_LENGTH: usize = 512;
const BATCH_SIZE: usize = 1;
@skye
skye / tpu_topology_env_vars.py
Last active September 4, 2025 15:32
You can use these environment variables to run a Python process on a subset of the TPU cores on a Cloud TPU VM. This allows running multiple TPU processes at the same time, since only one process can access a given TPU chip at a time. Note that on TPU v2 and v3, 1 TPU chip = 2 TpuDevice as reported by `jax.devices()` (8 devices total). On v4, 1 …
# ==== Non-communicating processes
# 4x 1 chip per process:
os.environ["TPU_CHIPS_PER_PROCESS_BOUNDS"] = "1,1,1"
os.environ["TPU_PROCESS_BOUNDS"] = "1,1,1"
# Different per process:
os.environ["TPU_VISIBLE_DEVICES"] = "0" # "1", "2", "3"
# 1-liner for bash: TPU_CHIPS_PER_PROCESS_BOUNDS=1,1,1 TPU_PROCESS_BOUNDS=1,1,1 TPU_VISIBLE_DEVICES=0 TPU_MESH_CONTROLLER_ADDRESS=localhost:8476 TPU_MESH_CONTROLLER_PORT=8476
@zhensongren
zhensongren / uninstall_python3.MD
Last active February 27, 2025 03:38
How to uninstall python3 from Ubuntu

To list all python versions in default locations

ls /usr/bin/python*

To remove just python3 package

sudo apt-get remove python3.5

plus it's dependent packages

sudo apt-get remove --auto-remove python3.5

plus configuration and/or data files of python3

sudo apt-get purge python3.5

@yang-zhang
yang-zhang / binary_cross_entropy_with_logits.ipynb
Created October 16, 2018 20:46
binary cross entropy implementation in pytorch
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.