-
Notifications
You must be signed in to change notification settings - Fork 1k
New modules: Llamacpp-python/run and huggingface/download for allowing to run simple text workloads with local LLMs #11053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
toniher
wants to merge
37
commits into
nf-core:master
Choose a base branch
from
biocorecrg:llamacpp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
7f1b7d7
adding modules for downloading and running gguf modules
toniher 9031f48
adding docker support
toniher 04cd556
allow custom HF_HOME cache input and other fixes
toniher 537a891
several test fixes
toniher 20b5d26
Upgrade problem with versions and test
toniher c9997f5
fix precommit linting
toniher 5035e82
fix yaml for prettier
toniher 2c796de
fix retrieval of version for huggingface
toniher 4f64bac
Merge branch 'nf-core:master' into llamacpp
toniher ff7039c
importing nextflow.config from HF_DOWNLOAD
toniher 7a3f8fc
Merge branch 'llamacpp' of github.com:biocorecrg/nf-core-modules into…
toniher fb1768c
adding hf_cache for setup as well
toniher ac7f44c
moving HF_DOWNLOAD to HUGGINGFACE_DOWNLOAD https://nf-co.re/docs/guid…
toniher 26168b7
Update modules/nf-core/huggingface/download/tests/main.nf.test
toniher 6dfff97
more detail and naming of Hugging Face
toniher 2d171ca
Merge remote-tracking branch 'upstream/master' into llamacpp
toniher ee04a27
Merge branch 'llamacpp' of github.com:biocorecrg/nf-core-modules into…
toniher 3021074
linting modules using
toniher 4630e5a
generate files on the fly
toniher 53c7826
rmed data files for tests
toniher 4156db0
upgrade tests to work on the fly and updated snaps
toniher 421603e
upgrading tests - adding new smollm3
toniher af5eadd
Update modules/nf-core/llamacpp-python/run/main.nf
toniher 02d3f6d
Update modules/nf-core/llamacpp-python/run/main.nf
toniher 297f503
Update modules/nf-core/llamacpp-python/run/main.nf
toniher ac61a56
Moving name of the module, script name and adapting tests and stubs
toniher ca4721b
update tests
toniher 8fdffea
Merge branch 'nf-core:master' into llamacpp
toniher 9a0d9f3
Merge branch 'llamacpp' of github.com:biocorecrg/nf-core-modules into…
toniher d65181d
update task.accelerator
toniher cd3d1b9
moving all assertions into the same snapshot
toniher fb81365
removed unneded nextflow.config for test
toniher 6f2affa
Merge branch 'nf-core:master' into llamacpp
toniher dfadccb
addressing some coments, such as cache_dir
toniher 1dbb3e9
lint didn't like, so out
toniher bfe3bf9
script moved to work as template and corresponding changes to version…
toniher 0d594f5
Merge branch 'nf-core:master' into llamacpp
toniher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json | ||
| channels: | ||
| - conda-forge | ||
| dependencies: | ||
| - conda-forge::huggingface_hub=1.6.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| process HF_DOWNLOAD { | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| tag "$meta.id" | ||
| label 'process_medium' | ||
|
|
||
| conda "${moduleDir}/environment.yml" | ||
| container "community.wave.seqera.io/library/huggingface_hub:1.6.0--c106a7f9664ca39b" | ||
|
|
||
| input: | ||
| tuple val(meta), val(hf_repo), val(hf_file), val(hf_home) | ||
|
|
||
| output: | ||
| tuple val(meta), path(hf_file), emit: output | ||
| tuple val("${task.process}"), val("huggingface_hub"), eval("hf --version 2>&1 | tail -n1 | awk '{print \$NF}'"), topic: versions, emit: versions_huggingface_hub | ||
|
|
||
| when: | ||
| task.ext.when == null || task.ext.when | ||
|
|
||
| script: | ||
| def hf_home_resolved = hf_home ?: "${workflow.projectDir}/hf_cache" | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
| export HF_HOME="${hf_home_resolved}" | ||
| export HF_HUB_CACHE=\$HF_HOME | ||
| hf download ${hf_repo} ${hf_file} --local-dir \$PWD | ||
| """ | ||
|
|
||
| stub: | ||
| """ | ||
| touch ${hf_file} | ||
toniher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """ | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| name: hf_download | ||
| description: Tool for downloading models from HuggingFace | ||
| keywords: | ||
| - llm | ||
| - llama | ||
| - ai | ||
| tools: | ||
| - huggingface_hub: | ||
| description: "HuggingFace Hub CLI interface" | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| homepage: "https://huggingface.co/docs/huggingface_hub/guides/cli" | ||
| licence: | ||
| - "MIT" | ||
| identifier: "" | ||
| input: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]`- prompt_file: | ||
| - hf_repo: | ||
| type: string | ||
| description: HuggingFace repository | ||
| - hf_file: | ||
| type: string | ||
| description: HuggingFace GGUF file | ||
| - hf_home: | ||
| type: string | ||
| description: HuggingFace default cache directory | ||
| output: | ||
| output: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]` | ||
| - hf_file: | ||
| type: file | ||
| description: Downloaded HuggingFace GGUF file | ||
| ontologies: [] | ||
| versions_huggingface_hub: | ||
| - - ${task.process}: | ||
| type: string | ||
| description: The name of the process | ||
| - huggingface_hub: | ||
| type: string | ||
| description: The name of the tool | ||
| - hf --version 2>&1 | tail -n1 | awk '{print \$NF}': | ||
| type: eval | ||
| description: The expression to obtain the version of the tool | ||
| topics: | ||
| versions: | ||
| - - ${task.process}: | ||
| type: string | ||
| description: The name of the process | ||
| - huggingface_hub: | ||
| type: string | ||
| description: The name of the tool | ||
| - hf --version 2>&1 | tail -n1 | awk '{print \$NF}': | ||
| type: eval | ||
| description: The expression to obtain the version of the tool | ||
| authors: | ||
| - "@toniher" | ||
| - "@lucacozzuto" | ||
| maintainers: | ||
| - "@toniher" | ||
| - "@lucacozzuto" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| nextflow_process { | ||
|
|
||
| name "Test Process HF_DOWNLOAD" | ||
| script "../main.nf" | ||
| process "HF_DOWNLOAD" | ||
|
|
||
| tag "modules" | ||
| tag "modules_nfcore" | ||
| tag "huggingface" | ||
| tag "huggingface/download" | ||
|
|
||
| test("download gguf file") { | ||
|
|
||
| when { | ||
| process { | ||
| """ | ||
| input[0] = [ | ||
| [ id:'test_model' ], | ||
| "ggml-org/gemma-3-1b-it-GGUF", | ||
| "gemma-3-1b-it-Q4_K_M.gguf", | ||
| "./hf_cache" | ||
| ] | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| then { | ||
| assertAll( | ||
| { assert process.success }, | ||
| { assert process.out.output.size() == 1 }, | ||
| { assert process.out.output[0][0] == [ id:'test_model' ] }, | ||
| { assert file(process.out.output[0][1]).name == "gemma-3-1b-it-Q4_K_M.gguf" }, | ||
| { assert file(process.out.output[0][1]).size() > 0 }, | ||
| { assert snapshot(process.out.findAll { key, val -> key.startsWith('versions') }).match() } | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| } | ||
| } | ||
|
|
||
| test("stub - download gguf file") { | ||
|
|
||
| options "-stub" | ||
|
|
||
| when { | ||
| process { | ||
| """ | ||
| input[0] = [ | ||
| [ id:'test_model' ], | ||
| "ggml-org/gemma-3-1b-it-GGUF", | ||
| "gemma-3-1b-it-Q4_K_M.gguf", | ||
| "./hf_cache" | ||
| ] | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| then { | ||
| assertAll( | ||
| { assert process.success }, | ||
| { assert process.out.output.size() == 1 }, | ||
| { assert process.out.output[0][0] == [ id:'test_model' ] }, | ||
| { assert file(process.out.output[0][1]).name == "gemma-3-1b-it-Q4_K_M.gguf" }, | ||
| { assert snapshot(process.out.findAll { key, val -> key.startsWith('versions') }).match() } | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| } | ||
| } | ||
| } | ||
38 changes: 38 additions & 0 deletions
38
modules/nf-core/huggingface/download/tests/main.nf.test.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "stub - download gguf file": { | ||
| "content": [ | ||
| { | ||
| "versions_huggingface_hub": [ | ||
| [ | ||
| "HF_DOWNLOAD", | ||
| "huggingface_hub", | ||
| "1.6.0" | ||
| ] | ||
| ] | ||
| } | ||
| ], | ||
| "timestamp": "2026-03-26T08:39:57.919278809", | ||
| "meta": { | ||
| "nf-test": "0.9.5", | ||
| "nextflow": "25.10.4" | ||
| } | ||
| }, | ||
| "download gguf file": { | ||
| "content": [ | ||
| { | ||
| "versions_huggingface_hub": [ | ||
| [ | ||
| "HF_DOWNLOAD", | ||
| "huggingface_hub", | ||
| "1.6.0" | ||
| ] | ||
| ] | ||
| } | ||
| ], | ||
| "timestamp": "2026-03-26T08:38:24.630341776", | ||
| "meta": { | ||
| "nf-test": "0.9.5", | ||
| "nextflow": "25.10.4" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| nextflow.enable.moduleBinaries = true | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| process { | ||
famosab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| withName: 'HF_DOWNLOAD' { | ||
| containerOptions = { workflow.profile.contains('docker') ? "--volume ${projectDir}/hf_cache:${projectDir}/hf_cache" : '' } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| FROM nvidia/cuda:12.4.1-devel-ubuntu22.04 | ||
|
|
||
| RUN apt-get update && apt-get install -y python3 python3-pip | ||
| RUN pip3 install llama-cpp-python \ | ||
| --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json | ||
| channels: | ||
| - conda-forge | ||
| - bioconda | ||
| dependencies: | ||
| - conda-forge::llama-cpp-python=0.3.16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| process LLAMACPP_PYTHON_RUN { | ||
| tag "$meta.id" | ||
| label 'process_medium' | ||
| label 'process_gpu' | ||
|
|
||
| conda "${moduleDir}/environment.yml" | ||
| container "${ task.ext.use_gpu ? 'quay.io/nf-core/llama-cpp-python:0.1.9' : 'community.wave.seqera.io/library/llama-cpp-python:0.3.16--b351398cd0ea7fc5' }" | ||
|
|
||
| input: | ||
| tuple val(meta), path(prompt_file), path(gguf_model) | ||
|
|
||
| output: | ||
| tuple val(meta), path("output.txt"), emit: output | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| tuple val("${task.process}"), val("llama-cpp-python"), eval("python3 -c 'import llama_cpp; print(llama_cpp.__version__)'"), topic: versions, emit: versions_llama_cpp_python | ||
|
|
||
| when: | ||
| task.ext.when == null || task.ext.when | ||
|
|
||
| script: | ||
| def args = task.ext.args ?: '' | ||
| prefix = task.ext.prefix ?: "${meta.id}" | ||
| """ | ||
| llamacpp-python.py \ | ||
| --model ${gguf_model} \ | ||
| --messages ${prompt_file} \ | ||
| --output output.txt \ | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ${args} | ||
| """ | ||
|
|
||
| stub: | ||
| prefix = task.ext.prefix ?: "${meta.id}" | ||
| """ | ||
| touch output.txt | ||
|
|
||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: llamacpp_python_run | ||
| description: Python wrapper for running locally-hosted LLM with llama.cpp | ||
| keywords: | ||
| - llm | ||
| - llama | ||
| - ai | ||
| tools: | ||
| - llama-cpp-python: | ||
| description: "Python wrapper for llama.cpp LLM inference tool" | ||
| homepage: "https://llama-cpp-python.readthedocs.io/en/latest/" | ||
| licence: | ||
| - "MIT" | ||
| identifier: "" | ||
| input: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]`- prompt_file: | ||
| - prompt_file: | ||
| type: file | ||
| description: | | ||
| Prompt file | ||
| Structure: [ val(meta), path(prompt_file) ] | ||
| ontologies: [] | ||
| - gguf_model: | ||
| type: file | ||
| description: | | ||
| GGUF model | ||
| Structure: [ val(meta), path(gguf_model) ] | ||
| ontologies: [] | ||
| output: | ||
| output: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]` | ||
| - "output.txt": | ||
| type: file | ||
| description: File with the output of LLM inference request | ||
| ontologies: [] | ||
| versions_llama_cpp_python: | ||
| - - ${task.process}: | ||
| type: string | ||
| description: The name of the process | ||
| - llama-cpp-python: | ||
| type: string | ||
| description: The name of the tool | ||
| - python3 -c 'import llama_cpp; print(llama_cpp.__version__)': | ||
| type: eval | ||
| description: The expression to obtain the version of the tool | ||
| topics: | ||
| versions: | ||
| - - ${task.process}: | ||
| type: string | ||
| description: The name of the process | ||
| - llama-cpp-python: | ||
| type: string | ||
| description: The name of the tool | ||
| - python3 -c 'import llama_cpp; print(llama_cpp.__version__)': | ||
| type: eval | ||
| description: The expression to obtain the version of the tool | ||
| authors: | ||
| - "@toniher" | ||
| - "@lucacozzuto" | ||
| maintainers: | ||
| - "@toniher" | ||
| - "@lucacozzuto" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.