-
Notifications
You must be signed in to change notification settings - Fork 49
feat: Adds think budget-forcing #107
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
Open
yelkurdi
wants to merge
35
commits into
generative-computing:main
Choose a base branch
from
yelkurdi:think_bf
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+504
−0
Open
Changes from 3 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
bd503cf
Initial commit - think budget-forcing - tests run - WIP
9385af8
adds zero-think case
fda0768
resolved type checking errors
ff03b6f
fixes typo and some scripts
d73c1ac
Merge branch 'main' into think_bf
yelkurdi 1df37d5
Merge branch 'main' into think_bf
yelkurdi e013f92
backend interface using _raw_generate
556634b
Bump version number from 0.0.2 to 0.0.3 (#117)
nrfulton 6b6599d
ci: Rename .mergify.yml to mergify.yml (#119)
avinash2692 396bf7a
docs: fix typo on README (#116)
mdevino cad893f
refactor: Full refactor of the Decompose CLI Tool & introduction of p…
tuliocoppola 75e3d0e
moved the budget forcing function into mellea/stdlib/sampling_algos/b…
fd7a3b3
adds budget forcing fn
8f1a820
Merge branch 'main' into think_bf
yelkurdi 599eac1
feat: adds think budget forcing - relocated test dir
8098128
Update budget_forcing.py
yelkurdi 56a828a
Merge branch 'main' into think_bf
nrfulton 3535b65
Merge branch 'main' into think_bf
yelkurdi ad076c5
merging main in-progress
yelkurdi 66ae952
Merge branch 'main' into think_bf
yelkurdi 05c8185
main branch updates
yelkurdi 80e8485
updates to think_budget_forcing function to match sampling strategy i…
yelkurdi 7f2c8f1
adds sampling strategy for budget forcing
yelkurdi 2493ca1
minor fixes
yelkurdi dbadd21
feat: ollama generate_from_raw uses existing event loop
jakelorocco 4396f81
Merge branch 'main' into think_bf
yelkurdi f4dc004
fix: add blocking prevention mech
jakelorocco c143ce4
Merge branch 'main' into jal/ollama-generate-from-raw
jakelorocco 99b3156
Merge branch 'jal/ollama-generate-from-raw' into think_bf
yelkurdi 8d91627
fixes of async inconsistencies and incorporating Jacob's branch
yelkurdi d0c9e41
Merge branch 'main' into think_bf
yelkurdi 8796661
updates interface significantly after prompting `_generate_from_raw` …
yelkurdi 5664a8d
minor fix to test case
yelkurdi d83fb84
minor updates
yelkurdi 1a999b9
Merge branch 'main' into think_bf
yelkurdi 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
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,2 @@ | ||
| vllm.err | ||
| vllm.log |
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,23 @@ | ||
|
|
||
| # Test for OpenAI API served by VLLM | ||
|
|
||
| ## Requirement | ||
|
|
||
| anaconda / miniconda / miniforge. | ||
|
|
||
| Make sure to run the test with multiple cores available (e.g. in a cloud instance / cluster job). | ||
| Although you may think 1 core is enough, | ||
| vllm could get stuck due to deadlock if so. | ||
|
|
||
| ## Installation | ||
|
|
||
| Needs to be done only once. | ||
| I creates a new conda environment named "mallea_tbf" only for the purposes of testing or contributing to the think budget-forcing feature. | ||
|
|
||
| Run `./install.sh` | ||
|
|
||
| ## Testing | ||
|
|
||
| ``` shell | ||
| ./run_test.sh | ||
| ``` | ||
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,7 @@ | ||
|
|
||
| name: mellea_tbf | ||
| channels: | ||
| - conda-forge | ||
| dependencies: | ||
| - python=3.12 # note: at the time of writing, xformer (< vllm) has a broken wheel for 3.13. https://github.com/facebookresearch/xformers/issues/740#issuecomment-2753869337 | ||
| - uv |
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 @@ | ||
| #!/bin/bash -xe | ||
|
|
||
| ENV_NAME=mellea_tbf | ||
| conda env remove -y -n $ENV_NAME || true | ||
| conda env create -f $(readlink -ef $(dirname $0))/environment.yml | ||
|
|
||
| in-conda (){ | ||
yelkurdi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| conda run -n $ENV_NAME $@ | ||
| } | ||
|
|
||
|
|
||
| cd ../../../ | ||
| in-conda uv pip install -e . | ||
| cd - | ||
| in-conda uv pip install pre-commit | ||
| in-conda uv pip install pytest | ||
| in-conda uv pip install vllm==0.10.0 | ||
| in-conda uv pip install outlines | ||
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,24 @@ | ||
| #!/bin/bash | ||
|
|
||
| ENV_NAME=mellea_tbf | ||
| eval "$(conda shell.bash hook)" | ||
| conda activate $ENV_NAME | ||
|
|
||
| dir=$(readlink -ef $(dirname $0)) | ||
yelkurdi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| rm $dir/vllm.log $dir/vllm.err | ||
|
|
||
| bash $dir/serve.sh & | ||
| vllm_pid=$! | ||
|
|
||
| trap "kill -SIGINT $vllm_pid ; wait" EXIT | ||
|
|
||
| while sleep 1 ; do | ||
| if grep -q "Application startup complete." $dir/vllm.err | ||
| then | ||
| break | ||
| fi | ||
| done | ||
|
|
||
| python test_think_budget_forcing.py | ||
|
|
||
|
|
||
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,37 @@ | ||
| #!/bin/bash | ||
|
|
||
| # @Masa note: | ||
| # the following code is a bash snippet Kristian gave me | ||
| # for how to run vllm with lora adapter loaded. | ||
|
|
||
| # HF_GRANITE_ALORA_SNAPSHOT=${HF_HOME:-$HOME/.cache/huggingface} | ||
| # HF_GRANITE_ALORA_SNAPSHOT+=/hub/ | ||
| # HF_GRANITE_ALORA_SNAPSHOT+=models--ibm-granite--granite-3.2-8b-alora-requirement-check/ | ||
| # HF_GRANITE_ALORA_SNAPSHOT+=snapshots/d55a7a7f5796609bc938c5c151a864cfcc6ab54e | ||
|
|
||
| # vllm serve ibm-granite/granite-3.2-8b-instruct \ | ||
| # --enable-lora \ | ||
| # --lora-modules "{\"name\": \"ibm-granite/granite-3.2-8b-alora-requirement-check\", \"path\": \"${HF_GRANITE_ALORA_SNAPSHOT}\", \"base_model_name\": \"ibm-granite/granite-3.2-8b-instruct\"}" \ | ||
| # --dtype bfloat16 \ | ||
| # --max-lora-rank 64 \ | ||
| # --enable-prefix-caching | ||
|
|
||
| # However, in our test, we do not load the alora when we serve. | ||
| # In this test, we use the dynamic loading interface from | ||
| # https://docs.vllm.ai/en/stable/features/lora.html#dynamically-serving-lora-adapters | ||
|
|
||
| # Using this feature requires the following environment variable. | ||
| # If you use conda/miniforge, | ||
| # this variable must have been set already when you set up the environment. | ||
| # see environment.yml. | ||
| export VLLM_ALLOW_RUNTIME_LORA_UPDATING=True | ||
|
|
||
| echo "launching a vllm server. Logs are found in $(readlink -ef $(dirname $0))/vllm.log" | ||
| # At the time of writing this code, Granite 4.4 vLLM serving did not support prefix-caching | ||
| # --enable-prefix-caching \ | ||
| vllm serve ibm-granite/granite-4.0-tiny-preview \ | ||
| --dtype bfloat16 \ | ||
| > $(readlink -ef $(dirname $0))/vllm.log \ | ||
| 2> $(readlink -ef $(dirname $0))/vllm.err | ||
|
|
||
|
|
Oops, something went wrong.
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.