Skip to content

Commit 8316495

Browse files
revert: remove adapters / intrinsics / alora / lora from openai code (#543)
* revert: remove adapters / intrinsics / alora / lora from openai code openai backend no longer supports intrinsics for vllm; vllm branch to support aloras was closed with prejudice. * fix: fix generate_from_raw with format for newer vllm server versions * fix: remove unnecessary vllm flags * doc: removed more mentions to VLLM_USE_V1=0 * refactor: make openai vllm test 'normal' * fix: vllm server complains numpy version --------- Co-authored-by: Masataro Asai <guicho2.71828@gmail.com>
1 parent 2f74853 commit 8316495

21 files changed

Lines changed: 543 additions & 923 deletions

docs/examples/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ def _run_vllm_examples_isolated(session, vllm_files: list[str]) -> int:
264264

265265
# Set environment variables for vLLM
266266
env = os.environ.copy()
267-
env["VLLM_USE_V1"] = "0"
268267
env["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
269268

270269
all_passed = True

docs/examples/intrinsics/intrinsics.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,12 @@
33
import mellea.stdlib.functional as mfuncs
44
from mellea.backends.adapters.adapter import AdapterType, GraniteCommonAdapter
55
from mellea.backends.huggingface import LocalHFBackend
6-
from mellea.backends.openai import OpenAIBackend, _ServerType
76
from mellea.stdlib.components import Intrinsic, Message
87
from mellea.stdlib.context import ChatContext
98

109
# This is an example for how you would directly use intrinsics. See `mellea/stdlib/intrinsics/rag.py`
1110
# for helper functions.
1211

13-
# Create the backend. Example for a VLLM Server. Commented out in favor of the hugging face code for now.
14-
# # Assumes a locally running VLLM server.
15-
# backend = OpenAIBackend(
16-
# model_id="ibm-granite/granite-4.0-micro",
17-
# base_url="http://0.0.0.0:8000/v1",
18-
# api_key="EMPTY",
19-
# )
20-
21-
# # If using a remote VLLM server, utilize the `test/backends/test_openai_vllm/serve.sh`
22-
# # script with `export VLLM_DOWNLOAD_RAG_INTRINSICS=True`. This will download the granite_common
23-
# # adapters on the server.
24-
# backend._server_type = _ServerType.REMOTE_VLLM
25-
2612
backend = LocalHFBackend(model_id="ibm-granite/granite-3.3-8b-instruct")
2713

2814
# Create the Adapter. GraniteCommonAdapter's default to ALORAs.

mellea/backends/adapters/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
AdapterType,
66
GraniteCommonAdapter,
77
LocalHFAdapter,
8-
OpenAIAdapter,
98
fetch_intrinsic_metadata,
109
get_adapter_for_intrinsic,
1110
)
@@ -15,7 +14,6 @@
1514
"AdapterType",
1615
"GraniteCommonAdapter",
1716
"LocalHFAdapter",
18-
"OpenAIAdapter",
1917
"fetch_intrinsic_metadata",
2018
"get_adapter_for_intrinsic",
2119
]

mellea/backends/adapters/adapter.py

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,6 @@ def __init__(self, name: str, adapter_type: AdapterType):
3838
"""set when the adapter is added to a backend"""
3939

4040

41-
class OpenAIAdapter(Adapter):
42-
"""Adapter for OpenAIBackends."""
43-
44-
@abc.abstractmethod
45-
def get_open_ai_path(
46-
self,
47-
base_model_name: str,
48-
server_type: _ServerType = _ServerType.LOCALHOST,
49-
remote_path: str | None = None,
50-
) -> str:
51-
"""Returns the path needed to load the adapter.
52-
53-
Args:
54-
base_model_name: the base model; typically the last part of the huggingface model id like "granite-3.3-8b-instruct"
55-
server_type: the server type (ie LOCALHOST / OPENAI); usually the backend has information on this
56-
remote_path: optional; used only if the server_type is REMOTE_VLLM; base path at which to find the adapter
57-
"""
58-
...
59-
60-
6141
class LocalHFAdapter(Adapter):
6242
"""Adapter for LocalHFBackends."""
6343

@@ -71,7 +51,7 @@ def get_local_hf_path(self, base_model_name: str) -> str:
7151
...
7252

7353

74-
class GraniteCommonAdapter(OpenAIAdapter, LocalHFAdapter):
54+
class GraniteCommonAdapter(LocalHFAdapter):
7555
"""Adapter for intrinsics that utilize the ``granite-common`` library."""
7656

7757
def __init__(
@@ -149,35 +129,6 @@ def __init__(
149129
assert config_dict is not None # Code above should initialize this variable
150130
self.config: dict = config_dict
151131

152-
def get_open_ai_path(
153-
self,
154-
base_model_name: str,
155-
server_type: _ServerType = _ServerType.LOCALHOST,
156-
remote_path: str | None = None,
157-
) -> str:
158-
"""Returns the path needed to load the adapter.
159-
160-
Args:
161-
base_model_name: the base model; typically the last part of the huggingface
162-
model id like "granite-3.3-8b-instruct"
163-
server_type: the server type (ie LOCALHOST / OPENAI); usually the backend
164-
has information on this
165-
remote_path: optional; used only if the server_type is REMOTE_VLLM; base
166-
path at which to find the adapter
167-
"""
168-
if server_type == _ServerType.LOCALHOST:
169-
path = self.download_and_get_path(base_model_name)
170-
elif server_type == _ServerType.REMOTE_VLLM:
171-
if remote_path is None:
172-
remote_path = "rag-intrinsics-lib"
173-
path = self.get_path_on_remote(base_model_name, remote_path)
174-
else:
175-
raise ValueError(
176-
f"{self} not supported for OpenAIBackend with server_type: {server_type}"
177-
)
178-
179-
return path
180-
181132
def get_local_hf_path(self, base_model_name: str) -> str:
182133
"""Returns the path needed to load the adapter.
183134
@@ -207,11 +158,6 @@ def download_and_get_path(self, base_model_name: str) -> str:
207158
)
208159
)
209160

210-
def get_path_on_remote(self, base_model_name: str, base_path: str) -> str:
211-
"""Assumes the files have already been downloaded on the remote server."""
212-
# TODO: This will break when we switch to the new repo!!!
213-
return f"./{base_path}/{self.name}/{self.adapter_type.value}/{base_model_name}"
214-
215161

216162
T = TypeVar("T")
217163

0 commit comments

Comments
 (0)