Skip to content

Instantly share code, notes, and snippets.

@willccbb
willccbb / grpo_demo.py
Last active November 2, 2025 13:27
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},
@MekkCyber
MekkCyber / kernel.py
Created August 29, 2024 14:24
Kernel for matmul while unpacking int2 weights
import torch
import triton
import triton.language as tl
def unpack_weights(packed: torch.Tensor, bits: int = 2) -> torch.Tensor:
values_per_item = 8 // bits
packed_shape = packed.shape
if len(packed_shape) == 1:
# pip install "distilabel[vllm]>=1.1.1"
# pip install flash-attn --no-build-isolation
# huggingface-cli login
import time
from distilabel.llms import vLLM
from distilabel.pipeline import Pipeline
from distilabel.steps import KeepColumns, LoadHubDataset
from distilabel.steps.tasks import PrometheusEval
// npm i express axios && node ./oailogger.js
const express = require('express');
const axios = require('axios');
const bodyParser = require('body-parser');
const stream = require('stream');
const { promisify } = require('util');
const fs = require('fs');
const logStream = fs.createWriteStream('logs.jsonl', { flags: 'a' });
const app = express();
@thistleknot
thistleknot / long_tiny_mistral_2-2b_blank.py
Last active January 8, 2024 02:47
long mistral 2-2b
import json
import argparse
from transformers import MistralConfig, AutoModelForCausalLM
import torch
import sys
import os
def calculate_model_parameters(config):
# Load the model configuration from the JSON file
# Extract the necessary values from the configuration
@ChrisHayduk
ChrisHayduk / merge_qlora_with_quantized_model.py
Last active September 27, 2025 08:22
Merging QLoRA weights with quantized model
"""
The code below combines approaches published by both @eugene-yh and @jinyongyoo on Github.
Thanks for the contributions guys!
"""
import torch
import peft
@NaxAlpha
NaxAlpha / long_gpt.py
Last active July 23, 2024 13:07
Training script for LongGPT; Fine-tunes GPT-2 (335M) on The Pile Dataset with a context size of 8k tokens. (requires > 16GB RAM)
import time
from contextlib import suppress
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torch.backends.cuda as cuda
from torch.utils.data import DataLoader, IterableDataset
@chadgroom
chadgroom / pystfp_paramiko_ecdsa.py
Last active April 2, 2025 16:43
Correct way to load ecdsa keys with paramiko/pysftp with OpenSSH.. Solves issue: https://github.com/paramiko/paramiko/issues/350
#!/usr/bin/env python3
# This error is caused by using `paramiko.RSA()` to manually load an ecdsa key from your know_hosts file or for manually loading as bytes.
# Using: `key = paramiko.AgentKey()` instead seemingly detects the key type automatically and accepts the ecdsa-sha2-nistp256 key just fine.
# EXAMPLE:
import pysftp
from base64 import decodebytes
import paramiko