Skip to content

Optimisation of resources for the workflow #455

Open

Description

@ypriverol

Description of feature

Currently, quantms have seven major categories for resources or processes:

withLabel:process_single {
        cpus   = { 1                   }
        memory = { 6.GB * task.attempt }
        time   = { 4.h  * task.attempt }
    }
    withLabel:process_low {
        cpus   = { 4     * task.attempt }
        memory = { 12.GB * task.attempt }
        time   = { 6.h   * task.attempt }
    }
    withLabel:process_very_low {
        cpus   = { 2     * task.attempt}
        memory = { 4.GB  * task.attempt}
        time   = { 3.h   * task.attempt}
    }
    withLabel:process_medium {
        cpus   = { 8     * task.attempt }
        memory = { 36.GB * task.attempt }
        time   = { 8.h   * task.attempt }
    }
    withLabel:process_high {
        cpus   = { 12    * task.attempt }
        memory = { 72.GB * task.attempt }
        time   = { 16.h  * task.attempt }
    }
    withLabel:process_long {
        time   = { 20.h  * task.attempt }
    }
    withLabel:process_high_memory {
        memory = { 200.GB * task.attempt }
    }

However, some of my current analyses showed that resource usage, for example, for DIA analysis, could be optimized much more at the process level. See some results from my analyses.

### Dataset: PXD030304

CPU Usage:

Screenshot 2024-12-05 at 09 08 27

Memory Usage:

Screenshot 2024-12-05 at 09 08 43

IO Usage:

Screenshot 2024-12-05 at 09 08 55

Most of the processes are under 50% of usage of memory and CPU which looks like a waist of resources?

Activity

  1. added
    enhancement
    on Dec 5, 2024
  2. jpfeuffer commented on Dec 5, 2024

    @jpfeuffer
    Collaborator

    My plan was always to use the results of your thousands of runs to learn a simple regression model for each step based on file size and or number of spectra. But I am not sure if you ever saved the execution logs.

  3. ypriverol commented on Dec 5, 2024

    @ypriverol
    ContributorAuthor

    I did it for most of the runs. However, you don't really need a huge data to be able to learn simple things. Some conclusions, easy ones:

    • samplecheet_check and sdrf_parsing are way-way over their memory requirements, they can now go easily to 1GB memory, currently we are given to them 6GB.
  4. jpfeuffer commented on Dec 5, 2024

    @jpfeuffer
    Collaborator

    Well, yes, but I wasnt talking about those easy things. Of course you can add smaller labels for those.

  5. ypriverol commented on Dec 5, 2024

    @ypriverol
    ContributorAuthor

    I think the orher ones depends heavily of the mzML size, number of MS and MS/MS I guess, even type of instrument, or file size.

  6. jpfeuffer commented on Dec 5, 2024

    @jpfeuffer
    Collaborator

    That's why I said learning from your results..

  7. jpfeuffer commented on Dec 5, 2024

    @jpfeuffer
    Collaborator

    All this information is available when starting a run..

  8. jpfeuffer commented on Dec 5, 2024

    @jpfeuffer
    Collaborator

    Would be a unique and potentially publishable feature of the pipeline.
    There is still the retry functionality if the resources were not enough. But I assume there should be some very informative features that allow for a very accurate prediction of resource usage.

  9. ypriverol commented on Dec 5, 2024

    @ypriverol
    ContributorAuthor

    Yes, the idea is to optimize the pipeline for each process for 80% of the runs, if the 20 fails, it can go to the next retry. Before doing the research we have to think if is needed to have the info inside the files, MS and MS/MS. because if for the model that information is needed, then we will need to block all process until mzml_statistics finish?

  10. jpfeuffer commented on Dec 5, 2024

    @jpfeuffer
    Collaborator

    Yes that is true.

  11. ypriverol commented on Dec 5, 2024

    @ypriverol
    ContributorAuthor

    I will argue that in the first iteration, we look for simple variables, file size, instrument, experiment type - DIA - DDA, and search parameters (database, mods, etc). That could be the first iteration.

  12. ypriverol commented on Dec 5, 2024

    @ypriverol
    ContributorAuthor

    This is DDA-TMT dataset PXD010557:

    Memory Usage:

    Screenshot 2024-12-05 at 09 51 00

    CPU Usage:

    Screenshot 2024-12-05 at 09 51 11

    IO Usage:

    Screenshot 2024-12-05 at 09 51 23

  13. jpfeuffer commented on Dec 5, 2024

    @jpfeuffer
    Collaborator

    I think we cannot predict CPU usage. We need to know from the implementation if it benefits from multiple cores.
    Depending on the implementation multiple cores also means a bit more RAM because more data is loaded at the same time or copies are made for thread-safety

  14. timosachsenberg commented on Dec 5, 2024

    @timosachsenberg

    You can also subsample and average statistics from some files to get a much better idea.

  15. josenimo commented on Mar 2, 2026

    @josenimo

    @ypriverol @jpfeuffer
    I am restarting this conversation, particularly for .d files on DIANN (DIA) runs.
    Currently, BIGBIO_QUANTMS:QUANTMS:DIA:PRELIMINARY_ANALYSIS asks for 72gb of RAM.
    I am actually not sure how much is needed, but my raw file is 3.5gb, and my speclib is 2gb.
    Now I am testing locally so it breaks my run, but also for the HPC asking that much RAM might be a bottleneck in some systems when running 100s of samples.

    thoughts?

    PS, you fixes worked!!

  16. josenimo commented on Mar 2, 2026

    @josenimo

    I have limited nextflow knowledge, but could one ask dynamically based on file sizes?

  17. ypriverol commented on Mar 2, 2026

    @ypriverol
    ContributorAuthor

    A couple of things here; you can optimize this in multiple ways. First, you can pass the params about how much memory do you want in that step; (honestly, I think in a local machine this will not work). The other thing is that you can pass the # of files that you want to do the preliminary analysis on; doesn't need to be the 100 files; it could be 40 for example; 50.

    You can start by passing

    process { 
       withLabel:process_high {
            cpus   = { 12    * task.attempt }
            memory = { 30.GB * task.attempt }
            time   = { 16.h  * task.attempt }
    }
    

    And pass this as extra parameter to the pipeline

  18. jpfeuffer commented on Mar 2, 2026

    @jpfeuffer
    Collaborator

    I think the solution for your local mac is to set maxMemory and maxCPUs. nf-core configs (like ours) will automatically cap to that value.

  19. josenimo commented on Mar 2, 2026

    @josenimo

    awesome, thank you both, now trying it out in HPC, closer to reality

  20. ypriverol commented on Mar 2, 2026

    @ypriverol
    ContributorAuthor

    Just to be sure, all the Mac analysis, using emulators for all the DIANN, is quite bad. Im trying to figure it out if we can produce a container from DIANN that do not need to use arm emulator which is extremely slow. I always recommend to use quantms with a few files in the machine but quantms is fundamental for HPC and could.

  21. josenimo commented on Mar 2, 2026

    @josenimo

    Yeah, I understand, and I think that is the correct way to prioritize.
    I just like to test things locally before adding the extra layer of complexity.

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

Metadata

Metadata

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions