Skip to content

Instantly share code, notes, and snippets.

@kalomaze
kalomaze / gist:37c70e022cb1e9428ebb1ee7a4b52275
Last active March 2, 2025 16:56
GRPO Reinforcement Learning - 7b GSM8k on 8xH100 / 8xA100
# the "verifiers" repository is a clean implementation of templated GRPO reinforcement learning training environments
# this is a generic set of "install from scratch" commands complete with a deepspeed z3 config that i have been using when i spin up nodes
# it will run on the gsm8k example w/ default batch size & generation size (8), and the 8th GPU is used for vllm generations
# qwen 14b full finetuning will run on this configuration too without LoRA or CUDA OOM, at least for the gsm8k task's context sizes + generation lengths
# hyperparameters are controlled by `verifiers/utils/config_utils.py`; i have been preferring extreme grad clipping (between 0.001 and 0.01) and low beta (under 0.01)
# NOTE FEB 27: examples have moved into `verifiers/examples` not `/examples`
cd /root
mkdir boom
# train_grpo.py
from typing import *
import re
import torch
from datasets import load_dataset, Dataset, load_from_disk
from transformers import AutoTokenizer, AutoModelForCausalLM, TrainingArguments
from peft import LoraConfig
from trl import GRPOConfig, GRPOTrainer, TrlParser
from dataclasses import dataclass, field
@abacaj
abacaj / train.py
Last active February 25, 2025 22:52
extending GRPOTrainer to run gsm8k eval during training
import tqdm
import numpy as np
import torch
import torch.distributed as dist
import transformers
def extract_xml_answer(text: str) -> str:
answer = text.split("<final_answer>")[-1]
answer = answer.split("</final_answer>")[0]
return answer.strip()
@willccbb
willccbb / grpo_demo.py
Last active March 3, 2025 09:30
GRPO Llama-1B
# train_grpo.py
#
# See https://github.com/willccbb/verifiers for ongoing developments
#
import re
import torch
from datasets import load_dataset, Dataset
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import LoraConfig
from trl import GRPOConfig, GRPOTrainer
@devinschumacher
devinschumacher / cloud-gpus.md
Last active March 2, 2025 12:10
Cloud GPUs // The Best Servers, Services & Providers [RANKED!]

Cloud GPUs: Servers, Providers & Everything You Would Ever Need

Your company's GPU computing strategy is essential whether you engage in 3D visualization, machine learning, AI, or any other form of intensive computing.

There was a time when businesses had to wait for long periods of time while deep learning models were being trained and processed. Because it was time-consuming, costly, and created space and organization problems, it reduced their output.

This problem has been resolved in the most recent GPU designs. Because of their high parallel processing efficiency, they are well-suited for handling large calculations and speeding up the training of your AI models.

When it comes to deep learning, good Cloud GPUs can speed up the training of neural networks by a factor of 250 compared to CPUs, and the latest generation of cloud GPUs is reshaping data science and other emerging technologies by delivering even greater performance

@AnirudhDagar
AnirudhDagar / pyg_setup.sh
Created April 17, 2020 08:38
PyTorch Geometric Setup Script for Mac OS X
# Works on OS X, with conda installed.
# Create conda environment for PyTorch Geometric
echo "Creating pyg environment"
conda create -n pyg python=3.6
echo "Activate pyg Env"
source activate pyg
# PyTorch Conda Installation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hiroara
hiroara / 三重県.json
Last active September 4, 2024 14:23
Japan Prefectures Geojson
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@leommoore
leommoore / mongodb_3.2.x_replica_sets_on_aws_ec2.md
Last active March 15, 2022 22:28
MongoDB 3.2.x Replica Sets on AWS EC2

#MongoDB 3.2.x Replica Sets on AWS EC2 A MongoDB replica set provides a mechanism to allow for a reliable database services. The basic replica set consists of three servers, a primary, a secondary and an arbitrator. The primary and secondary both hold a copy of the data. The arbitrator is normally a low spec server which just monitors the other servers and help with the failover process. In production, there can be more than three servers.

To setup mongo as a replica set on Amazon Web Services EC2 you need to first setup a security group with ssh on port 22 and mongodb on port 27017. You then need to create three servers. Select Ubuntu 14.04 LTS x64 and a micro (or bigger depending on your database size, ideally you should have enough memory to match your database size) instance for the primary and secondary and a nano instance for the arbitrator.

##Adjust the File System on each Server The operating system by default will update the last access time on a file. In a high data throughput database application

AWS LambdaのPythonから利用出来るOpenCV3.0のライブラリを作成する手順

AWS Lambdaの実行環境の確認

AWSのLambda 実行環境と利用できるライブラリで確認する。

2015年12月現在では、 AMI ID: アジアパシフィック(東京) リージョンの ami-cbf90ecb を使っている。

OpenCVのビルド環境を作る