Skip to content
Merged

Lora fix #19304

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .ci/scripts/test_lora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ cleanup_files() {
rm result*.txt
}

matches_base_response_prefix() {
local output_file="$1"
python - "$output_file" <<'PY'
import pathlib
import re
import sys

text = pathlib.Path(sys.argv[1]).read_text()
pattern = re.compile(
r"^<\|im_start\|>user Calculate 15% of 80\?<\|im_end\|><\|im_start\|>assistant:\n"
r"(?:<think>\n)+"
r"Okay, so I need to calculate 15% of 80\.",
re.MULTILINE,
)
sys.exit(0 if pattern.match(text) else 1)
PY
}

# Hosting lora adapter in personal repo for now.
python -m pip install -q huggingface_hub
HF_ADAPTER_REPO="lucylq/qwen3_06B_lora_math"
Expand Down Expand Up @@ -186,7 +204,7 @@ cmake-out/examples/models/llama/llama_main --model_path=qwen_q.pte --data_paths=
NOW=$(date +"%H:%M:%S")
echo "Finished at ${NOW}"
RESULT=$(cat result.txt)
if [[ "${RESULT}" == "${EXPECTED_QUANT_PREFIX}"* ]]; then
if matches_base_response_prefix result.txt; then
echo "Expected result prefix: ${EXPECTED_QUANT_PREFIX}"
echo "Actual result: ${RESULT}"
echo "Test 3: Success"
Expand Down
20 changes: 19 additions & 1 deletion .ci/scripts/test_lora_multimethod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ cleanup_files() {
rm -f result*.txt
}

matches_base_response_prefix() {
local output_file="$1"
python - "$output_file" <<'PY'
import pathlib
import re
import sys

text = pathlib.Path(sys.argv[1]).read_text()
pattern = re.compile(
r"^<\|im_start\|>user Calculate 15% of 80\?<\|im_end\|><\|im_start\|>assistant:\n"
r"(?:<think>\n)+"
r"Okay, so I need to calculate 15% of 80\.",
re.MULTILINE,
)
sys.exit(0 if pattern.match(text) else 1)
PY
}

# Download LoRA adapter.
python -m pip install -q huggingface_hub
HF_ADAPTER_REPO="lucylq/qwen3_06B_lora_math"
Expand Down Expand Up @@ -107,7 +125,7 @@ NOW=$(date +"%H:%M:%S")
echo "Finished at ${NOW}"

RESULT=$(cat result_base.txt)
if [[ "${RESULT}" == "${EXPECTED_BASE_PREFIX}"* ]]; then
if matches_base_response_prefix result_base.txt; then
echo "Test 2 (base_forward): Success"
else
echo "Test 2 (base_forward): Failure"
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/test_model_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ fi
if [ "$AUDIO_URL" != "" ]; then
curl -L $AUDIO_URL -o ${MODEL_DIR}/$AUDIO_FILE
elif [[ "$MODEL_NAME" == *whisper* ]] || [ "$MODEL_NAME" = "voxtral_realtime" ]; then
conda install -y -c conda-forge "ffmpeg<8"
conda install -y -c conda-forge ffmpeg
pip install datasets soundfile
# We pushd'd into EXECUTORCH_ROOT above, so torch_pin is importable here.
TORCHCODEC_PKG=$(python -c "from torch_pin import torchcodec_spec; print(torchcodec_spec())")
Expand Down
Loading