-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add debug setup for inference server & worker #3575
base: main
Are you sure you want to change the base?
Changes from all commits
1d99f38
b9f814e
b08dad6
23b5d98
a2f1235
6369f7e
c880a24
8734873
73bbce6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,38 @@ | |
"CUDA_VISIBLE_DEVICES": "1,2,3,4,5", | ||
"OMP_NUM_THREADS": "1" | ||
} | ||
}, | ||
{ | ||
"name": "Debug: Inference Server", | ||
"type": "python", | ||
"request": "attach", | ||
"connect": { | ||
"host": "localhost", | ||
"port": 5678 | ||
}, | ||
"pathMappings": [ | ||
{ | ||
"localRoot": "${workspaceFolder}/inference/server", | ||
"remoteRoot": "/opt/inference/server" | ||
} | ||
], | ||
"justMyCode": false | ||
}, | ||
{ | ||
"name": "Debug: Worker", | ||
"type": "python", | ||
"request": "attach", | ||
"connect": { | ||
"host": "localhost", | ||
"port": 5679 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note the different ports for server and worker |
||
}, | ||
"pathMappings": [ | ||
{ | ||
"localRoot": "${workspaceFolder}/inference/worker", | ||
"remoteRoot": "/opt/inference/worker" | ||
} | ||
], | ||
"justMyCode": false | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,12 +231,14 @@ services: | |
TRUSTED_CLIENT_KEYS: "6969" | ||
ALLOW_DEBUG_AUTH: "True" | ||
API_ROOT: "http://localhost:8000" | ||
DEBUG: "True" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly, the compose file is only meant for local development, so setting this here shouldn't be a problem? |
||
volumes: | ||
- "./oasst-shared:/opt/inference/lib/oasst-shared" | ||
- "./inference/server:/opt/inference/server" | ||
restart: unless-stopped | ||
ports: | ||
- "8000:8000" | ||
- "5678:5678" # Port to attach debugger | ||
depends_on: | ||
inference-redis: | ||
condition: service_healthy | ||
|
@@ -254,9 +256,12 @@ services: | |
MODEL_CONFIG_NAME: ${MODEL_CONFIG_NAME:-distilgpt2} | ||
BACKEND_URL: "ws://inference-server:8000" | ||
PARALLELISM: 2 | ||
DEBUG: "True" | ||
volumes: | ||
- "./oasst-shared:/opt/inference/lib/oasst-shared" | ||
- "./inference/worker:/opt/inference/worker" | ||
ports: | ||
- "5679:5679" # Port to attach debugger | ||
deploy: | ||
replicas: 1 | ||
profiles: ["inference"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,3 +148,21 @@ async def maybe_add_debug_api_keys(): | |
async def welcome_message(): | ||
logger.warning("Inference server started") | ||
logger.warning("To stop the server, press Ctrl+C") | ||
|
||
|
||
if __name__ == "__main__": | ||
import os | ||
|
||
import uvicorn | ||
|
||
port = int(os.getenv("PORT", "8000")) | ||
is_debug = bool(os.getenv("DEBUG", "False")) | ||
|
||
if is_debug: | ||
import debugpy | ||
|
||
debugpy.listen(("0.0.0.0", 5678)) | ||
# Uncomment to wait here until a debugger is attached | ||
# debugpy.wait_for_client() | ||
|
||
uvicorn.run("main:app", host="0.0.0.0", port=port, reload=is_debug) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method of starting the server is only used for development - the docker image for production still invokes the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
aiohttp | ||
debugpy | ||
hf_transfer | ||
huggingface_hub | ||
langchain==0.0.142 | ||
|
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.
@olliestanley This is what was causing pre-commit to fail on my machine.
python3
is interpreted as python3.7, which is not new enough for some of the syntax, or isort. When I am more specific, like here, it works. Should this be examined some more?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.
I suspect this wouldn't be an issue if you ran the commands from inside a Python 3.10 virtual environment (I guess that's why others haven't had any similar issues) but I don't see any reason we can't make this config change if it helps make things easier
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.
I'm on a rolling release Linux system with Python 3.10.10. It worked correctly inside a Ubuntu Docker container with the same Python version.. so it's probably some other dependency that broke this