3636
3737 PYTHONPATH="${PWD}" python .ci/scripts/gather_test_models.py --target-os macos --event "${GITHUB_EVENT_NAME}"
3838
39+ test-pip-install-editable-mode-macos :
40+ name : test-pip-install-editable-mode-macos
41+ uses : pytorch/test-infra/.github/workflows/macos_job.yml@main
42+ permissions :
43+ id-token : write
44+ contents : read
45+ strategy :
46+ fail-fast : false
47+ with :
48+ runner : macos-m1-stable
49+ python-version : ' 3.11'
50+ submodules : ' true'
51+ ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
52+ timeout : 90
53+ script : |
54+ # The generic Linux job chooses to use base env, not the one setup by the image
55+ CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
56+ conda activate "${CONDA_ENV}"
57+ # Debug
58+ which pip
59+ bash .ci/scripts/setup-conda.sh
60+ PYTHON_EXECUTABLE=python ${CONDA_RUN} bash ./install_executorch.sh --editable --pybind xnnpack
61+ # Try to import extension library
62+ python -c "from executorch.extension.llm.custom_ops import custom_ops"
63+
3964 test-models-macos :
4065 name : test-models-macos
4166 uses : pytorch/test-infra/.github/workflows/macos_job.yml@main
@@ -374,7 +399,13 @@ jobs:
374399 secrets : inherit
375400 strategy :
376401 matrix :
377- hf_model_repo : [google/gemma-2-2b]
402+ hf_model_id : [
403+ google/gemma-2-2b,
404+ Qwen/Qwen2.5-0.5B,
405+ HuggingFaceTB/SmolLM2-135M,
406+ meta-llama/Llama-3.2-1B,
407+ allenai/OLMo-1B-hf
408+ ]
378409 fail-fast : false
379410 with :
380411 secrets-env : EXECUTORCH_HF_TOKEN
@@ -389,66 +420,39 @@ jobs:
389420 CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
390421 conda activate "${CONDA_ENV}"
391422 PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh cmake
392-
393- echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
394- rm -rf cmake-out
395- cmake \
396- -DCMAKE_INSTALL_PREFIX=cmake-out \
397- -DCMAKE_BUILD_TYPE=Release \
398- -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
399- -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
400- -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
401- -DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
402- -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
403- -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
404- -DEXECUTORCH_BUILD_XNNPACK=ON \
405- -DPYTHON_EXECUTABLE=python \
406- -Bcmake-out .
407- cmake --build cmake-out -j9 --target install --config Release
408-
409- echo "Build llama runner"
410- dir="examples/models/llama"
411- cmake \
412- -DCMAKE_INSTALL_PREFIX=cmake-out \
413- -DCMAKE_BUILD_TYPE=Release \
414- -DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
415- -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
416- -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
417- -DEXECUTORCH_BUILD_XNNPACK=ON \
418- -DPYTHON_EXECUTABLE=python \
419- -Bcmake-out/${dir} \
420- ${dir}
421- cmake --build cmake-out/${dir} -j9 --config Release
422423 echo "::endgroup::"
423424
424- echo "::group::Set up HuggingFace Dependencies"
425- if [ -z "$SECRET_EXECUTORCH_HF_TOKEN" ]; then
426- echo "::error::SECRET_EXECUTORCH_HF_TOKEN is empty. For security reason secrets won't be accessible on forked PRs. Please make sure you submit a non-forked PR."
427- exit 1
428- fi
425+ echo "::group::Set up Hugging Face"
429426 pip install -U "huggingface_hub[cli]"
430427 huggingface-cli login --token $SECRET_EXECUTORCH_HF_TOKEN
428+ git clone https://github.com/huggingface/optimum-executorch
429+ cd optimum-executorch
430+ # There is no release yet, for CI stability, always test from the same commit on main
431+ git checkout 6a7e83f3eee2976fa809335bfb78a45b1ea1cb25
432+ pip install .
431433 pip install accelerate sentencepiece
432434 pip list
433435 echo "::endgroup::"
434436
435- echo "::group::Export to ExecuTorch"
436- TOKENIZER_FILE=tokenizer.model
437- TOKENIZER_BIN_FILE=tokenizer.bin
438- ET_MODEL_NAME=et_model
439- DOWNLOADED_TOKENIZER_FILE_PATH=$(bash .ci/scripts/download_hf_hub.sh --model_id "${{ matrix.hf_model_repo }}" --files "${TOKENIZER_FILE}")
440- if [ -f "$DOWNLOADED_TOKENIZER_FILE_PATH/$TOKENIZER_FILE" ]; then
441- echo "${TOKENIZER_FILE} downloaded successfully at: $DOWNLOADED_TOKENIZER_FILE_PATH"
442- python -m extension.llm.tokenizer.tokenizer -t "$DOWNLOADED_TOKENIZER_FILE_PATH/$TOKENIZER_FILE" -o ./${TOKENIZER_BIN_FILE}
443- ls ./tokenizer.bin
444- else
445- echo "Failed to download ${TOKENIZER_FILE} from ${{ matrix.hf_model_repo }}."
446- exit 1
447- fi
448-
449- python -m extension.export_util.export_hf_model -hfm=${{ matrix.hf_model_repo }} -o ${ET_MODEL_NAME}
450-
451- cmake-out/examples/models/llama/llama_main --model_path=${ET_MODEL_NAME}.pte --tokenizer_path=${TOKENIZER_BIN_FILE} --prompt="My name is"
437+ echo "::group::Export and Run ${{ matrix.hf_model_id }}"
438+ # Pass matrix variable as environment variable
439+ export MODEL_ID="${{ matrix.hf_model_id }}"
440+ python -c "
441+ import os
442+ from optimum.executorch import ExecuTorchModelForCausalLM
443+ from transformers import AutoTokenizer
444+
445+ model_id = os.getenv('MODEL_ID')
446+ print(f'Loading model: {model_id}')
447+ model = ExecuTorchModelForCausalLM.from_pretrained(model_id, recipe='xnnpack')
448+ tokenizer = AutoTokenizer.from_pretrained(model_id)
449+ generated_text = model.text_generation(
450+ tokenizer=tokenizer,
451+ prompt='Simply put, the theory of relativity states that',
452+ max_seq_len=64
453+ )
454+ print(generated_text)
455+ "
452456 echo "::endgroup::"
453457
454458
0 commit comments