Skip to content

feat(comebin/runcomebin): add GPU support, fix outputs and add a real test - #12796

Open
dialvarezs wants to merge 7 commits into
nf-core:masterfrom
dialvarezs:comebin-gpu
Open

feat(comebin/runcomebin): add GPU support, fix outputs and add a real test#12796
dialvarezs wants to merge 7 commits into
nf-core:masterfrom
dialvarezs:comebin-gpu

Conversation

@dialvarezs

@dialvarezs dialvarezs commented Aug 25, 2026

Copy link
Copy Markdown
Member

GPU support

Container and conda environment are selected from task.accelerator, and the resolved device is passed to run_comebin.sh with -d. The CUDA runtime version goes to the versions topic.

The GPU environment pins pytorch-gpu=2.13.0 with cuda-version=12.9, the lowest CUDA that pytorch 2.13 ships on linux-64.

Fixes

  • The declared embeddings.tsv and covembeddings.tsv outputs do not exist. COMEBin 1.1.0 writes embeddings.npy and covembeddings.npy, plus embedding_ids.txt giving the row order, which is now emitted too.

  • Passing -d is also needed on the CPU path since 1.1.0. run_comebin.sh defaults to device=cuda, and 1.1.0 turned that into a hard error rather than the silent CPU fallback 1.0.4 did, so a real run on the current container raises before training:

     RuntimeError: CUDA training was requested, but the installed PyTorch is CPU-only
    
  • find ${prefix}/comebin_res_bins/*.fa -exec gzip {} \; fails under Singularity (no find in the image).
    The glob already does the work, so this is now a plain gzip.

Tests

The stub-only test is replaced by a real one over a two-genome community, plus a GPU test tagged gpu.

Bin contents are not reproducible across machines. Pinning -s 1 and cpus fixes COMEBin's own threading, but not the BLAS and OpenMP pools underneath, which follow the host's core count. So the snapshot keeps the stable outputs and the bin count is checked by assertion, as semibin/multieasybin already does for the same reason.

PR checklist

  • This comment contains a description of changes (with reason).
  • If you've fixed a bug or added code that should be tested, add tests!
  • If necessary, include test data in your PR.
  • Broadcast software version numbers to topic: versions
  • Follow the naming conventions.
  • Follow the input/output options guidelines.
  • Add a resource label
  • Use BioConda and BioContainers if possible to fulfil software requirements.
  • Ensure that the test works with either Docker / Singularity:
    • nf-core modules test comebin/runcomebin --profile singularity
    • nf-core modules test comebin/runcomebin --profile docker
    • nf-core modules test comebin/runcomebin --profile conda

dialvarezs and others added 4 commits August 25, 2026 19:38
… test

Select the container and conda environment from `task.accelerator`, and pass
the resolved device to `run_comebin.sh` with `-d`. The module never passed
`-d`, so it used the tool's `cuda` default against a CPU-only pytorch build
and raised before training. Also emits the CUDA runtime version to the
versions topic.

Two further fixes that only show up on a real run:

  - The declared `embeddings.tsv` and `covembeddings.tsv` outputs do not
    exist. COMEBin 1.1.0 writes `embeddings.npy` and `covembeddings.npy`,
    plus `embedding_ids.txt` giving the row order, which is now emitted too.

  - `find ${prefix}/comebin_res_bins/*.fa -exec gzip {} \;` fails with
    `find: command not found` under Singularity, because that image is based
    on Amazon Linux 2023 while the Docker one is Ubuntu. The glob already
    does the work, so this is now a plain `gzip`. Note the `find` gave no
    protection against an empty glob either; both forms fail the same way.

Replaces the stub-only test with a real one over a two-genome community,
plus a GPU test tagged `gpu`. COMEBin has no default random seed and its
clustering also varies with the thread count, so the test config pins both.
Snapshots were confirmed stable across two runs on each path.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
CI showed the bin contents differ between machines on both the CPU and the
GPU path. COMEBin's own log says why:

    KMeans, NumPy, scikit-learn, BLAS, OpenMP, and other native runtime
    pools are not controlled by --num_threads.

So pinning `-s 1` and `cpus` fixes COMEBin's own threading but not the
native pools underneath, which follow the host's core count. On the GPU
path the runner's T4 (sm_75) also gives different numerics than the sm_120
card the snapshot was recorded on.

Only the well-separated genome landed identically everywhere; the marginal
contigs moved between bins. So the snapshot now keeps the stable outputs
and the bin count assertion, mirroring what semibin/multieasybin already
does for the same reason.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The binning dataset is merged, so the tests use params.modules_testdata_base_path
instead of raw URLs on a fork.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dialvarezs
dialvarezs marked this pull request as ready for review August 26, 2026 07:11
dialvarezs and others added 2 commits August 26, 2026 03:50
The CPU test passed a single BAM, so the list staging into `bam/` was never
exercised. It now passes all three, which is also the mode the dataset was
built for. The GPU test keeps one sample, so both input shapes are covered.

Runtime is unchanged: COMEBin's cost is dominated by training and CheckM,
not by the number of coverage files.

Also trims the code comments added earlier.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@prototaxites prototaxites left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small comment, but looks really good - thanks for doing this!

Comment thread modules/nf-core/comebin/runcomebin/main.nf
Comment thread modules/nf-core/comebin/runcomebin/tests/main.gpu.nf.test Outdated
Comment thread modules/nf-core/comebin/runcomebin/tests/main.nf.test Outdated
Co-authored-by: Diego Alvarez S. <dialvarezs@gmail.com>

@prototaxites prototaxites left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it looks good to me but I will leave approval to someone else with some knowledge of GPUs and their nf-core implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants