Execute the unit test cases of the MindSpeed-LLM project.
Runtime Environment
When running mindspeed-llm test cases, strictly follow the requirements of the following runtime environment.
- Docker Container:
q4_master - Default Environment Configuration:'source /root/.bashrc'
- Default Working Directory: the current project working directory, denoted as
WORK_DIR - NPU Environment Configuration:'source /usr/local/Ascend/ascend-toolkit/set_env.sh && source /usr/local/Ascend/nnal/atb/set_env.sh'
Input
The user inputs an execution script (such as the run_coverage.sh script) or specifies a test case directory.
Execution Flow
1. Enter the docker container
docker exec -it q4_master /bin/bash
2. Execute the default environment configuration
source /root/.bashrc
3. Enter the project working directory
cd ${WORK_DIR}
4. Run the task Execute the test command or script
# 执行全量代码覆盖率扫描任务
bash tests/run_coverage.sh all
# 执行pipeline所有用例
bash tests/pipeline/pipe_run.sh
# 执行ut测试用例
pytest -s tests/ut/inference/test_inference.py
5. Analyze the run results
Output
Output the test report or coverage report in the form of a markdown file to theTESTdirectory
Example
Execute the full code coverage scan task
docker exec -it q4_master bash -c "source /root/.bashrc && cd ${WORK_DIR} && bash tests/run_coverage.sh all"
Run all pipeline test cases
docker exec -it q4_master bash -c "source /root/.bashrc && cd ${WORK_DIR} && bash tests/pipeline/pipe_run.sh"
Run UT test cases
# 运行一个ut测试用例文件中的所有用例
docker exec -it q4_master bash -c "source /root/.bashrc && cd ${WORK_DIR} && pytest -s tests/pipeline/ut/model_module/test_attention.py"
# 运行一个ut测试用例中的特定测试用例
docker exec -it q4_master bash -c "source /root/.bashrc && cd ${WORK_DIR} && pytest -s tests/pipeline/ut/model_module/test_attention.py::TestAttention::test_alibi_seq8192_bs2_bf16"
Run ST test cases
docker exec -it q4_master bash -c "source /root/.bashrc && cd ${WORK_DIR} && bash tests/pipeline/st/llama2/llama2_tp8_pp1_coc_ptd.sh"