Skip to content

Commit 0425619

Browse files
authored
feat(lemonade): add FastFlowLM backend for AMD Ryzen AI NPU inference (#19)
1 parent 9e4ab72 commit 0425619

9 files changed

Lines changed: 1205 additions & 3 deletions

aetherpak.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ oci_repository: lemonade-sdk/flatpak
55
branding:
66
index_template: .github/workflows/templates/lemonade.html
77

8+
defaults:
9+
remotes:
10+
amd-npu: https://abn.github.io/flatpaks-amd-npu/amd-npu.flatpakrepo
11+
lemonade: https://lemonade-sdk.github.io/flatpak/lemonade.flatpakrepo
12+
813
apps:
914
- id: ai.lemonade_server.Lemonade
10-
branch: stable
1115
arches:
1216
- x86_64
1317
- aarch64
1418
manifest: ai.lemonade_server.Lemonade/ai.lemonade_server.Lemonade.yaml
15-
builder_args:
16-
- --install-deps-from=flathub
19+
- id: ai.lemonade_server.Lemonade.backends.fastflowlm
20+
arches:
21+
- x86_64
22+
manifest: ai.lemonade_server.Lemonade.backends.fastflowlm/ai.lemonade_server.Lemonade.backends.fastflowlm.yaml
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<component type="addon">
3+
<id>ai.lemonade_server.Lemonade.backends.fastflowlm</id>
4+
<extends>ai.lemonade_server.Lemonade</extends>
5+
<metadata_license>CC0-1.0</metadata_license>
6+
<project_license>MIT</project_license>
7+
<name>FastFlowLM Backend</name>
8+
<summary>AMD Ryzen AI NPU inference backend for Lemonade</summary>
9+
<developer id="com.fastflowlm">
10+
<name>FastFlowLM</name>
11+
</developer>
12+
<icon type="stock">ai.lemonade_server.Lemonade.backends.fastflowlm</icon>
13+
<description>
14+
<p>
15+
This extension adds the FastFlowLM inference backend to Lemonade. Once
16+
installed, Lemonade can select FastFlowLM as one of its backends to serve
17+
large language models directly on AMD Ryzen AI NPUs.
18+
</p>
19+
<p>
20+
FastFlowLM is an NPU-optimized runtime that delivers fast, efficient
21+
language model inference on tile-structured neural processing units. It
22+
provides instant token streaming and support for context windows up to
23+
256k tokens, with multiple AI modalities including reasoning models,
24+
vision, audio, and embeddings.
25+
</p>
26+
</description>
27+
<url type="homepage">https://fastflowlm.com/</url>
28+
<url type="bugtracker">https://github.com/FastFlowLM/FastFlowLM/issues</url>
29+
<provides>
30+
<binary>flm</binary>
31+
</provides>
32+
<releases>
33+
<release version="0.9.43" date="2026-06-09">
34+
<description/>
35+
</release>
36+
</releases>
37+
</component>
19.6 KB
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
id: ai.lemonade_server.Lemonade.backends.fastflowlm
2+
runtime: ai.lemonade_server.Lemonade
3+
runtime-version: 'stable'
4+
5+
sdk: org.freedesktop.Sdk//25.08
6+
sdk-extensions:
7+
- org.freedesktop.Sdk.Extension.xrt
8+
- org.freedesktop.Sdk.Extension.rust-stable
9+
10+
build-extension: true
11+
separate-locales: false
12+
13+
build-options:
14+
strip: true
15+
no-debuginfo: true
16+
17+
cleanup:
18+
- /lib/cmake
19+
- /lib/pkgconfig
20+
- /include/boost
21+
- '*.a'
22+
23+
modules:
24+
- modules/boost.yaml
25+
- modules/fftw3f.yaml
26+
- modules/fastflowlm.yaml
27+
- name: appdata
28+
buildsystem: simple
29+
build-commands:
30+
- install -Dm0644 ai.lemonade_server.Lemonade.backends.fastflowlm.appdata.xml -t ${FLATPAK_DEST}/share/metainfo
31+
- install -Dm0644 ai.lemonade_server.Lemonade.backends.fastflowlm.png ${FLATPAK_DEST}/share/icons/hicolor/256x256/apps/ai.lemonade_server.Lemonade.backends.fastflowlm.png
32+
sources:
33+
- type: file
34+
path: ai.lemonade_server.Lemonade.backends.fastflowlm.appdata.xml
35+
- type: file
36+
path: ai.lemonade_server.Lemonade.backends.fastflowlm.png
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
2+
--- a/src/CMakeLists.txt
3+
+++ b/src/CMakeLists.txt
4+
@@ -229,18 +229,6 @@
5+
- if(FFTW3_PKG_FOUND)
6+
- target_include_directories(flm PUBLIC ${FFTW3_PKG_INCLUDE_DIRS})
7+
- target_link_libraries(flm PUBLIC ${FFTW3_PKG_LIBRARIES})
8+
- else()
9+
- target_link_libraries(flm PUBLIC fftw3)
10+
- endif()
11+
if(FFTW3F_PKG_FOUND)
12+
target_include_directories(flm PUBLIC ${FFTW3F_PKG_INCLUDE_DIRS})
13+
target_link_libraries(flm PUBLIC ${FFTW3F_PKG_LIBRARIES})
14+
else()
15+
target_link_libraries(flm PUBLIC fftw3f)
16+
endif()
17+
- if(FFTW3L_PKG_FOUND)
18+
- target_include_directories(flm PUBLIC ${FFTW3L_PKG_INCLUDE_DIRS})
19+
- target_link_libraries(flm PUBLIC ${FFTW3L_PKG_LIBRARIES})
20+
- else()
21+
- target_link_libraries(flm PUBLIC fftw3l)
22+
- endif()
23+
@@ -347,9 +331,0 @@
24+
-if(NOT WIN32 AND NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr" AND NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr/local")
25+
- install(CODE "
26+
- message(STATUS \"Creating symlink for flm\")
27+
- file(MAKE_DIRECTORY \"$ENV{DESTDIR}/usr/local/bin\")
28+
- execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink
29+
- \"${CMAKE_INSTALL_PREFIX}/bin/flm\"
30+
- \"$ENV{DESTDIR}/usr/local/bin/flm\")"
31+
- )
32+
-endif()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: boost
2+
buildsystem: simple
3+
build-options:
4+
env:
5+
BOOST_JOBS: "-j3"
6+
build-commands:
7+
- ./bootstrap.sh --prefix=$FLATPAK_DEST --with-libraries=atomic,filesystem,program_options,system
8+
- ./b2 -j${FLATPAK_BUILDER_N_JOBS:-4} variant=release threading=multi link=shared,static install
9+
sources:
10+
- type: archive
11+
url: https://archives.boost.io/release/1.81.0/source/boost_1_81_0.tar.gz
12+
sha256: 205666dea9f6a7cfed87c7a6dfbeb52a2c1b9de55712c9c1a87735d7181452b6
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: fastflowlm
2+
buildsystem: simple
3+
build-options:
4+
append-path: /usr/lib/sdk/rust-stable/bin
5+
env:
6+
CARGO_NET_OFFLINE: 'true'
7+
build-commands:
8+
- |
9+
export PKG_CONFIG_PATH="${FLATPAK_DEST}/lib/pkgconfig:${FLATPAK_DEST}/share/pkgconfig"
10+
export LDFLAGS="-L${FLATPAK_DEST}/lib -L${FLATPAK_DEST}/lib64 -L/usr/lib/sdk/xrt/lib -L/usr/lib/sdk/xrt/lib64"
11+
12+
cmake -G Ninja \
13+
-DCMAKE_INSTALL_PREFIX="${FLATPAK_DEST}" \
14+
-DFLM_VERSION=0.9.43 \
15+
-DNPU_VERSION=32.0.203.304 \
16+
-DCMAKE_PREFIX_PATH="${FLATPAK_DEST};/usr/lib/sdk/xrt" \
17+
-DXRT_INCLUDE_DIR=/usr/lib/sdk/xrt/include \
18+
-DXRT_LIB_DIR=/usr/lib/sdk/xrt/lib \
19+
-DCMAKE_XCLBIN_PREFIX="${FLATPAK_DEST}/share/flm" \
20+
.
21+
ninja
22+
ninja install
23+
post-install:
24+
- mkdir -p "${FLATPAK_DEST}/lib"
25+
- cp -pv /usr/lib/sdk/xrt/lib/*.so* "${FLATPAK_DEST}/lib/" || true
26+
- cp -pv /usr/lib/sdk/xrt/lib64/*.so* "${FLATPAK_DEST}/lib/" || true
27+
- cp -a /usr/lib/sdk/xrt/lib/xrt "${FLATPAK_DEST}/lib/" 2>/dev/null || true
28+
- chmod a+rX "${FLATPAK_DEST}/bin/flm"
29+
subdir: src
30+
sources:
31+
- type: git
32+
url: https://github.com/FastFlowLM/FastFlowLM.git
33+
commit: 5324dd73162e7005546d287aa4daeceff56e3b2c
34+
- type: patch
35+
path: 0001-fastflowlm-disable-usr-local-symlink.patch
36+
- type: inline
37+
contents: |
38+
[source.crates-io]
39+
replace-with = "vendored-sources"
40+
41+
[source.vendored-sources]
42+
directory = "/run/build/fastflowlm/cargo/vendor"
43+
dest: third_party/tokenizers-cpp/rust/.cargo
44+
dest-filename: config.toml
45+
- generated-flm-cargo-sources.json
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: fftw3f
2+
buildsystem: simple
3+
build-commands:
4+
- ./configure --prefix=${FLATPAK_DEST}
5+
--libdir=${FLATPAK_DEST}/lib
6+
--enable-shared --disable-static --enable-threads --enable-float --enable-avx
7+
- make -j${FLATPAK_BUILDER_N_JOBS:-4}
8+
- make install
9+
sources:
10+
- type: archive
11+
url: https://www.fftw.org/fftw-3.3.10.tar.gz
12+
sha256: 56c932549852cddcfafdab3820b0200c7742675be92179e59e6215b340e26467

0 commit comments

Comments
 (0)