modkit icon indicating copy to clipboard operation
modkit copied to clipboard

Please clarify release files in v0.5.0

Open SuhasSrinivasan opened this issue 6 months ago • 4 comments

Dear ONT Developers,

Thank you for developing modkit.

In the latest v0.5.0 release, there are multiple compiled binaries available and the file names are not descriptive enough to understand which one should be used. Additionally, the Quick Start Guide does not contain any information to aid the installation. There is also no relevant documentation in the GitHub README.

It will be helpful to know the differences in the binaries and which is the recommended binary to use.

SuhasSrinivasan avatar Jul 07 '25 21:07 SuhasSrinivasan

Hello @SuhasSrinivasan,

There is a mention of the different versions in the open chromatin documentation but I agree that it could be more useful. The README could also use a refresh.

Generally here is the breakdown of which build to use:

If you have a GPU: Use either the candle or tch releases of Modkit (candle: https://github.com/nanoporetech/modkit/releases/download/v0.5.0/modkit_v0.5.0_u20_x86_64_candle.tar.gz, tch: https://github.com/nanoporetech/modkit/releases/download/v0.5.0/modkit_v0.5.0_u20_x86_64_tch.tar.gz).

The GPU versions are quite quite a bit quicker than the CPU version, the tch version especially. The trade-off between tch and candle when using a GPU is that the tch version requires you to download torchlib and set some environment variables. There are some instructions here. The candle version on the other hand doesn't require anything, but is 1.5-3x slower than the tch version. You don't need a fancy GPU to run this command, I use the oldest ones on our cluster and it's fine for small tests. For large runs, bigger/newer is better but that shouldn't be surprising.

If you don't have a GPU, and must run on the CPU, the only real usable version is the tch version with this flag: --device cpu . The generic release (https://github.com/nanoporetech/modkit/releases/download/v0.5.0/modkit_v0.5.0_u16_x86_64.tar.gz) and the candle version are unfortunately quite slow on the CPU, the tch version is a lot faster (even on CPU). I'm working on better work-arounds here.

If you must run on CPU and don't/cant get torchlib downloaded, the generic release is probably slightly better than the candle one.

If you're compiling on MacOS and want to use tch, I have some scripts I can give you.

The open-chromatin function in Modkit is new, I'm more than happy to answer any questions you may have.

ArtRand avatar Jul 07 '25 23:07 ArtRand

Hi @ArtRand Thank you for reviewing and the detailed response to the query! I will setup the necessary requirements and try the tch binary in a Ubuntu 22.04 environment.

Since dorado has native support through PyTorch and Metal Performance Shaders, are there plans to provide a macOS binary for modkit? Would be very helpful!

SuhasSrinivasan avatar Jul 09 '25 00:07 SuhasSrinivasan

Hello @SuhasSrinivasan,

Since dorado has native support through PyTorch and Metal Performance Shaders, are there plans to provide a macOS binary for modkit?

If there is sufficient users who need a macOS binary with tch I can look into doing this. Distributing macOS binaries requires Mac CI infrastructure as you can imagine. On the other hand, building on Mac with cargo is pretty easy (I develop Modkit on a Mac).

If you clone the repo and run cargo run --release --features accelerate,tch -- open-chromatin predict, you will build a version that can use the --device mps option to leverage the Mac GPU. When you use cargo run it takes care of a lot of the annoyance around getting the libtorch and informing Modkit where it is.

However, if you run the build artifact you may get an error like this:

dyld[14815]: Library not loaded: @rpath/libtorch_cpu.dylib
  Referenced from: <50155C59-DCFC-3338-A892-A3D4AF618D0E> /Users/art.rand/projects/mod_flatten/target/debug/modkit
  Reason: no LC_RPATH's found
[1]    14815 abort      target/debug/modkit

There are a couple ways to deal with this, both are pretty easy.

The first way requires you to have some kind of python environment to get pytorch.

$ python -m venv venv
$ . venv/bin/activate 
$ pip install --upgrade pip
$ pip install torch

Then set these environment variables:

export LIBTORCH_USE_PYTORCH=1
export LIBTORCH=/full/path/to/venv/lib/python3.11/site-packages/torch
export DYLD_LIBRARY_PATH=/full/path/to/venv/lib/python3.11/site-packages/torch/lib

Replace python3.11 with the python version you have. Then the build in target/release should pick up libtorch and "just work".

The second, no-python, way is to search the target/[debug|release] directory for the directory containing libtorch.dylib, on my machine it is /Users/art.rand/projects/mod_flatten/target/release/build/torch-sys-e16d1d6bba7288bc/out/libtorch/libtorch/lib for a particular build. Then set the DYLC_LIBRARY_PATH to this location and run modkit:

$ DYLD_LIBRARY_PATH=/Users/art.rand/projects/mod_flatten/target/release/build/torch-sys-e16d1d6bba7288bc/out/libtorch/libtorch/lib ./target/release/modkit

You can also copy this directory somewhere and keep the environment variable in your .zshrc (this is what I do). The tch crate on which Modkit depends has some clever logic to download the libtorch version you want on Mac, so might as well use it.

ArtRand avatar Jul 09 '25 22:07 ArtRand

Hi @ArtRand

Thank you very much again! Completely understand the development & testing effort and CI infrastructure needed to support another OS.

Considering:

  1. dorado has a binary with PyTorch MPS acceleration for Mac
  2. Apple has listed ONT Dorado Basecalling in the 2025 Mac Studio-M3 Ultra product page! 😁

Hope to see a modkit macOS binary soon!

SuhasSrinivasan avatar Jul 09 '25 23:07 SuhasSrinivasan

Hi @ArtRand , Thank you for releasing v 0.6.0! Are there any plans/timelines to release a macOS binary?

SuhasSrinivasan avatar Dec 01 '25 05:12 SuhasSrinivasan

Hello @SuhasSrinivasan,

Yes, it's on my TODOs. For what it's worth, there isn't a v0.6.0 release of the tch and candle builds since the open chromatin module has not changed for v0.6.0.

ArtRand avatar Dec 01 '25 19:12 ArtRand

Hi @ArtRand ,

Thank you and looking forward to it! With Macs being so powerful with their CPU design and catching up with GPU design too, it will be great to have modkit support for Macs.

SuhasSrinivasan avatar Dec 01 '25 19:12 SuhasSrinivasan