Skip to content
프로젝트

소개

OpenAI의 최신 GPT OSS 모델을 위한 스크립트와 노트북 모음

개발 도구

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
-1
in 15 days
기록 수집 중
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

OpenAI GPT-OSS Recipes

OpenAI GPT-OSS

Collection of scripts demonstrating different optimization and fine-tuning techniques for OpenAI's GPT-OSS models (20B and 120B parameters).

Resources

Scripts

  • generate_tp.py - Model with Tensor Parallelism.
  • generate_flash_attention.py - Model with Flash Attention + Tensor Parallelism.
  • generate_tp_continuous_batching.py - Model with Flash Attention + Tensor Parallelism and Continuous Batching.
  • generate_all.py - Model with all optimizations: Expert Parallelism, Tensor Parallelism, Flash Attention.
  • sft.py - Script for fine-tuning the model using supervised fine-tuning (SFT). Supports both full-parameter training and LoRA training.

Model Configuration

All generation scripts support both 20B and 120B models. To switch between model sizes, simply edit the model_path variable at the top of each script:

# Model configuration - uncomment the model size you want to use
model_path = "openai/gpt-oss-120b"  # 120B model (default)
# model_path = "openai/gpt-oss-20b"  # 20B model - uncomment this line and comment the line above

The scripts automatically configure the appropriate device mapping and settings based on the selected model size.

Installation

First create a virtual environment using e.g. uv:

uv venv gpt-oss --python 3.11 && source gpt-oss/bin/activate && uv pip install --upgrade pip

Next install PyTorch and Triton kernels:

uv pip install torch==2.8.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/test/cu128

If your hardware supports the MXFP4 quantization format, you can also install Triton kernels for optimized performance:

uv pip install git+https://github.com/triton-lang/triton.git@main#subdirectory=python/triton_kernels

Finall install the remaining dependencies:

uv pip install -r requirements.txt

Usage

Inference

[!IMPORTANT] Before running any script, edit the model_path variable to select your desired model size (20B or 120B).

Run a generation script:

python generate_<script_name>.py

or for distributed:

torchrun --nproc_per_node=x generate_<script_name>.py

Training

For full-parameter training on one node of 8 GPUs, run:

# Eager attention
accelerate launch --config_file configs/zero3.yaml sft.py --config configs/sft_full.yaml

# FlashAttention3
accelerate launch --config_file configs/zero3.yaml sft.py --config configs/sft_full.yaml --attn_implementation kernels-community/vllm-flash-attn3

For LoRA training on one GPU, run:

python sft.py --config configs/sft_lora.yaml

To change the dataset or training hyperparameters, either modify the sft_lora.yaml or sft_full.yaml files or pass them as command line arguments e.g.:

accelerate launch --config_file configs/zero3.yaml \
    sft.py --config configs/sft_full.yaml \
    --dataset_name DATASET_NAME

관련 프로젝트 살펴보기

불러오는 중…