Skip to content
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

Dpatel enable tests on spyre #77

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

dpatel-ops
Copy link
Member

@dpatel-ops dpatel-ops commented Feb 10, 2025

This PR is to enable tests for spyre execution:
It allows users to achieve the following via environment variables:

  • to pass dynamic model directory
  • to pass back end type
  • to pass list of models

Note:

  • The default behavior values are set to assume that tests are being executed in CPU environment so if no value is set then it will execute based on existing CPU environment tests.

Expected behavior:

  • The tests should execute on cpu without any changes without any execution behavior changes
  • If correct environment values are set then, tests should successfully run on spyre environment

Copy link

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

@dpatel-ops dpatel-ops added the enhancement New feature or request label Feb 10, 2025
@pytest.mark.parametrize("prompts", [[
"Provide a list of instructions for preparing"
" chicken soup for a family of four.", "Hello",
"What is the weather today like?", "Who are you?"
]])
@pytest.mark.parametrize("warmup_shape", [(64, 20, 4), (64, 20, 8),
(128, 20, 4), (128, 20, 8)]
# @pytest.mark.parametrize("warmup_shape", [(64, 20, 1), (128, 20, 1)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this line be removed?

# get model backend from env, if not set then default to "eager"
# For multiple values, export SPYRE_TEST_MODEL_DIR="eager,inductor"
backend_type = os.environ.get("SPYRE_TEST_BACKEND_TYPE", "eager")
# get model names from env, if not set then default to "llama-194m"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# get model names from env, if not set then default to "llama-194m"
# get model names from env, if not set then default to "all-roberta-large-v1"

backend_type = os.environ.get("SPYRE_TEST_BACKEND_TYPE", "eager")
# get model names from env, if not set then default to "llama-194m"
# For multiple values, export SPYRE_TEST_MODEL_DIR="llama-194m,all-roberta-large-v1"
user_test_model_list = os.environ.get("SPYRE_TEST_MODEL_LIST","llama-194m")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note: you named it SPYRE_TEST_MODEL_LIST because multiple models can be tested, but you named SPYRE_TEST_BACKEND_TYPE and not SPYRE_TEST_BACKEND_TYPE_LIST. Same for the other files.

Comment on lines 46 to 48
# ) # (prompt_length/new_tokens/batch_size)
# @pytest.mark.parametrize("warmup_shapes",
# [[(64, 20, 1)], [(128, 20, 1)]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before: should it be removed?

# For multiple values, export SPYRE_TEST_MODEL_DIR="eager,inductor"
backend_type = os.environ.get("SPYRE_TEST_BACKEND_TYPE", "eager")
# get model names from env, if not set then default to "llama-194m"
# For multiple values, export SPYRE_TEST_MODEL_DIR="llama-194m,all-roberta-large-v1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# For multiple values, export SPYRE_TEST_MODEL_DIR="llama-194m,all-roberta-large-v1"
# For multiple values, export SPYRE_TEST_MODEL_LIST="llama-194m,all-roberta-large-v1"

# get model directory path from env, if not set then default to "/models".
model_dir_path = os.environ.get("SPYRE_TEST_MODEL_DIR", "/models")
# get model backend from env, if not set then default to "eager"
# For multiple values, export SPYRE_TEST_MODEL_DIR="eager,inductor"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# For multiple values, export SPYRE_TEST_MODEL_DIR="eager,inductor"
# For multiple values, export SPYRE_TEST_BACKEND_TYPE="eager,inductor"

# For multiple values, export SPYRE_TEST_MODEL_DIR="eager,inductor"
backend_type = os.environ.get("SPYRE_TEST_BACKEND_TYPE", "eager")
# get model names from env, if not set then default to "llama-194m"
# For multiple values, export SPYRE_TEST_MODEL_DIR="llama-194m,all-roberta-large-v1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# For multiple values, export SPYRE_TEST_MODEL_DIR="llama-194m,all-roberta-large-v1"
# For multiple values, export SPYRE_TEST_MODEL_LIST="llama-194m,all-roberta-large-v1"

# get model directory path from env, if not set then default to "/models".
model_dir_path = os.environ.get("SPYRE_TEST_MODEL_DIR", "/models")
# get model backend from env, if not set then default to "eager"
# For multiple values, export SPYRE_TEST_MODEL_DIR="eager,inductor"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# For multiple values, export SPYRE_TEST_MODEL_DIR="eager,inductor"
# For multiple values, export SPYRE_TEST_BACKEND_TYPE="eager,inductor"

# For multiple values, export SPYRE_TEST_MODEL_DIR="eager,inductor"
backend_type = os.environ.get("SPYRE_TEST_BACKEND_TYPE", "eager")
# get model names from env, if not set then default to "llama-194m"
# For multiple values, export SPYRE_TEST_MODEL_DIR="llama-194m,all-roberta-large-v1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# For multiple values, export SPYRE_TEST_MODEL_DIR="llama-194m,all-roberta-large-v1"
# For multiple values, export SPYRE_TEST_MODEL_LIST="llama-194m,all-roberta-large-v1"

@pytest.mark.parametrize("backend",
["eager"]) #, "inductor", "sendnn_decoder"])
test_backend_list) #, "inductor", "sendnn_decoder"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open question: should we still keep the #, "inductor", "sendnn_decoder"]) part if we use a list of backends? Maybe we can put that in the header part?

- fix comments
@dpatel-ops
Copy link
Member Author

Thank you @sducouedic for all the inputs. I have made few changes. Please let me know if anything is missed.

Copy link
Member

@sducouedic sducouedic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 15 to 30
# get model directory path from env, if not set then default to "/models".
model_dir_path = os.environ.get("SPYRE_TEST_MODEL_DIR", "/models")
# get model backend from env, if not set then default to "eager"
# For multiple values, export SPYRE_TEST_BACKEND_LIST="eager,inductor,sendnn_decoder"
backend_list = os.environ.get("SPYRE_TEST_BACKEND_LIST", "eager")
# get model names from env, if not set then default to "llama-194m"
# For multiple values, export SPYRE_TEST_MODEL_LIST="llama-194m,all-roberta-large-v1"
user_test_model_list = os.environ.get("SPYRE_TEST_MODEL_LIST","llama-194m")
test_model_list, test_backend_list = [],[]

@pytest.mark.parametrize("model", ["/models/llama-194m"])
for model in user_test_model_list.split(','):
test_model_list.append(f"{model_dir_path.strip()}/{model.strip()}")

for backend in backend_list.split(','):
test_backend_list.append(backend.strip())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these environment variables (and the code to parse them) are used in multiple files, I think it would make sense to move them into a common place (spyre_util.py perhaps) and then have each test import them from there.

Copy link
Member

@tdoublep tdoublep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also ensure the changes are adhering to the formatting guidelines of vLLM (you can run bash format.sh to run through all the checks).

Copy link
Contributor

@maxdebayser maxdebayser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dpatel-007, you can move common helper functions to conftest.py as fixtures that can be used the tests. For example instead of redefining this in every file:

model_dir_path = os.environ.get("SPYRE_TEST_MODEL_DIR", "/models")

You could have

@pytest.fixture(scope="session")
def model_dir_path():
    return os.environ.get("SPYRE_TEST_MODEL_DIR", "/models")

(I'm not saying that this is the ideal solution for model_dir_path, it's just to illustrate the idea)

- fixed E501 erros
- created functions in utils and removed repeated code
- fixed spyre_utils and embeddings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants