Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mellea/backends/aloras/openai/granite_aloras.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def generate_using_strings(
output._meta["alora_name"] = self.name

output._process = processing
output._post_process = functools.partial(post_processing, backend=self._backend)
output._post_process = functools.partial(post_processing, self._backend)

try:
# To support lazy computation, will need to remove this create_task and store just the unexecuted coroutine.
Expand Down
21 changes: 16 additions & 5 deletions test/backends/test_openai_vllm/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,26 @@ in-conda (){
}


in-conda uv pip install -e .[dev]
in-conda pip install -e . --group dev
in-conda uv pip install pre-commit
# in-conda pre-commit install


install-vllm-fork (){

# first, install vllm
uv pip install vllm==0.9.1
# find the most recent commit between the two code bases
dir=$(readlink -ef $(dirname $0))
branch="alora" # Allow targeting other branches.

git clone --bare https://github.com/vllm-project/vllm.git $dir/vllm-commits
pushd $dir/vllm-commits
git remote add alora https://github.com/tdoublep/vllm.git
git fetch alora $branch
common_commit=$(git merge-base main alora/$branch)
popd
rm -rf $dir/vllm-commits

# install vllm from the most recent common commit
uv pip install "vllm @ git+https://github.com/vllm-project/vllm.git@$common_commit"

# copying the shared objects that are missing in the custom build
rsync -av --prune-empty-dirs --include="*/" --include="*.so" --exclude="*" ${CONDA_PREFIX}/lib/python3.12/site-packages/vllm/ vllm_backup/
Expand All @@ -25,7 +36,7 @@ install-vllm-fork (){
# it seems they are manually copying this directory, so I should follow this too...
rsync -av --prune-empty-dirs --include="*/" --include="*.py" --exclude="*" ${CONDA_PREFIX}/lib/python3.12/site-packages/vllm/vllm_flash_attn/ vllm_backup/vllm_flash_attn/

uv pip install "vllm @ git+https://github.com/tdoublep/vllm@alora"
uv pip install "vllm @ git+https://github.com/tdoublep/vllm@$branch"

rsync -av vllm_backup/ ${CONDA_PREFIX}/lib/python3.12/site-packages/vllm/
}
Expand Down
3 changes: 3 additions & 0 deletions test/backends/test_openai_vllm/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ done
VLLM_TESTS_ENABLED="1" python $dir/test_openai_vllm.py


# The VLLM process doesn't always get cleaned up. Get the pid of the VLLM::Engine zombie process and kill it.
potential_zombie_process=$( grep -m 1 -oP 'EngineCore_DP0 pid=\K\d+' $(readlink -ef $(dirname $0))/vllm.err)
kill -9 $potential_zombie_process
2 changes: 0 additions & 2 deletions test/backends/test_openai_vllm/serve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,3 @@ vllm serve ibm-granite/granite-3.2-8b-instruct \
--enable-prefix-caching \
> $(readlink -ef $(dirname $0))/vllm.log \
2> $(readlink -ef $(dirname $0))/vllm.err


26 changes: 11 additions & 15 deletions test/backends/test_openai_vllm/test_openai_vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from mellea.stdlib.base import CBlock, ModelOutputThunk, ChatContext
from mellea.backends.openai import OpenAIBackend
from mellea.backends.aloras.openai.granite_aloras import add_granite_aloras
from mellea.stdlib.requirement import Requirement, ALoraRequirement, LLMaJRequirement
from mellea.stdlib.requirement import Requirement, ALoraRequirement, LLMaJRequirement, req
from mellea.backends.formatter import TemplateFormatter
from mellea.backends.types import ModelOption

Expand Down Expand Up @@ -168,12 +168,11 @@ def test_constraint_lora_with_requirement(self):
"Corporate wants you to find the difference between these two strings: aaaaaaaaaa aaaaabaaaa"
)
validation_outputs = self.m.validate(
"The answer should mention that there is a b in the middle of one of the strings but not the other.",
return_full_validation_results=True,
ALoraRequirement("The answer should mention that there is a b in the middle of one of the strings but not the other."),
)
assert len(validation_outputs) == 1
alora_output, valuation_boolean = validation_outputs[0]
assert str(alora_output) in ["Y", "N"]
val_result = validation_outputs[0]
assert str(val_result.reason) in ["Y", "N"]
self.m.reset()

def test_constraint_lora_override(self):
Expand All @@ -183,12 +182,11 @@ def test_constraint_lora_override(self):
"Corporate wants you to find the difference between these two strings: aaaaaaaaaa aaaaabaaaa"
)
validation_outputs = self.m.validate(
"The answer should mention that there is a b in the middle of one of the strings but not the other.",
return_full_validation_results=True,
LLMaJRequirement("The answer should mention that there is a b in the middle of one of the strings but not the other."),
)
assert len(validation_outputs) == 1
non_alora_output, _ = validation_outputs[0]
assert str(non_alora_output) not in ["Y", "N"]
val_result = validation_outputs[0]
assert str(val_result.reason) not in ["Y", "N"]
self.backend.default_to_constraint_checking_alora = True
self.m.reset()

Expand All @@ -202,11 +200,10 @@ def test_constraint_lora_override_does_not_override_alora(self):
ALoraRequirement(
"The answer should mention that there is a b in the middle of one of the strings but not the other."
),
return_full_validation_results=True,
)
assert len(validation_outputs) == 1
non_alora_output, _ = validation_outputs[0]
assert str(non_alora_output) in ["Y", "N"]
non_alora_output = validation_outputs[0]
assert str(non_alora_output.reason) in ["Y", "N"]
self.backend.default_to_constraint_checking_alora = True
self.m.reset()

Expand All @@ -220,11 +217,10 @@ def test_llmaj_req_does_not_use_alora(self):
LLMaJRequirement(
"The answer should mention that there is a b in the middle of one of the strings but not the other."
),
return_full_validation_results=True,
)
assert len(validation_outputs) == 1
non_alora_output, _ = validation_outputs[0]
assert str(non_alora_output) not in ["Y", "N"]
non_alora_output = validation_outputs[0]
assert str(non_alora_output.reason) not in ["Y", "N"]
self.m.reset()

def test_instruct(self):
Expand Down