-
Notifications
You must be signed in to change notification settings - Fork 9
Add sglang and preprocessor for verl #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
36c7519
Add preprocess script for python
BoyeGuillaume e9f68d7
Add sglang
BoyeGuillaume 62c7a11
Add and start updating sglang
BoyeGuillaume bca4bcd
Add dataset configuration files and refactor preprocessing logic
BoyeGuillaume 70bb220
Update num_processes in config-baai-taco.yaml and correct output path…
BoyeGuillaume 2223aa3
Remove unused configuration files and scripts; add new dataset downlo…
BoyeGuillaume 3af1772
Refactor math-shepherd configuration and update dataset download script
BoyeGuillaume 064302a
Add nsjail installation and cleanup steps in Dockerfile
BoyeGuillaume 5322d4a
Start on tooling
BoyeGuillaume e9f4c75
Merge remote-tracking branch 'origin/master' into verl
BoyeGuillaume File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 +1,6 @@ | ||
| [submodule "third-party/verl"] | ||
| path = third-party/verl | ||
| url = git@github.com:EPFLiGHT/verl.git | ||
| [submodule "third-party/sglang"] | ||
| path = third-party/sglang | ||
| url = git@github.com:EPFLiGHT/sglang.git |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,43 @@ | ||
| # Notice: TACO make use of dataset script that are no longer supported, need to | ||
| # downgrade datasets to datasets<=3.6.0 to load the dataset. | ||
| hydra: | ||
| searchpath: | ||
| - pkg://multimeditron.config | ||
|
|
||
| defaults: | ||
| - preprocess-ds | ||
| - _self_ | ||
|
|
||
| source: | ||
| type: hf # Supported types: 'hf', 'jsonl' | ||
| kwargs: | ||
| path: BAAI/TACO | ||
| split: train | ||
|
|
||
| tokenizer: | ||
| enable: false | ||
| model: null | ||
| use_fast: true | ||
| attachment_token: <|reserved_special_token_0|> | ||
|
|
||
| output: /capstor/store/cscs/swissai/a127/meditron/multimediset/reasoning/taco.parquet | ||
| num_processes: 128 | ||
|
|
||
| processes: | ||
| - type: python | ||
| kwargs: | ||
| remove_columns: [ | ||
| 'question', 'solutions', 'starter_code', 'input_output', 'name', 'url', 'Expected Auxiliary Space', 'Expected Time Complexity', | ||
| 'raw_tags', 'skill_types', 'tags', 'source', | ||
| 'date', 'picture_num', | ||
| ] | ||
| imports: ['re'] | ||
| func: | | ||
| { | ||
| "prompt": data["question"], | ||
| "solution": data["solutions"], | ||
| "checks": data["input_output"], | ||
| } | ||
| - type: shuffle | ||
| kwargs: | ||
| seed: 42 |
This file contains hidden or 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,43 @@ | ||
| hydra: | ||
| searchpath: | ||
| - pkg://multimeditron.config | ||
|
|
||
| defaults: | ||
| - preprocess-ds | ||
| - _self_ | ||
|
|
||
| source: | ||
| type: hf # Supported types: 'hf', 'jsonl' | ||
| kwargs: | ||
| path: trl-lib/math_shepherd | ||
| split: train | ||
|
|
||
| tokenizer: | ||
| enable: false | ||
| model: null | ||
| use_fast: true | ||
| attachment_token: <|reserved_special_token_0|> | ||
|
|
||
| output: /capstor/store/cscs/swissai/a127/meditron/multimediset/reasoning/math-shepherd.parquet | ||
| num_processes: 128 | ||
|
|
||
| processes: | ||
| - type: python-filter | ||
| kwargs: | ||
| func: | | ||
| all(k for k in data["labels"]) | ||
|
|
||
| - type: python | ||
| kwargs: | ||
| remove_columns: ['labels', 'completions'] | ||
| imports: ['re'] | ||
| func: | | ||
| { | ||
| "prompt": [{"content": data["prompt"], "role": "user"}], | ||
| "reward_model": {"ground_truth": data["completions"]}, | ||
| "data_source": "math-shepherd", | ||
| } | ||
|
|
||
| - type: shuffle | ||
| kwargs: | ||
| seed: 42 |
This file contains hidden or 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,36 @@ | ||
| hydra: | ||
| searchpath: | ||
| - pkg://multimeditron.config | ||
|
|
||
| defaults: | ||
| - preprocess-ds | ||
| - _self_ | ||
|
|
||
| source: | ||
| type: hf # Supported types: 'hf', 'jsonl' | ||
| kwargs: | ||
| path: nvidia/Llama-Nemotron-Post-Training-Dataset | ||
| split: code | ||
|
|
||
| tokenizer: | ||
| enable: false | ||
| model: null | ||
| use_fast: true | ||
| attachment_token: <|reserved_special_token_0|> | ||
|
|
||
| output: /capstor/store/cscs/swissai/a127/meditron/multimediset/reasoning/nemotron-post-training-code.parquet | ||
| num_processes: 32 | ||
|
|
||
| processes: | ||
| - type: python | ||
| kwargs: | ||
| remove_columns: ['input', 'output', 'category', 'license', 'reasoning', 'generator', 'used_in_training', 'version', 'system_prompt'] | ||
| imports: ['re'] | ||
| func: | ||
| - output_p = re.sub(r"<think>(([^<]|<(?!\/think>))*)<\/think>", '', data["output"], flags=re.MULTILINE).strip() | ||
| - code_p = list(re.finditer(r"```python\n(([^`]|`(?!``))*)\n```", output_p)) | ||
| - | | ||
| { | ||
| "prompt": data["input"][0]["content"], | ||
| "response": code_p[-1].group(1).strip() if len(code_p) > 0 else output_p, | ||
| } |
This file contains hidden or 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,18 @@ | ||
| hydra: | ||
| searchpath: | ||
| - pkg://multimeditron.config | ||
| - pkg://verl.trainer.config | ||
|
|
||
| defaults: | ||
| - verl_trainer | ||
| - _self_ | ||
|
|
||
| data: | ||
| train_files: | ||
| - /capstor/store/cscs/swissai/a127/meditron/multimediset/reasoning/math-shepherd.parquet | ||
| # - ./mock_dataset/mock_dataset.parquet | ||
| val_files: | ||
| - /capstor/store/cscs/swissai/a127/meditron/multimediset/reasoning/math-shepherd-val.parquet | ||
| # - ./mock_dataset/mock_dataset.parquet | ||
| prompt_key: prompt | ||
| reward_fn_key: data_source |
This file contains hidden or 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 hidden or 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 hidden or 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,61 @@ | ||
| #!/bin/bash | ||
| # Usage: <script> name0 name1 ... (if no names are given, provide a list of all datasets) | ||
| set -eou pipefail | ||
|
|
||
| # Check that the multimeditron scripts have been installed | ||
| if ! command -v mm &> /dev/null | ||
| then | ||
| echo "mm command could not be found, please install the multimeditron package" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # List of all of the datasets, command to run | ||
| BASE_CONFIG_PATH=$(realpath $(dirname "$0")/../config) | ||
| echo "Base config path: $BASE_CONFIG_PATH" | ||
| DATASETS=( | ||
| "math-shepherd mm preprocess-ds -c $BASE_CONFIG_PATH/rl/ds/config-math-shepherd.yaml" | ||
| "math-shepherd-val mm preprocess-ds -c $BASE_CONFIG_PATH/rl/ds/config-math-shepherd.yaml source.kwargs.split=test output=/capstor/store/cscs/swissai/a127/meditron/multimediset/reasoning/math-shepherd-val.parquet" | ||
| "baai-taco mm preprocess-ds -c $BASE_CONFIG_PATH/rl/ds/config-baai-taco.yaml" | ||
| "nemotron mm preprocess-ds -c $BASE_CONFIG_PATH/rl/ds/config-nemotron-post-training.yaml" | ||
| ) | ||
|
|
||
| # Extract the names of the datasets | ||
| ALL_DATASET_NAMES=() | ||
| for entry in "${DATASETS[@]}"; do | ||
| name=$(echo $entry | cut -d' ' -f1) | ||
| ALL_DATASET_NAMES+=("$name") | ||
| done | ||
|
|
||
| # If no arguments are given, display the list of all datasets and exit | ||
| if [ "$#" -eq 0 ]; then | ||
| echo "No dataset names provided. Available datasets are:" | ||
| for name in "${ALL_DATASET_NAMES[@]}"; do | ||
| echo " - $name" | ||
| done | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Download the specified datasets | ||
| for name in "$@"; do | ||
| found=false | ||
| for entry in "${DATASETS[@]}"; do | ||
| entry_name=$(echo $entry | cut -d' ' -f1) | ||
| if [ "$name" == "$entry_name" ]; then | ||
| found=true | ||
| echo "Downloading dataset: $name" | ||
| # Execute the command to download the dataset | ||
| cmd=$(echo $entry | cut -d' ' -f2-) | ||
| echo "Running command: $cmd" | ||
| $cmd | ||
| echo "Finished downloading dataset: $name" | ||
| break | ||
| fi | ||
| done | ||
| if [ "$found" = false ]; then | ||
| echo "Dataset name '$name' not recognized. Available datasets are:" | ||
| for valid_name in "${ALL_DATASET_NAMES[@]}"; do | ||
| echo " - $valid_name" | ||
| done | ||
| exit 1 | ||
| fi | ||
| done |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -24,4 +24,5 @@ def main_cli(): | |
|
|
||
| from .preprocess import * | ||
| from .verl import * | ||
| from .debug import * | ||
| from .train import * | ||
This file contains hidden or 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,44 @@ | ||
| from multimeditron.cli import EPILOG, CONFIG_PATH, main_cli | ||
| from multimeditron.utils import get_torch_dtype | ||
| from datasets import load_dataset | ||
| import ray | ||
| from ray import serve | ||
| from fastapi import Request | ||
|
|
||
|
|
||
| @serve.deployment(num_replicas=2) # scale horizontally if needed | ||
| class PyExecService: | ||
| def __init__(self): | ||
| # create a single NsJailExecutor actor for each replica | ||
| # self.executor = NsJailExecutor.remote() | ||
| pass | ||
|
|
||
| async def __call__(self, request: Request): | ||
| """ | ||
| HTTP handler: | ||
| - expects POST with JSON body {"code": "print('hello')", "timeout": 5} | ||
| - runs code in nsjail | ||
| - returns JSON result | ||
| """ | ||
| data = await request.json() | ||
| code = data.get("code", "") | ||
| # timeout = data.get("timeout", 5) | ||
|
|
||
| if not code.strip(): | ||
| return {"error": "No code provided"} | ||
|
|
||
| # execute asynchronously via Ray | ||
| # result = await self.executor.execute.remote(code, wall_timeout=timeout) | ||
|
BoyeGuillaume marked this conversation as resolved.
|
||
|
|
||
| return {"not": "implemented"} | ||
|
|
||
| @main_cli.command("serve") | ||
| def _serve(): | ||
| # Start ray if not already running | ||
| ray.init(address="auto", namespace="serve") | ||
|
|
||
| # Deploy service | ||
| app = PyExecService.bind() | ||
| serve.run(app, blocking=True) | ||
|
|
||
| print("🚀 Ray Serve running at http://127.0.0.1:8000/PyExecService") | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.