diff --git a/actions/llama-cpp/README.md b/actions/llama-cpp/README.md new file mode 100644 index 0000000..151dcba --- /dev/null +++ b/actions/llama-cpp/README.md @@ -0,0 +1,15 @@ +# Summary + +Used to run the llama.cpp OpenAI-compatible server. + +## Usage + +```yaml +steps: + - name: + uses: neuralmagic/nm-actions/actions/llama-cpp@main + with: + port: 8000 + model: "aminkhalafi/Phi-3-mini-4k-instruct-Q4_K_M-GGUF" + context-size: 2048 +``` diff --git a/actions/llama-cpp/action.yaml b/actions/llama-cpp/action.yaml new file mode 100644 index 0000000..d94b2aa --- /dev/null +++ b/actions/llama-cpp/action.yaml @@ -0,0 +1,37 @@ +name: "Run llama.cpp" +description: "Run llama.cpp OpenAI compatible web server" + +inputs: + port: + description: "The port of running service" + required: false + default: 8080 + model: + description: "The Hugging Face model" + required: false + default: "aminkhalafi/Phi-3-mini-4k-instruct-Q4_K_M-GGUF" + context-size: + description: "The size of input context size (tokens)" + required: false + default: 2048 + +runs: + using: "composite" + steps: + - name: Install llama.cpp + id: install + shell: bash + run: | + brew install llama.cpp + + - name: Start llama.cpp web server + id: start + shell: bash + run: | + llama-server --hf-repo "${{inputs.port}}" -ctx-size "${{inputs.context-size}}" --port "${{inputs.port}}" & + + - name: Wait llama server to be started + id: wait + shell: bash + run: | + sleep 10 diff --git a/actions/publish_pypi/README.md b/actions/publish_pypi/README.md new file mode 100644 index 0000000..3ff04f8 --- /dev/null +++ b/actions/publish_pypi/README.md @@ -0,0 +1,17 @@ +# Summary + +Used to build and publish packages to internal and public package indexes using tox automation engine. + +## Usage + +```yaml +steps: + - name: + uses: neuralmagic/nm-actions/actions/publisher@main + with: + publish_pypi: false + publish_pypi_internal: true + timestamp: true + prefix: "-nightly" + build_number: ${{ github.event.pull_request.number }} +``` diff --git a/actions/publish_pypi/action.yml b/actions/publish_pypi/action.yml new file mode 100644 index 0000000..ae5e1ed --- /dev/null +++ b/actions/publish_pypi/action.yml @@ -0,0 +1,118 @@ +name: "Build and publish the distribution to the PyPI server" +description: "Build and publish PyPi wheel using tox for ML repos e.g. sparseml, compressed-tensors" + +inputs: + publish_pypi_internal: + description: "Publish the distribution to the internal PyPI server" + required: true + + publish_pypi: + description: "Publish the distribution to the pypi.org" + required: true + + built_type: + description: "Applies a set of rules depending on the environment. Available values: (dev|release|nightly|custom)" + required: true + + custom_package_name: + description: "Custom package name could be used along wtih the 'custom' build_type" + required: false + +outputs: + whlname: + description: "wheel filename" + value: ${{ steps.build.outputs.whlname }} + tarname: + description: "tar.gz filename" + value: ${{ steps.build.outputs.tarname }} + +runs: + using: "composite" + + steps: + - name: Validate input parameters + run: | + if [ "${{ inputs.publish_pypi }}" == "false" ] && [ "${{ inputs.publish_pypi_internal }}" == "false" ]; then + echo "Error: At least one of 'publish_pypi' or 'publish_pypi_internal' must be set to 'true'" + exit 1 + fi + if [ "${{ inputs.built_type }}" == "custom" ] && [ "${{ inputs.custom_package_name }}" == "" ]; then + echo "Error: If 'built_type' is set to 'custom' the 'custom_package_name' must be specified" + exit 1 + fi + + - name: Install tox + run: python3 -m pip install --user tox build + + - name: Build the distribution with tox + id: build + run: | + python3 -m tox -e build + + # suffixes dispatcher + SUFFIX="" + case ${{ inputs.built_type }} in + "dev") + SUFFIX="-dev-${{ github.event.pull_request.number }}" + ;; + "nightly") + SUFFIX="-nightly-$(date +%Y%m%d)" + ;; + "staging") + ;; + "release") + ;; + "custom") + if [[ -z ${{ inputs.custom_package_name }} ]]; then + echo "Error: Custom build_type requires a custom_package_name input" + exit 1 + fi + SUFFIX="" + ;; + *) + echo "Invalid build_type: ${{ inputs.built_type }}" + exit 1 + esac + + echo "::set-output name=suffix::$SUFFIX" + + - name: Rename build artifacts + run: | + # Retrieve package name from previous step + PACKAGE_NAME="${{ inputs.custom_package_name || 'guidellm' }}" + + # Extract version from distribution file name (e.g., guidellm-1.2.3-dev.whl) + VERSION=$(find dist -name "*.whl" | cut -d '-' -f 2) + + # Generate final file name based on build_type and package name + NEW_NAME="${PACKAGE_NAME}${SUFFIX}-${VERSION}.whl" + TAR_NAME="${PACKAGE_NAME}${SUFFIX}-${VERSION}.tar.gz" + + mv dist/* dist/$NEW_NAME + cp dist/$NEW_NAME dist/$TAR_NAME + + # Set outputs for subsequent steps + echo "::set-output name=whlname::$NEW_NAME" + echo "::set-output name=tarname::$TAR_NAME" + + - name: Authenticate to GCP + uses: google-github-actions/auth@v2.1.3 + with: + project_id: ${{ secrets.GCP_PROJECT }} + workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ secrets.NM_PYPI_SA }} + + - name: Upload to Internal PyPI + if: ${{ inputs.publish_pypi_internal }} + uses: neuralmagic/nm-actions/actions/gcp-upload-asset@v1.1.0 + with: + bucket_target: ${{ secrets.GCP_NM_PYPI_DIST }} + asset: ${{ steps.build.outputs.whlname }} + + - name: Publish to Public PyPI + if: ${{ inputs.publish_pypi }} + uses: neuralmagic/nm-actions/actions/publish-whl@v1.0.0 + with: + username: ${{ secrets.PYPI_PUBLIC_USER }} + password: ${{ secrets.PYPI_PUBLIC_AUTH }} + whl: ${{ steps.build.outputs.whlname }}