name: phi4 title: Phi 4 base: core24 summary: Local AI with Phi 4 inference snap description: | Phi 4 is a 14B parameter state-of-the-art open model by Microsoft, built upon a blend of synthetic datasets, filtered public domain websites, and academic books and Q&A datasets, focused on high quality data and advanced reasoning. Use this snap to quickly install an optimized environment for local inference with Phi 4. The snap includes the following hardware-optimized inference engines: * cpu: Optimized for x64 and ARM (armv8, armv9) CPUs * nvidia-gpu: CUDA-enabled GPU acceleration The most suitable engine is automatically selected based on the available hardware. **Install:** `sudo snap install phi4` **Run:** `phi4` Some accelerators require extra drivers to be usable with this snap: https://documentation.ubuntu.com/inference-snaps/how-to/setup/drivers/ **License:** The Phi 4 model is provided by Microsoft under the MIT license. The licenses of all the bundled software can be found after installing the snap at `/snap/phi4/current/usr/share/doc`. icon: snap/gui/icon-256.png website: https://documentation.ubuntu.com/inference-snaps source-code: https://github.com/canonical/phi4-snap issues: https://github.com/canonical/inference-snaps/issues adopt-info: version grade: stable confinement: strict compression: lzo assumes: - snapd2.68 platforms: amd64: arm64: build-on: [arm64] build-for: [arm64] environment: SNAP_COMPONENTS: /snap/$SNAP_INSTANCE_NAME/components/$SNAP_REVISION ARCH_TRIPLET: $CRAFT_ARCH_TRIPLET_BUILD_FOR slots: provider: interface: content content: inference-provider source: read: - $SNAP_COMMON/share/provider plugs: # To allow sideloading models by root home: read: all hooks: install: plugs: &install-plugs - hardware-observe - opengl post-refresh: plugs: *install-plugs parts: version: after: [cli] plugin: nil source: . # To regenerate the git hash on every change build-packages: - jq - git override-pull: | # Do nothing. This significantly reduces build time when sourcing large files. override-build: | set -eo pipefail cli_version=$($CRAFT_STAGE/bin/modelctl version --format=json | jq .cli --raw-output) git_hash=$(git -C "$SNAPCRAFT_PROJECT_DIR" describe --always) craftctl set version="${cli_version#v}+${git_hash}" cli: source: - on amd64: https://github.com/canonical/inference-snaps/releases/download/v2.0.0/modelctl-linux-amd64.tar.xz - on arm64: https://github.com/canonical/inference-snaps/releases/download/v2.0.0/modelctl-linux-arm64.tar.xz plugin: dump override-build: | # For tab completion ln --symbolic ./modelctl bin/phi4 craftctl default cli-dependencies: plugin: nil stage-packages: - pciutils # lspci webui: plugin: dump source: https://github.com/canonical/inference-snaps-webui/releases/download/v1.1.0/inference-snaps-webui.tar.xz organize: "*": webui/ engines: source: engines plugin: dump organize: "*": engines/ models: source: models plugin: dump organize: "*": models/ runtimes: source: runtimes plugin: dump organize: "*": runtimes/ scripts: source: scripts plugin: dump stage-packages: - jq organize: "server.sh": bin/ "server-webui.sh": bin/ model-weights: plugin: cmake source: model-weights override-build: | cp -rf --archive --link --no-dereference ${CRAFT_PART_SRC}/* ${CRAFT_PART_INSTALL} organize: "model-q4-k-m-1-of-2/*": (component/model-q4-k-m-gguf-1-of-2) "model-q4-k-m-2-of-2/*": (component/model-q4-k-m-gguf-2-of-2) prime: # Exclude everything not explicitly organized - -* llamacpp: plugin: dump source: - on amd64: https://github.com/canonical/llama.cpp-builds/releases/download/v1.0.0/llamacpp-amd64.tar.gz - on arm64: https://github.com/canonical/llama.cpp-builds/releases/download/v1.0.0/llamacpp-arm64.tar.gz override-build: | # Move license files to be included in the snap, not the component mkdir -p $CRAFT_PRIME/usr/share/doc/ mv licenses $CRAFT_PRIME/usr/share/doc/llama.cpp craftctl default stage-packages: - libgomp1 organize: "*": (component/llamacpp) llamacpp-cuda: plugin: dump source: - on amd64: https://github.com/canonical/llama.cpp-builds/releases/download/v1.0.0/llamacpp-amd64+cuda12.9.tar.gz - on arm64: https://github.com/canonical/llama.cpp-builds/releases/download/v1.0.0/llamacpp-arm64+cuda12.9.tar.gz override-build: | # Move license files to be included in the snap, not the component mkdir -p $CRAFT_PRIME/usr/share/doc/ mv licenses $CRAFT_PRIME/usr/share/doc/llama.cpp+cuda craftctl default stage-packages: - libgomp1 organize: "*": (component/llamacpp-cuda) # Used for NVIDIA vRAM and CUDA Capability detection. # Only the binary is included to avoid staging libraries, which should instead be provided by the host through the opengl interface. cli-nvidia-smi: plugin: nil build-packages: - nvidia-utils-580 override-build: | mkdir -p $CRAFT_PART_INSTALL/usr/bin cp /usr/bin/nvidia-smi $CRAFT_PART_INSTALL/usr/bin/ license_dir=$CRAFT_PART_INSTALL/usr/share/doc/nvidia-utils-580/ mkdir -p $license_dir cp /usr/share/doc/nvidia-utils-580/copyright $license_dir/ notice: plugin: nil source: NOTICE source-type: file override-build: | license_dir=$CRAFT_PART_INSTALL/usr/share/doc mkdir -p $license_dir cp NOTICE $license_dir/ cp $SNAPCRAFT_PROJECT_DIR/LICENSE $license_dir/ cp $SNAPCRAFT_PROJECT_DIR/LICENSE-phi4 $license_dir/ components: model-q4-k-m-gguf-1-of-2: &model-14b type: standard summary: Phi 4 Q4_K_M quantized GGUF model (part 1 of 2) description: | 14B parameter model quantized to Q4_K_M format for efficient CPU and GPU inference. model-q4-k-m-gguf-2-of-2: <<: *model-14b summary: Phi 4 Q4_K_M quantized GGUF model (part 2 of 2) llamacpp: type: standard summary: llama.cpp using default CPU instruction sets description: LLM inference in C/C++ llamacpp-cuda: type: standard summary: llama.cpp with CUDA backend description: LLM inference in C/C++ apps: phi4: command: bin/modelctl completer: bin/snap-completer.bash plugs: - hardware-observe - opengl - network - desktop # To open the webui in the browser environment: ADDITIONAL_FEATURES: chat, webui server: command: bin/server.sh daemon: simple plugs: - network-bind - hardware-observe - opengl - home server-webui: command: bin/server-webui.sh daemon: simple plugs: - network-bind lint: ignore: - metadata: - license - contact