-
Notifications
You must be signed in to change notification settings - Fork 42
Add script for cuda unit test #567
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
XuehaoSun
wants to merge
11
commits into
main
Choose a base branch
from
xuehao/cuda_ut
base: main
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 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cc1aed4
Add script for cuda unit test
XuehaoSun 765416c
fix conda path
XuehaoSun a200ee9
refine ut
XuehaoSun 512f436
fix pip install
XuehaoSun d4cf11e
fix ut
XuehaoSun b985d30
Merge branch 'main' into xuehao/cuda_ut
XuehaoSun 86682cf
Merge branch 'main' into xuehao/cuda_ut
XuehaoSun 86a1b49
fix
XuehaoSun 0df36ad
Merge branch 'main' into xuehao/cuda_ut
XuehaoSun 166d07b
Merge branch 'main' into xuehao/cuda_ut
XuehaoSun ade05a8
add gguf
XuehaoSun 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
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 |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/bin/bash | ||
set -xe | ||
|
||
CONDA_ENV_NAME="unittest_cuda" | ||
PYTHON_VERSION="3.10" | ||
REPO_PATH=$(git rev-parse --show-toplevel) | ||
LOG_DIR=${REPO_PATH}/ut_log_dir | ||
|
||
function create_conda_env() { | ||
echo "-----[VAL INFO] create conda env -----" | ||
[[ -d ${HOME}/anaconda3/bin ]] && export PATH=${HOME}/anaconda3/bin/:$PATH | ||
[[ -d ${HOME}/miniforge3/bin ]] && export PATH=${HOME}/miniforge3/bin/:$PATH | ||
[[ -d ${HOME}/miniconda3/bin ]] && export PATH=${HOME}/miniconda3/bin/:$PATH | ||
|
||
# create conda env | ||
source activate base | ||
if conda info --envs | grep -q "^$CONDA_ENV_NAME\s"; then conda remove -n ${CONDA_ENV_NAME} --all -y; fi | ||
conda create -n ${CONDA_ENV_NAME} python=${PYTHON_VERSION} setuptools=69.5.1 -y | ||
source activate ${CONDA_ENV_NAME} | ||
conda install -c conda-forge git gxx=11.2.0 gcc=11.2.0 gdb sysroot_linux-64 libgcc -y | ||
pip install uv | ||
export LD_PRELOAD=${CONDA_PREFIX}/lib/libstdc++.so.6 | ||
|
||
# install AutoRound | ||
cd ${REPO_PATH} | ||
pip uninstall auto-round -y | ||
uv pip install -r requirements.txt | ||
sed -i '/^torch==/d;/^transformers==/d;/^lm-eval==/d' requirements.txt | ||
if [ -d "/proc/driver/nvidia" ]; then | ||
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}} | ||
export LD_LIBRARY_PATH=$(python -c "import site; print(site.getsitepackages()[0])")/nvidia/nvjitlink/lib:$LD_LIBRARY_PATH | ||
fi | ||
uv pip install -v --no-build-isolation . | ||
uv pip install pytest-cov pytest-html cmake==3.31.6 | ||
} | ||
|
||
function run_unit_test() { | ||
# install unit test dependencies | ||
create_conda_env | ||
cd ${REPO_PATH}/test/test_cuda | ||
|
||
uv pip install -v git+https://github.com/casper-hansen/AutoAWQ.git --no-build-isolation | ||
uv pip install -v git+https://github.com/ModelCloud/GPTQModel.git@v2.1.0 --no-build-isolation | ||
uv pip install -r requirements.txt | ||
|
||
uv pip list | ||
export COVERAGE_RCFILE=${REPO_PATH}/.azure-pipelines/scripts/ut/.coverage | ||
local auto_round_path=$(python -c 'import auto_round; print(auto_round.__path__[0])') | ||
|
||
# setup test env | ||
mkdir -p ${LOG_DIR} | ||
local ut_log_name=${LOG_DIR}/unittest_cuda.log | ||
find . -name "test_*.py" | sed "s,\.\/,python -m pytest --cov=\"${auto_round_path}\" --cov-report term --html=report.html --self-contained-html --cov-report xml:coverage.xml --cov-append -vs --disable-warnings ,g" >run.sh | ||
cat run.sh | ||
|
||
# run unit test | ||
bash run.sh 2>&1 | tee ${ut_log_name} | ||
|
||
cp report.html ${LOG_DIR}/ | ||
cp coverage.xml ${LOG_DIR}/ | ||
|
||
if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ] || [ $(grep -c ' passed' ${ut_log_name}) == 0 ]; then | ||
echo "Find errors in pytest case, please check the output..." | ||
exit 1 | ||
fi | ||
} | ||
|
||
function run_unit_test_vlm() { | ||
# install unit test dependencies | ||
create_conda_env | ||
cd ${REPO_PATH}/test/test_cuda | ||
|
||
uv pip install git+https://github.com/haotian-liu/LLaVA.git@v1.2.2 | ||
local site_path=$(python -c "import site; print(site.getsitepackages()[0])") | ||
# reference https://github.com/haotian-liu/LLaVA/issues/1448#issuecomment-2119845242 | ||
sed -i '/inputs\[.*image_sizes.*\] = image_sizes/a\ inputs.pop("cache_position")' ${site_path}/llava/model/language_model/llava_llama.py | ||
uv pip install git+https://github.com/deepseek-ai/DeepSeek-VL2.git | ||
uv pip install -v git+https://github.com/casper-hansen/AutoAWQ.git@v0.2.0 --no-build-isolation | ||
uv pip install -r requirements_vlm.txt | ||
|
||
uv pip list | ||
export COVERAGE_RCFILE=${REPO_PATH}/.azure-pipelines/scripts/ut/.coverage | ||
local auto_round_path=$(python -c 'import auto_round; print(auto_round.__path__[0])') | ||
|
||
# setup test env | ||
mkdir -p ${LOG_DIR} | ||
local ut_log_name=${LOG_DIR}/unittest_cuda_vlm.log | ||
find . -name "test*vlms.py" | sed "s,\.\/,python -m pytest --cov=\"${auto_round_path}\" --cov-report term --html=report_vlms.html --self-contained-html --cov-report xml:coverage_vlms.xml --cov-append -vs --disable-warnings ,g" >run_vlms.sh | ||
cat run_vlms.sh | ||
|
||
# run unit test | ||
bash run_vlms.sh 2>&1 | tee ${ut_log_name} | ||
|
||
cp report_vlms.html ${LOG_DIR}/ | ||
cp coverage_vlms.xml ${LOG_DIR}/ | ||
|
||
if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ] || [ $(grep -c ' passed' ${ut_log_name}) == 0 ]; then | ||
echo "Find errors in pytest case, please check the output..." | ||
exit 1 | ||
fi | ||
} | ||
|
||
function main() { | ||
run_unit_test | ||
run_unit_test_vlm | ||
} | ||
|
||
main |
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
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 |
---|---|---|
|
@@ -9,3 +9,4 @@ dist/ | |
.clangd | ||
CMakeUserPresets.json | ||
tmp_autoround/ | ||
ut_log_dir/ |
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.
Uh oh!
There was an error while loading. Please reload this page.