{"id":30158708,"url":"https://github.com/huggingface/gpt-oss-recipes","last_synced_at":"2025-10-14T15:29:12.977Z","repository":{"id":308440557,"uuid":"1030313786","full_name":"huggingface/gpt-oss-recipes","owner":"huggingface","description":"Collection of scripts and notebooks for OpenAI's latest GPT OSS models","archived":false,"fork":false,"pushed_at":"2025-08-25T17:06:08.000Z","size":58,"stargazers_count":454,"open_issues_count":8,"forks_count":48,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-10-12T15:05:46.443Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huggingface.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-01T12:35:15.000Z","updated_at":"2025-10-12T06:26:20.000Z","dependencies_parsed_at":"2025-08-06T00:27:17.511Z","dependency_job_id":"d3d31c2d-f7f6-4cb3-abfb-174f9723697f","html_url":"https://github.com/huggingface/gpt-oss-recipes","commit_stats":null,"previous_names":["huggingface/gpt-oss-recipes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/huggingface/gpt-oss-recipes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huggingface%2Fgpt-oss-recipes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huggingface%2Fgpt-oss-recipes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huggingface%2Fgpt-oss-recipes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huggingface%2Fgpt-oss-recipes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huggingface","download_url":"https://codeload.github.com/huggingface/gpt-oss-recipes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huggingface%2Fgpt-oss-recipes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279019314,"owners_count":26086711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-11T14:55:05.243Z","updated_at":"2025-10-14T15:29:12.970Z","avatar_url":"https://github.com/huggingface.png","language":"Jupyter Notebook","funding_links":[],"categories":["Inference"],"sub_categories":["Local"],"readme":"# OpenAI GPT-OSS Recipes\n\n![OpenAI GPT-OSS](https://huggingface.co/blog/assets/openai/openai-hf-thumbnail.png)\n\nCollection of scripts demonstrating different optimization and fine-tuning techniques for OpenAI's GPT-OSS models (20B and 120B parameters).\n\n**Resources**\n\n- [Blog - Welcome GPT-OSS: the new open-source model family from OpenAI](https://huggingface.co/blog/welcome-openai-gpt-oss)\n- [Cookbook - Fine-tuning with GPT-OSS and Hugging Face](https://cookbook.openai.com/articles/gpt-oss/fine-tune-transfomers)\n- [OpenAI GPT-OSS 20B model](https://huggingface.co/openai/gpt-oss-20b)\n- [OpenAI GPT-OSS 120B model](https://huggingface.co/openai/gpt-oss-120b)\n- [Release collection on Hugging Face](https://huggingface.co/collections/openai/gpt-oss-68911959590a1634ba11c7a4)\n\n## Scripts\n\n- `generate_tp.py` - Model with Tensor Parallelism.\n- `generate_flash_attention.py` - Model with Flash Attention + Tensor Parallelism.\n- `generate_tp_continuous_batching.py` - Model with Flash Attention + Tensor Parallelism and Continuous Batching.\n- `generate_all.py` - Model with all optimizations: Expert Parallelism, Tensor Parallelism, Flash Attention.\n- `sft.py` - Script for fine-tuning the model using supervised fine-tuning (SFT). Supports both full-parameter training and LoRA training.\n\n### Model Configuration\n\nAll 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:\n\n```python\n# Model configuration - uncomment the model size you want to use\nmodel_path = \"openai/gpt-oss-120b\"  # 120B model (default)\n# model_path = \"openai/gpt-oss-20b\"  # 20B model - uncomment this line and comment the line above\n```\n\nThe scripts automatically configure the appropriate device mapping and settings based on the selected model size.\n\n## Installation\n\nFirst create a virtual environment using e.g. `uv`:\n\n```sh\nuv venv gpt-oss --python 3.11 \u0026\u0026 source gpt-oss/bin/activate \u0026\u0026 uv pip install --upgrade pip\n```\n\nNext install PyTorch and Triton kernels:\n\n```sh\nuv pip install torch==2.8.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/test/cu128\n```\n\nIf your hardware supports the MXFP4 quantization format, you can also install Triton kernels for optimized performance:\n\n```sh\nuv pip install git+https://github.com/triton-lang/triton.git@main#subdirectory=python/triton_kernels\n```\n\nFinall install the remaining dependencies:\n\n```sh\nuv pip install -r requirements.txt\n```\n\n## Usage\n\n### Inference\n\n\u003e [!IMPORTANT]\n\u003e Before running any script, edit the `model_path` variable to select your desired model size (20B or 120B).\n\nRun a generation script:\n\n```bash\npython generate_\u003cscript_name\u003e.py\n```\n\nor for distributed:\n\n```bash\ntorchrun --nproc_per_node=x generate_\u003cscript_name\u003e.py\n```\n\n### Training\n\nFor full-parameter training on one node of 8 GPUs, run:\n\n```bash\n# Eager attention\naccelerate launch --config_file configs/zero3.yaml sft.py --config configs/sft_full.yaml\n\n# FlashAttention3\naccelerate launch --config_file configs/zero3.yaml sft.py --config configs/sft_full.yaml --attn_implementation kernels-community/vllm-flash-attn3\n```\n\nFor LoRA training on one GPU, run:\n\n```bash\npython sft.py --config configs/sft_lora.yaml\n```\n\nTo 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.:\n\n```bash\naccelerate launch --config_file configs/zero3.yaml \\\n    sft.py --config configs/sft_full.yaml \\\n    --dataset_name DATASET_NAME\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuggingface%2Fgpt-oss-recipes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuggingface%2Fgpt-oss-recipes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuggingface%2Fgpt-oss-recipes/lists"}