Repository navigation
Update FLM to 0.9.44 and enable portable FLM for Linux - #2544
Conversation
|
Awesome! When are you planning to merge it? We are trying to find a 26.04 system so we can thoroughly test the portable FLM asap. |
Once you merge the FLM side and tag it will merge this side and we can test E2E. |
a7298b4 to
84aecd2
Compare
PR #2544 enables portable FLM for Linux, but the extraction always uses --strip-components=1. The FLM tarball has files at the root (level: flm, lib/, xclbins/) with no wrapper directory, so stripping component 1 removes filenames entirely. Fix: list archive contents, detect if all entries share a single top-level directory with nested content. Only then use --strip-components=1; otherwise use 0 to preserve the original layout.
PR #2544 enables portable FLM for Linux, but the extraction always uses --strip-components=1. The FLM tarball has files at the root (level: flm, lib/, xclbins/) with no wrapper directory, so stripping component 1 removes filenames entirely. Fix: list archive contents, detect if all entries share a single top-level directory with nested content. Only then use --strip-components=1; otherwise use 0 to preserve the original layout.
7d5a8b9 to
72b2c96
Compare
fl0rianr
left a comment
There was a problem hiding this comment.
Thanks! Looking forward bringing this in.
One thing I think we should fix before merging: FastFlowLMServer::load() now calls install_backend("flm", "npu") unconditionally before get_flm_path(). On Linux, the managed backend install path does not appear to treat an already-installed flm from PATH as an existing backend before the offline/no_fetch/download handling. That means a user with a valid system FLM in PATH could still hit an unnecessary GitHub download, and offline/no_fetch mode could fail before the later PATH lookup gets a chance to use the system FLM.
Could we skip install_backend on Linux when fastflowlm::find_flm_executable() already finds FLM, or otherwise make the install path recognize FLM's PATH install before attempting download/offline handling?
Side note, not blocking: I noticed archive_windows.cpp was updated too. From what I know, Lemonade currently uses zip or 7z assets on Windows, not tarballs. So this may simply be symmetry with the Unix extractor, but I wanted to mention it in case there is a Windows tarball path I missed. If this path is currently unused and was not tested, I think it is fine to address any potential Windows-specific tarball issue when the path is first needed.
It's a good call out. While fixing I looked over all the logic and noticed a bunch of complexity with the handling (code duplication and redundancy). I've adjusted the logic accordingly
It was to make sure that if we started using tarballs on Windows things keep working. I've moved it into a common path to avoid the code duplication. |
fl0rianr
left a comment
There was a problem hiding this comment.
Thanks, this looks much better now. The Linux PATH/offline case looks addressed to me.
Two small things I noticed:
-
The Linux unavailable/status action still points users to installing the FLM system package, while the docs and load path now say Lemonade can auto-install the portable FLM binary if FLM is not in PATH. I think the /system-info action should match that new behavior, probably by using the generic
lemonade backends install flm:npuaction or the Lemonade FLM troubleshooting page instead of only the upstream system package path. -
The new compute_tarball_strip_components() helper seems to return 0 for common tar listings that include an explicit top-level directory entry, e.g.
pkg/followed bypkg/bin/flm. Since pkg/ gets normalized topkgand then treated as a root-level entry,all_same_dirbecomes false. This may not break the current FLM install because executable discovery is recursive, but it does not quite match the helper’s stated behavior. What do you think? A small test for top-level directory entries would make this safer?
Windows tarball question totally fine.
fl0rianr
left a comment
There was a problem hiding this comment.
Thanks, the previous two points look addressed to me now.
One remaining concern to think about: the new PATH-first logic now also changes Windows behavior. Previously Windows always went through install_backend() and find_flm_executable() explicitly avoided PATH, using the Lemonade-managed FLM install dir only. With the new shared resolver, any flm.exe on PATH now skips install_backend() and is preferred over the Lemonade-managed install.
That seems useful for Linux, but for Windows it could let a stale or unrelated PATH flm.exe shadow the managed FLM zip and prevent the pinned Lemonade-managed version from being installed/updated. Since this PR is about the new Linux portable FLM path, could we keep the PATH-bypass Linux-only, or keep Windows as managed-install-first?
Yes - this is intentional to have the same approach on both operating systems.
Then that means a lot of different code paths. Why should they be different? |
fl0rianr
left a comment
There was a problem hiding this comment.
I just wanted to call it out because the old Windows path was managed-install-first.
Looks good to me otherwise, so go for it with a small caveat - I'm not at my 1151-sytem atm and was not able to test it properly.
FastFlowLM portable has a static build of ffmpeg and packages it's own libxrt.
PR #2544 enables portable FLM for Linux, but the extraction always uses --strip-components=1. The FLM tarball has files at the root (level: flm, lib/, xclbins/) with no wrapper directory, so stripping component 1 removes filenames entirely. Fix: list archive contents, detect if all entries share a single top-level directory with nested content. Only then use --strip-components=1; otherwise use 0 to preserve the original layout.
A system-managed FLM (Linux distro package on PATH) must not trigger a GitHub download and must keep working in offline/no_fetch mode. Guard the load-time install_backend so it only fetches when no PATH FLM is present; the managed install dir still goes through install_backend for updates. Unify FLM executable resolution into find_flm_executable() (config bin override, then PATH on Linux, then managed install dir) and reduce get_flm_path() to a single call. Factor the duplicated tarball strip-components detection into a shared header helper.
Replace the Linux-only #ifdef guard around load-time install_backend with a cross-platform find_flm_in_path() check, so a user-managed FLM on PATH is honored on Windows too (no download, works offline/no_fetch). The managed install dir still flows through install_backend for version-pinned updates. Extract find_flm_in_path() and reuse it inside find_flm_executable().
compute_tarball_strip_components() treated an explicit top-level directory entry (e.g. "pkg/" listed before "pkg/bin/flm") as a root-level file, which flipped all_same_dir false and returned strip 0. Distinguish directory entries (trailing slash) from genuine root-level files so listings with an explicit directory entry strip correctly. The FLM Linux /system-info action pointed only at the upstream system package, but Lemonade now auto-installs the portable FLM when none is on PATH. Use the generic backends install action for installable/update states and the Lemonade Linux troubleshooting page for driver/xrt issues, mirroring the Windows branch.
8de1385 to
a5cb8d1
Compare
FLM's classify_unavailable override was added when Linux required a system
package install (no auto-install), so it needed custom guidance. Now that
the portable FLM auto-installs on Linux, the generic fallback ("Backend is
supported but not installed") is correct. Remove the override so FLM shows
the same friendly message as every other backend.
There is no 100% right answer here, but from what I can tell this PR will instantly break Lemonade+FLM on my Windows PC, which would be sad. My Windows PC has a stale copy of system FLM on it, so instead of using my nice up-to-date Lemonade-managed FLM, Lemonade will refer to the stale system copy and refuse to work until I do a manual update This is the reason for the prior FLM-on-Windows policy, it "just works" 100% of the time (at the expense of people maybe having 2 copies of FLM on their system). My preference is always for "it just works". |
Add prefer_system: false to FLM's descriptor config_extra (matching llama.cpp's
pattern). Update find_flm_in_path() to check the config value — PATH binaries
are only used when the user enables {"flm": {"prefer_system": true}} in
config.json. By default, Lemonade's managed FLM install takes precedence.
|
I have adjusted it to have a new
|
0a4a618 to
2e5e81f
Compare
|
Looks good! All PATH usage is gated behind a new config flag flm.prefer_system that defaults to false. |
* Bump FLM version to 0.9.44 * Add support for getting a portable flm asset * Update Linux NPU documentation * debian/control: Drop libxrt and ffmpeg recommends FastFlowLM portable has a static build of ffmpeg and packages it's own libxrt. * Detect tarball layout to avoid stripping root-level entries PR #2544 enables portable FLM for Linux, but the extraction always uses --strip-components=1. The FLM tarball has files at the root (level: flm, lib/, xclbins/) with no wrapper directory, so stripping component 1 removes filenames entirely. Fix: list archive contents, detect if all entries share a single top-level directory with nested content. Only then use --strip-components=1; otherwise use 0 to preserve the original layout. * Skip FLM backend install when a system FLM is on PATH A system-managed FLM (Linux distro package on PATH) must not trigger a GitHub download and must keep working in offline/no_fetch mode. Guard the load-time install_backend so it only fetches when no PATH FLM is present; the managed install dir still goes through install_backend for updates. Unify FLM executable resolution into find_flm_executable() (config bin override, then PATH on Linux, then managed install dir) and reduce get_flm_path() to a single call. Factor the duplicated tarball strip-components detection into a shared header helper. * Guard FLM install on PATH lookup instead of platform ifdef Replace the Linux-only #ifdef guard around load-time install_backend with a cross-platform find_flm_in_path() check, so a user-managed FLM on PATH is honored on Windows too (no download, works offline/no_fetch). The managed install dir still flows through install_backend for version-pinned updates. Extract find_flm_in_path() and reuse it inside find_flm_executable(). * Fix tarball strip detection and align FLM Linux status action compute_tarball_strip_components() treated an explicit top-level directory entry (e.g. "pkg/" listed before "pkg/bin/flm") as a root-level file, which flipped all_same_dir false and returned strip 0. Distinguish directory entries (trailing slash) from genuine root-level files so listings with an explicit directory entry strip correctly. The FLM Linux /system-info action pointed only at the upstream system package, but Lemonade now auto-installs the portable FLM when none is on PATH. Use the generic backends install action for installable/update states and the Lemonade Linux troubleshooting page for driver/xrt issues, mirroring the Windows branch. * Remove FLM custom classify_unavailable override FLM's classify_unavailable override was added when Linux required a system package install (no auto-install), so it needed custom guidance. Now that the portable FLM auto-installs on Linux, the generic fallback ("Backend is supported but not installed") is correct. Remove the override so FLM shows the same friendly message as every other backend. * Gate FLM PATH lookup behind prefer_system config Add prefer_system: false to FLM's descriptor config_extra (matching llama.cpp's pattern). Update find_flm_in_path() to check the config value — PATH binaries are only used when the user enables {"flm": {"prefer_system": true}} in config.json. By default, Lemonade's managed FLM install takes precedence. * Fallback to system FLM if portable fails to install even if prefer_system turned off * Use portable FLM for CI on Linux
…2544) * Bump FLM version to 0.9.44 * Add support for getting a portable flm asset * Update Linux NPU documentation * debian/control: Drop libxrt and ffmpeg recommends FastFlowLM portable has a static build of ffmpeg and packages it's own libxrt. * Detect tarball layout to avoid stripping root-level entries PR lemonade-sdk#2544 enables portable FLM for Linux, but the extraction always uses --strip-components=1. The FLM tarball has files at the root (level: flm, lib/, xclbins/) with no wrapper directory, so stripping component 1 removes filenames entirely. Fix: list archive contents, detect if all entries share a single top-level directory with nested content. Only then use --strip-components=1; otherwise use 0 to preserve the original layout. * Skip FLM backend install when a system FLM is on PATH A system-managed FLM (Linux distro package on PATH) must not trigger a GitHub download and must keep working in offline/no_fetch mode. Guard the load-time install_backend so it only fetches when no PATH FLM is present; the managed install dir still goes through install_backend for updates. Unify FLM executable resolution into find_flm_executable() (config bin override, then PATH on Linux, then managed install dir) and reduce get_flm_path() to a single call. Factor the duplicated tarball strip-components detection into a shared header helper. * Guard FLM install on PATH lookup instead of platform ifdef Replace the Linux-only #ifdef guard around load-time install_backend with a cross-platform find_flm_in_path() check, so a user-managed FLM on PATH is honored on Windows too (no download, works offline/no_fetch). The managed install dir still flows through install_backend for version-pinned updates. Extract find_flm_in_path() and reuse it inside find_flm_executable(). * Fix tarball strip detection and align FLM Linux status action compute_tarball_strip_components() treated an explicit top-level directory entry (e.g. "pkg/" listed before "pkg/bin/flm") as a root-level file, which flipped all_same_dir false and returned strip 0. Distinguish directory entries (trailing slash) from genuine root-level files so listings with an explicit directory entry strip correctly. The FLM Linux /system-info action pointed only at the upstream system package, but Lemonade now auto-installs the portable FLM when none is on PATH. Use the generic backends install action for installable/update states and the Lemonade Linux troubleshooting page for driver/xrt issues, mirroring the Windows branch. * Remove FLM custom classify_unavailable override FLM's classify_unavailable override was added when Linux required a system package install (no auto-install), so it needed custom guidance. Now that the portable FLM auto-installs on Linux, the generic fallback ("Backend is supported but not installed") is correct. Remove the override so FLM shows the same friendly message as every other backend. * Gate FLM PATH lookup behind prefer_system config Add prefer_system: false to FLM's descriptor config_extra (matching llama.cpp's pattern). Update find_flm_in_path() to check the config value — PATH binaries are only used when the user enables {"flm": {"prefer_system": true}} in config.json. By default, Lemonade's managed FLM install takes precedence. * Fallback to system FLM if portable fails to install even if prefer_system turned off * Use portable FLM for CI on Linux
|
@superm1 Well it broke NPU detection for me: Additionally on host system: Lemonade GUI is not even showing FastFlowLM as an option to install. Freshly pulled lemonade-server docker container and updated app from Flatpak. Both to 11.0.0 Full relevant logAny ideas what could go wrong here? |
I would guess you're missing libreadline8 in the container (we just fixed that on main). If that's not it, open a new ticket please rather than comment on a PR. |
FLM 0.9.44 has a portable Linux release available, adjust Lemonade to optionally use it.