-
Notifications
You must be signed in to change notification settings - Fork 0
Adapt SWEAgentTranslator for local model use via Ollama and vLLM #26
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
ikhillan
wants to merge
35
commits into
develop
Choose a base branch
from
swe-agent-local-models
base: develop
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.
Open
Changes from 12 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
e915ca4
SWE-agent local model WIP commit
ikhillan 3ac817d
Add ollama server startup in swe-agent
jhdavis8 22600f2
Remove model name from ollama serve command, not needed and in wrong …
jhdavis8 b2c6af1
WIP w/ adding Klaud's config suggestions
f426764
Modified .gitignore to include .envrc
ikhillan 9da9146
Cleaned up unnecessary optional SWEAgentTranslator params
ikhillan 3554274
Updated self._swe_agent_model_name initialization in __init__
ikhillan 7ae1977
Add --swe-agent-config to add_args()
ikhillan 8f90863
Delete generated translation_task files
ikhillan 5dcddc6
Updated launch_ollama_server() to mute Ollama startup logs
1dd87f7
Deleted unnecessary repro_script() function
9829a6a
Fixed minor style issue
7d7b08d
Fixed small bug in launch_ollama_server
be519bc
Change typo for swe-agent-parser choices
f2a7eb2
Added multi-config file support and vLLM support in SWEAgentTranslator
ikhillan ab5de16
Fix bugs related to launching vllm server in SWEAgentTranslator
ikhillan 1bf8a37
Fixed small errors w/ vLLM setup for SWE-agent on perlmutter
ikhillan 24a4cd7
Fixed issue w/ removing openai part of model for vllm
ikhillan 53a60f9
WIP Klaud's suggestions
66e51e5
Made changes w/ Josh and Klaud WIP
9ffd703
Updated prompt for SWE-agent
6062bdc
Added temporary Makefile fix
ikhillan 10916b4
Update Makefile fix in SWEAgentTranslator
ikhillan 1372b93
Fix conditional part of fixing Makefiles
ikhillan 5116468
Add ninja dep for Kokkos
jhdavis8 69fed2e
Codex implementation WIP
ikhillan 82c9552
Modified codex command call
ikhillan 4814d35
WIP fix for codex impl
ikhillan 4e1348f
Added initial OpenCode impl
ikhillan c4e8fd8
Updated OpenCode Translator to test temperature
ikhillan 3776ed4
Update opencode_config to use tool calling
ikhillan e369c0c
Modified Codex impl to include vllm_proxy.py helper file
ikhillan 460a629
Used Popen for the codex output logging
ikhillan 53cfb45
Updated OpenCode implementation
ikhillan a478c7f
Updated codex cmd argument flags
ikhillan 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 |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ __pycache__ | |
|
|
||
| tmp* | ||
| .env | ||
| .envrc | ||
| .venv | ||
|
|
||
| .request_cache_*.pkl | ||
|
|
||
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 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |||||||||||||||||||||||||||||
| import shutil | ||||||||||||||||||||||||||||||
| import subprocess | ||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||
| import time | ||||||||||||||||||||||||||||||
| from typing import List, Optional, Dict, Any | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # local imports | ||||||||||||||||||||||||||||||
|
|
@@ -20,6 +21,7 @@ class SWEAgentTranslator(Translator): | |||||||||||||||||||||||||||||
| TRAJECTORIES_DIR = "trajectories" | ||||||||||||||||||||||||||||||
| PATCH_FILENAME = "temp.patch" | ||||||||||||||||||||||||||||||
| EXPERIMENT_METADATA_FILENAME = "experiment_metadata.json" | ||||||||||||||||||||||||||||||
| SERVE_CHECK_COOLDOWN = 10 | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # File extensions to remove from output | ||||||||||||||||||||||||||||||
| REMOVE_EXTENSIONS = (".cu", ".cuh") | ||||||||||||||||||||||||||||||
|
|
@@ -32,6 +34,10 @@ class SWEAgentTranslator(Translator): | |||||||||||||||||||||||||||||
| # Instance variables | ||||||||||||||||||||||||||||||
| _swe_agent_model_name: str | ||||||||||||||||||||||||||||||
| _swe_agent_per_instance_cost_limit: float | ||||||||||||||||||||||||||||||
| _swe_agent_config: Optional[str] | ||||||||||||||||||||||||||||||
| _swe_agent_parser: Optional[str] | ||||||||||||||||||||||||||||||
| _swe_agent_max_input_token: Optional[int] | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| _temp_repo_path: str | ||||||||||||||||||||||||||||||
| _translation_task_path: str | ||||||||||||||||||||||||||||||
| _output_path: str | ||||||||||||||||||||||||||||||
|
|
@@ -47,7 +53,10 @@ def __init__( | |||||||||||||||||||||||||||||
| dry: bool = False, | ||||||||||||||||||||||||||||||
| hide_progress: bool = False, | ||||||||||||||||||||||||||||||
| swe_agent_model_name: Optional[str] = None, | ||||||||||||||||||||||||||||||
| swe_agent_per_instance_cost_limit: float = 0.06 | ||||||||||||||||||||||||||||||
| swe_agent_per_instance_cost_limit: float = 0.06, | ||||||||||||||||||||||||||||||
| swe_agent_config: Optional[str] = None, | ||||||||||||||||||||||||||||||
| swe_agent_parser: Optional[str] = None, | ||||||||||||||||||||||||||||||
| swe_agent_max_input_token: Optional[int] = None, | ||||||||||||||||||||||||||||||
| ) -> None: | ||||||||||||||||||||||||||||||
| super().__init__( | ||||||||||||||||||||||||||||||
| input_repo, | ||||||||||||||||||||||||||||||
|
|
@@ -62,31 +71,82 @@ def __init__( | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| self._swe_agent_model_name = swe_agent_model_name | ||||||||||||||||||||||||||||||
| self._swe_agent_per_instance_cost_limit = swe_agent_per_instance_cost_limit | ||||||||||||||||||||||||||||||
| self._swe_agent_config = swe_agent_config | ||||||||||||||||||||||||||||||
| self._swe_agent_parser = swe_agent_parser | ||||||||||||||||||||||||||||||
| self._swe_agent_max_input_token = swe_agent_max_input_token | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| self._temp_repo_path = self.TEMP_REPO_PATH | ||||||||||||||||||||||||||||||
| self._translation_task_path = os.path.join( | ||||||||||||||||||||||||||||||
| self._input_repo.path, self.TRANSLATION_TASK_FILENAME | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| self._output_path = os.path.join(self._output_paths[0], "repo") | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if self._is_ollama_model(self._swe_agent_model_name): | ||||||||||||||||||||||||||||||
| if self._swe_agent_parser is None: | ||||||||||||||||||||||||||||||
| self._swe_agent_parser = "thought_action" | ||||||||||||||||||||||||||||||
| if self._swe_agent_max_input_token is None: | ||||||||||||||||||||||||||||||
| self._swe_agent_max_input_token = 4096 | ||||||||||||||||||||||||||||||
| self._launch_ollama_server() | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| @staticmethod | ||||||||||||||||||||||||||||||
| def _is_ollama_model(name: str) -> bool: | ||||||||||||||||||||||||||||||
| name = (name or "").lower() | ||||||||||||||||||||||||||||||
| return name.startswith("ollama/") | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def _launch_ollama_server(self) -> None: | ||||||||||||||||||||||||||||||
| """Launch an Ollama server in the background.""" | ||||||||||||||||||||||||||||||
| # Check that ollama is installed | ||||||||||||||||||||||||||||||
| if not shutil.which("ollama"): | ||||||||||||||||||||||||||||||
| raise ValueError("Ollama is not in the path. Please install Ollama and add it to the path.") | ||||||||||||||||||||||||||||||
| # Early exit if ollama is already running | ||||||||||||||||||||||||||||||
| if subprocess.run(["ollama", "list"], capture_output=True, text=True).returncode == 0: | ||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||
| ollama_command = ["ollama", "serve"] | ||||||||||||||||||||||||||||||
| subprocess.Popen(ollama_command, | ||||||||||||||||||||||||||||||
| stdout=subprocess.DEVNULL, | ||||||||||||||||||||||||||||||
| stderr=subprocess.STDOUT, | ||||||||||||||||||||||||||||||
| stdin=subprocess.DEVNULL, | ||||||||||||||||||||||||||||||
| start_new_session=True, | ||||||||||||||||||||||||||||||
| env=env) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| subprocess.Popen(ollama_command, | |
| stdout=subprocess.DEVNULL, | |
| stderr=subprocess.STDOUT, | |
| stdin=subprocess.DEVNULL, | |
| start_new_session=True, | |
| env=env) | |
| subprocess.Popen( | |
| ollama_command, | |
| stdout=subprocess.DEVNULL, | |
| stderr=subprocess.STDOUT, | |
| stdin=subprocess.DEVNULL, | |
| start_new_session=True, | |
| env=env | |
| ) |
This file was deleted.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undefined variable 'env'. The Popen call references 'env' parameter but it is not defined in this function. Either remove the env parameter or define it before use.