Skip to content

Commit d12167b

Browse files
feat: add script for testing new changes (#72)
* feat: add script for testing new changes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update: change user models --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 2ff4ae0 commit d12167b

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

tests/Readme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Tests
2+
3+
This directory contains test scripts to ensure that the loos validator can successfully validate models. It checks if variou supported models and LORAs can be validated.
4+
## Running Tests
5+
6+
To run the tests, use the following command:
7+
8+
```bash
9+
FLOCK_API_KEY=<your_flock_api_key> HF_TOKEN=<your_hf_token> bash tests/test_validation.sh

tests/test_validation.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
3+
python3 -m venv venv
4+
5+
source venv/bin/activate
6+
7+
# Install requirements
8+
echo "Downloading requirements..."
9+
pip install -r requirements.txt > /dev/null 2>&1
10+
11+
declare -A MODEL_MAP=(
12+
["Qwen/Qwen1.5-1.8B-Chat"]="qwen1.5"
13+
["google/gemma-2b"]="gemma"
14+
["microsoft/Phi-3-mini-4k-instruct"]="phi3"
15+
["mistralai/Ministral-8B-Instruct-2410"]="mistral"
16+
["01-ai/Yi-1.5-6B-Chat"]="yi"
17+
["meta-llama/Llama-3.1-8B"]="llama3"
18+
["random-sequence/task-1-microsoft-Phi-3-mini-4k-instruct"]="phi3"
19+
["random-sequence/task-1-microsoft-Phi-3.5-mini-instruct"]="phi3"
20+
["random-sequence/task-1-Qwen-Qwen2.5-7B-Instruct"]="qwen1.5"
21+
["random-sequence/task-2-google-gemma-2-2b-it"]="gemma"
22+
)
23+
24+
# Define models to validate - mix of full models and LORA
25+
MODELS=(
26+
"Qwen/Qwen1.5-1.8B-Chat"
27+
"google/gemma-2b"
28+
"microsoft/Phi-3-mini-4k-instruct"
29+
"mistralai/Ministral-8B-Instruct-2410"
30+
"01-ai/Yi-1.5-6B-Chat"
31+
"meta-llama/Llama-3.1-8B"
32+
"random-sequence/task-1-microsoft-Phi-3-mini-4k-instruct"
33+
"random-sequence/task-1-microsoft-Phi-3.5-mini-instruct"
34+
"random-sequence/task-1-Qwen-Qwen2.5-7B-Instruct"
35+
"random-sequence/task-2-google-gemma-2-2b-it"
36+
)
37+
38+
# Run validation for each model
39+
for MODEL in "${MODELS[@]}"; do
40+
echo "Validating model: $MODEL"
41+
42+
cd src
43+
44+
# Determine the base model based on the model name using the dictionary
45+
BASE_MODEL=${MODEL_MAP[$MODEL]}
46+
47+
if [ -z "$BASE_MODEL" ]; then
48+
echo "Unknown model: $MODEL"
49+
continue
50+
fi
51+
52+
OUTPUT=$(FLOCK_API_KEY="$FLOCK_API_KEY" HF_TOKEN="$HF_TOKEN" python validate.py validate \
53+
--model_name_or_path "$MODEL" \
54+
--base_model "$BASE_MODEL" \
55+
--eval_file ./data/dummy_data.jsonl \
56+
--context_length 4096 \
57+
--max_params 9000000000 \
58+
--local_test \
59+
--lora_only False \
60+
--validation_args_file validation_config.json.example 2>&1)
61+
62+
# Display relevant logs for the current model. Add INFO to see info logs
63+
echo "$OUTPUT" | grep -E " ERROR|WARNING" # Show only INFO, ERROR, and WARNING logs
64+
65+
# Check if model is validated
66+
if echo "$OUTPUT" | grep -q "The model can be correctly validated by validators."; then
67+
echo -e "\e[32m$MODEL \xE2\x9C\x94\e[0m" # Green text and tick symbol
68+
else
69+
# Check for CUDA error
70+
if echo "$OUTPUT" | grep -q "CUDA error"; then
71+
echo -e "$MODEL \xE2\x9D\x8C"
72+
else
73+
echo -e "$MODEL \xE2\x9D\x8C"
74+
echo "Error details: $OUTPUT"
75+
fi
76+
fi
77+
78+
echo "---------------------------------------"
79+
80+
cd ..
81+
done
82+
83+
deactivate

0 commit comments

Comments
 (0)