* Change dependency version for langchain uts * Downgrade pandas version instead; and update example readme accordingly
		
			
				
	
	
		
			188 lines
		
	
	
	
		
			9 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			188 lines
		
	
	
	
		
			9 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
name: LLM Unit Tests
 | 
						|
 | 
						|
# Cancel previous runs in the PR when you push new commits
 | 
						|
concurrency:
 | 
						|
  group: ${{ github.workflow }}-llm-unittest-${{ github.event.pull_request.number || github.run_id }}
 | 
						|
  cancel-in-progress: true
 | 
						|
 | 
						|
# Controls when the action will run.
 | 
						|
on:
 | 
						|
  # Triggers the workflow on push or pull request events but only for the main branch
 | 
						|
  push:
 | 
						|
    branches: [main]
 | 
						|
    paths:
 | 
						|
      - "python/llm/**"
 | 
						|
      - ".github/workflows/llm_unit_tests.yml"
 | 
						|
      - ".github/workflows/llm-binary-build.yml"
 | 
						|
      - ".github/actions/llm/setup-llm-env/action.yml"
 | 
						|
      - ".github/actions/llm/remove-llm-env/action.yml"
 | 
						|
      - ".github/actions/llm/cli-test-linux/action.yml"
 | 
						|
      - ".github/actions/llm/cli-test-windows/action.yml"
 | 
						|
      - ".github/actions/llm/download-llm-binary/action.yml"
 | 
						|
  pull_request:
 | 
						|
    branches: [main]
 | 
						|
    paths:
 | 
						|
      - "python/llm/**"
 | 
						|
      - ".github/workflows/llm_unit_tests.yml"
 | 
						|
      - ".github/workflows/llm-binary-build.yml"
 | 
						|
      - ".github/actions/llm/setup-llm-env/action.yml"
 | 
						|
      - ".github/actions/llm/remove-llm-env/action.yml"
 | 
						|
      - ".github/actions/llm/cli-test-linux/action.yml"
 | 
						|
      - ".github/actions/llm/cli-test-windows/action.yml"
 | 
						|
      - ".github/actions/llm/download-llm-binary/action.yml"
 | 
						|
  workflow_dispatch:
 | 
						|
  workflow_call:
 | 
						|
 | 
						|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
 | 
						|
jobs:
 | 
						|
  llm-cpp-build:
 | 
						|
    uses: ./.github/workflows/llm-binary-build.yml
 | 
						|
  llm-unit-test:
 | 
						|
    needs: llm-cpp-build
 | 
						|
    strategy:
 | 
						|
      fail-fast: false
 | 
						|
      matrix:
 | 
						|
        include:
 | 
						|
          - os: windows
 | 
						|
            instruction: avx2
 | 
						|
            python-version: "3.9"
 | 
						|
          - os: ubuntu-20.04-lts
 | 
						|
            instruction: avx512
 | 
						|
            python-version: "3.9"
 | 
						|
    runs-on: [self-hosted, llm, "${{matrix.instruction}}", "${{matrix.os}}"]
 | 
						|
    env:
 | 
						|
      THREAD_NUM: 24
 | 
						|
      ANALYTICS_ZOO_ROOT: ${{ github.workspace }}
 | 
						|
    steps:
 | 
						|
      - name: Set model directories
 | 
						|
        shell: bash
 | 
						|
        run: |
 | 
						|
          echo "DATASET_DIR=${{ github.workspace }}/../llm/datasets" >> "$GITHUB_ENV"
 | 
						|
          echo "ORIGIN_DIR=${{ github.workspace }}/../llm/origin-models" >> "$GITHUB_ENV"
 | 
						|
          echo "INT4_CKPT_DIR=${{ github.workspace }}/../llm/converted-models" >> "$GITHUB_ENV"          
 | 
						|
      - name: Create model directories
 | 
						|
        shell: bash
 | 
						|
        run: |
 | 
						|
          if [ ! -d $DATASET_DIR ]; then
 | 
						|
            mkdir -p $DATASET_DIR
 | 
						|
          fi
 | 
						|
          if [ ! -d $ORIGIN_DIR ]; then
 | 
						|
            mkdir -p $ORIGIN_DIR
 | 
						|
          fi
 | 
						|
          if [ ! -d $INT4_CKPT_DIR ]; then
 | 
						|
            mkdir -p $INT4_CKPT_DIR
 | 
						|
          fi          
 | 
						|
      - name: Set environment variables
 | 
						|
        shell: bash
 | 
						|
        run: |
 | 
						|
          echo "SPEECH_DATASET_PATH=${DATASET_DIR}/librispeech_asr_dummy" >> "$GITHUB_ENV"
 | 
						|
          echo "COMMON_VOICE_PATH=${DATASET_DIR}/common_voice" >> "$GITHUB_ENV"
 | 
						|
 | 
						|
          echo "LLAMA_ORIGIN_PATH=${ORIGIN_DIR}/llama-7b-hf" >> "$GITHUB_ENV"
 | 
						|
          echo "BLOOM_ORIGIN_PATH=${ORIGIN_DIR}/bloom-7b1" >> "$GITHUB_ENV"
 | 
						|
          echo "ORIGINAL_CHATGLM2_6B_PATH=${ORIGIN_DIR}/chatglm2-6b" >> "$GITHUB_ENV"
 | 
						|
          echo "ORIGINAL_REPLIT_CODE_PATH=${ORIGIN_DIR}/replit-code-v1-3b" >> "$GITHUB_ENV"
 | 
						|
          echo "ORIGINAL_WHISPER_TINY_PATH=${ORIGIN_DIR}/whisper-tiny" >> "$GITHUB_ENV"
 | 
						|
 | 
						|
          echo "LLAMA_INT4_CKPT_PATH=${INT4_CKPT_DIR}/bigdl_llm_llama_7b_q4_0.bin" >> "$GITHUB_ENV"
 | 
						|
          echo "GPTNEOX_INT4_CKPT_PATH=${INT4_CKPT_DIR}/bigdl_llm_redpajama_7b_q4_0.bin" >> "$GITHUB_ENV"
 | 
						|
          echo "BLOOM_INT4_CKPT_PATH=${INT4_CKPT_DIR}/bigdl_llm_bloom_7b_q4_0.bin" >> "$GITHUB_ENV"
 | 
						|
          echo "STARCODER_INT4_CKPT_PATH=${INT4_CKPT_DIR}/bigdl_llm_santacoder_1b_q4_0.bin" >> "$GITHUB_ENV"
 | 
						|
          echo "CHATGLM_INT4_CKPT_PATH=${INT4_CKPT_DIR}/chatglm2-6b-q4_0.bin" >> "$GITHUB_ENV"          
 | 
						|
      - uses: actions/checkout@v3
 | 
						|
      - name: Set up Python ${{ matrix.python-version }}
 | 
						|
        uses: actions/setup-python@v4
 | 
						|
        with:
 | 
						|
          python-version: ${{ matrix.python-version }}
 | 
						|
      - name: Install dependencies
 | 
						|
        shell: bash
 | 
						|
        run: |
 | 
						|
          python -m pip install --upgrade pip
 | 
						|
          python -m pip install --upgrade setuptools==58.0.4
 | 
						|
          python -m pip install --upgrade wheel          
 | 
						|
 | 
						|
      - name: Download llm binary
 | 
						|
        uses: ./.github/actions/llm/download-llm-binary
 | 
						|
 | 
						|
      - name: Run LLM install (all) test
 | 
						|
        uses: ./.github/actions/llm/setup-llm-env
 | 
						|
 | 
						|
      - name: Download ckpt & original models
 | 
						|
        shell: bash
 | 
						|
        run: |
 | 
						|
          if [ ! -e $LLAMA_INT4_CKPT_PATH ]; then
 | 
						|
            echo "Directory $LLAMA_INT4_CKPT_PATH not found. Downloading from FTP server..."
 | 
						|
            echo "wget --no-verbose $LLM_FTP_URL/llm/ggml-actions/stable/bigdl_llm_llama_7b_q4_0.bin -P $INT4_CKPT_DIR"
 | 
						|
            wget --no-verbose $LLM_FTP_URL/llm/ggml-actions/stable/bigdl_llm_llama_7b_q4_0.bin -P $INT4_CKPT_DIR
 | 
						|
          fi
 | 
						|
          if [ ! -e $GPTNEOX_INT4_CKPT_PATH ]; then
 | 
						|
            echo "Directory $GPTNEOX_INT4_CKPT_PATH not found. Downloading from FTP server..."
 | 
						|
            wget --no-verbose $LLM_FTP_URL/llm/ggml-actions/stable/bigdl_llm_redpajama_7b_q4_0.bin -P $INT4_CKPT_DIR
 | 
						|
          fi
 | 
						|
          if [ ! -e $BLOOM_INT4_CKPT_PATH ]; then
 | 
						|
            echo "Directory $BLOOM_INT4_CKPT_PATH not found. Downloading from FTP server..."
 | 
						|
            wget --no-verbose $LLM_FTP_URL/llm/ggml-actions/stable/bigdl_llm_bloom_7b_q4_0.bin -P $INT4_CKPT_DIR
 | 
						|
          fi
 | 
						|
          if [ ! -e $STARCODER_INT4_CKPT_PATH ]; then
 | 
						|
            echo "Directory $STARCODER_INT4_CKPT_PATH not found. Downloading from FTP server..."
 | 
						|
            wget --no-verbose $LLM_FTP_URL/llm/ggml-actions/stable/bigdl_llm_santacoder_1b_q4_0.bin -P $INT4_CKPT_DIR
 | 
						|
          fi
 | 
						|
          # if [ ! -e $CHATGLM_INT4_CKPT_PATH ]; then
 | 
						|
          #   echo "Directory $CHATGLM_INT4_CKPT_PATH not found. Downloading from FTP server..."
 | 
						|
          #   wget --no-verbose $LLM_FTP_URL/llm/ggml-actions/stable/chatglm2-6b-q4_0.bin -P $INT4_CKPT_DIR
 | 
						|
          # fi
 | 
						|
          if [ ! -d $ORIGINAL_CHATGLM2_6B_PATH ]; then
 | 
						|
            echo "Directory $ORIGINAL_CHATGLM2_6B_PATH not found. Downloading from FTP server..."
 | 
						|
            echo "wget -r -nH --no-verbose --cut-dirs=1 $LLM_FTP_URL/llm/chatglm2-6b -P $ORIGIN_DIR"            
 | 
						|
            wget -r -nH --no-verbose --cut-dirs=1 $LLM_FTP_URL/llm/chatglm2-6b -P $ORIGIN_DIR
 | 
						|
          fi
 | 
						|
          if [ ! -d $ORIGINAL_REPLIT_CODE_PATH ]; then
 | 
						|
            echo "Directory $ORIGINAL_REPLIT_CODE_PATH not found. Downloading from FTP server..."
 | 
						|
            echo "wget -r -nH --no-verbose --cut-dirs=1 $LLM_FTP_URL/llm/replit-code-v1-3b -P $ORIGIN_DIR"
 | 
						|
            wget -r -nH --no-verbose --cut-dirs=1 $LLM_FTP_URL/llm/replit-code-v1-3b -P $ORIGIN_DIR
 | 
						|
          fi
 | 
						|
          if [ ! -d $ORIGINAL_WHISPER_TINY_PATH ]; then
 | 
						|
            echo "Directory $ORIGINAL_WHISPER_TINY_PATH not found. Downloading from FTP server..."
 | 
						|
            echo "wget -r -nH --no-verbose --cut-dirs=1 $LLM_FTP_URL/llm/whisper-tiny -P $ORIGIN_DIR"
 | 
						|
            wget -r -nH --no-verbose --cut-dirs=1 $LLM_FTP_URL/llm/whisper-tiny -P $ORIGIN_DIR
 | 
						|
          fi
 | 
						|
          if [ ! -d $LLAMA_ORIGIN_PATH ]; then
 | 
						|
            echo "Directory $LLAMA_ORIGIN_PATH not found. Downloading from FTP server..."
 | 
						|
            echo "wget --no-verbose $LLM_FTP_URL/llm/llama-7b-hf -P $ORIGIN_DIR"
 | 
						|
            wget -r -nH --no-verbose --cut-dirs=1 $LLM_FTP_URL/llm/llama-7b-hf -P $ORIGIN_DIR
 | 
						|
          fi
 | 
						|
          if [ ! -d $BLOOM_ORIGIN_PATH ]; then
 | 
						|
            echo "Directory $BLOOM_ORIGIN_PATH not found. Downloading from FTP server..."
 | 
						|
            echo "wget --no-verbose $LLM_FTP_URL/llm/bloom-7b1 -P $ORIGIN_DIR"
 | 
						|
            wget -r -nH --no-verbose --cut-dirs=1 $LLM_FTP_URL/llm/bloom-7b1 -P $ORIGIN_DIR
 | 
						|
          fi
 | 
						|
          if [ ! -d $SPEECH_DATASET_PATH ]; then
 | 
						|
            echo "Directory $SPEECH_DATASET_PATH not found. Downloading from FTP server..."
 | 
						|
            echo "wget -r -nH --no-verbose --cut-dirs=2 $LLM_FTP_URL/llm/datasets/librispeech_asr_dummy -P $DATASET_DIR"
 | 
						|
            wget -r -nH --no-verbose --cut-dirs=2 $LLM_FTP_URL/llm/datasets/librispeech_asr_dummy -P $DATASET_DIR
 | 
						|
          fi
 | 
						|
          if [ ! -d $COMMON_VOICE_PATH ]; then
 | 
						|
            echo "Directory $COMMON_VOICE_PATH not found. Downloading from FTP server..."
 | 
						|
            echo "wget -r -nH --no-verbose --cut-dirs=2 $LLM_FTP_URL/llm/datasets/common_voice -P $DATASET_DIR"
 | 
						|
            wget -r -nH --no-verbose --cut-dirs=2 $LLM_FTP_URL/llm/datasets/common_voice -P $DATASET_DIR
 | 
						|
          fi          
 | 
						|
 | 
						|
      - name: Run LLM cli test (Linux)
 | 
						|
        if: runner.os == 'Linux' 
 | 
						|
        uses: ./.github/actions/llm/cli-test-linux
 | 
						|
      - name: Run LLM cli test (Windows)
 | 
						|
        if: runner.os == 'Windows' 
 | 
						|
        uses: ./.github/actions/llm/cli-test-windows
 | 
						|
      - name: Run LLM inference test
 | 
						|
        shell: bash
 | 
						|
        run: |
 | 
						|
          python -m pip install einops datasets librosa openai-whisper
 | 
						|
          bash python/llm/test/run-llm-inference-tests.sh          
 | 
						|
      - name: Run LLM langchain test
 | 
						|
        shell: bash
 | 
						|
        run: |
 | 
						|
          pip install -U langchain==0.0.184
 | 
						|
          pip install -U chromadb==0.3.25
 | 
						|
          pip install -U pandas==2.0.3
 | 
						|
          pip install -U typing_extensions==4.5.0
 | 
						|
          bash python/llm/test/run-llm-langchain-tests.sh          
 |