-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,995 additions
and
116 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +0,0 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Loading dataset...\n" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"Dataset({\n", | ||
" features: ['chosen', 'rejected', 'chosen_prompt', 'rejected_prompt'],\n", | ||
" num_rows: 90000\n", | ||
"})" | ||
] | ||
}, | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from datasets import load_from_disk, Dataset\n", | ||
"from transformers import (\n", | ||
" AutoModelForSequenceClassification,\n", | ||
" AutoTokenizer,\n", | ||
")\n", | ||
"from trl import RewardTrainer, RewardConfig\n", | ||
"from peft.tuners.lora import LoraConfig\n", | ||
"from peft.mapping import get_peft_model\n", | ||
"import wandb\n", | ||
"\n", | ||
"# Configuration\n", | ||
"model_name = \"unsloth/Llama-3.2-3B\"\n", | ||
"dataset_path = \"./data/sample_pairs\"\n", | ||
"output_dir = \"./reward_model_output\"\n", | ||
"num_epochs = 1\n", | ||
"batch_size = 8\n", | ||
"learning_rate = 5e-5\n", | ||
"max_length = 4096\n", | ||
"\n", | ||
"print(\"Loading dataset...\")\n", | ||
"dataset: Dataset = load_from_disk(dataset_path)[\"train\"]\n", | ||
"\n", | ||
"dataset\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"Dataset({\n", | ||
" features: ['_data_files', '_fingerprint', '_format_columns', '_format_kwargs', '_format_type', '_output_all_columns', '_split'],\n", | ||
" num_rows: 1\n", | ||
"})" | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"dataset" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
) | ||
}, | ||
) | ||
async def main(): | ||
def main(): | ||
import os | ||
import torch | ||
from datasets import Dataset | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import io | ||
import subprocess | ||
import tempfile | ||
import os | ||
import hashlib | ||
|
||
|
||
def update_image(): | ||
# Create hash of dockerfile contents | ||
dockerfile_hash = hashlib.sha256(dockerfile.encode()).hexdigest()[:12] | ||
image_name = f"ghcr.io/openpipe/scraped-stories-rm:{dockerfile_hash}" | ||
|
||
print(f"Building image {image_name}") | ||
|
||
# Create temporary directory and write dockerfile there | ||
with tempfile.TemporaryDirectory() as tmpdir: | ||
dockerfile_path = os.path.join(tmpdir, "Dockerfile") | ||
with open(dockerfile_path, "w") as f: | ||
f.write(dockerfile) | ||
|
||
subprocess.run( | ||
["docker", "build", "--platform", "linux/amd64", "-t", image_name, tmpdir], | ||
check=True, | ||
) | ||
|
||
print(f"Pushing image {image_name}") | ||
subprocess.run(["docker", "push", image_name], check=True) | ||
|
||
print(f"Image {image_name} updated") | ||
|
||
return image_name | ||
|
||
|
||
if __name__ == "__main__": | ||
update_image() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import sky | ||
import dotenv | ||
import os | ||
from typing import Callable | ||
|
||
dotenv.load_dotenv() | ||
|
||
|
||
def run_skypilot(script_path: str, env_vars: dict[str, str] | None = None): | ||
env_vars = env_vars or dotenv.dotenv_values() # type: ignore | ||
|
||
s3_bucket_name = os.getenv("REMOTE_BUCKET") | ||
task = sky.Task( | ||
run="pwd && ls", | ||
envs=env_vars, | ||
workdir=os.path.dirname(os.path.abspath(__file__)), | ||
) | ||
|
||
# task.set_resources(sky.Resources(cloud=sky.RunPod(), accelerators="H100:1")) | ||
task.set_resources(sky.Resources(cloud=sky.RunPod())) | ||
|
||
# task.set_storage_mounts({"/remote": sky.Storage(source=f"s3://{s3_bucket_name}")}) | ||
|
||
sky.launch(task, cluster_name="scraped-stories-rm", down=True) | ||
|
||
|
||
def is_local(): | ||
return "SKYPILOT_TASK_ID" not in os.environ | ||
|
||
|
||
if __name__ == "__main__": | ||
run_skypilot("scraped_stories/rm/model1.py") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.