Skip to content

Add support for job arrays  #196

Closed
Closed

Description

@sntgluca

Dear dask community,

I am moving my first steps with Dask and distributed, and I wish to bring up a couple of ideas and suggestions.
The first one is about enhancing the integration with the schedulers.

Dask workers are usually requested in bulk.
When the schedulers allow it, i.e. with SGE, I think it's a good practice to submit those as job (task) arrays rather than multiple independent jobs.

In systems with heavy loads it would make the work of the scheduler much easier.

I don't know the code well enough yet to come up with a complete solution, I think there are multiple places where the code needs changes. So I would like to be sure it's a good idea before working on it.

What do you think?

Activity

  1. guillaumeeb commented on Nov 15, 2018

    @guillaumeeb
    Member

    The first thought that comes to my mind here is that we've designed dask-jobqueue with simplicity in mind, as discussed and argumented by @jhamman here: #84 (comment).

    The discussion was about multi nodes reservation at first, but I feel this apply, even with a lesser extend, to job arrays. I'd be curious to have @jhamman advice here.

    What goes into your direction @sntgluca is that I believe that job arrays have an implementation almost every job queue softwares. But still, I'm not sure if this is an easy thing to implement in dask-jobqueue, and we certainly don't want to make it too complex.

    One question if we implemented this, how will we able to easily implement scale_up and scale_down functions with arrays? Is it always easy to qdel or equivalent only part of an array of jobs? Will this be compatible with the internal state (running_jobs, pending_jobs ...) we store?
    I think if we wanted to use arrays, we should do it systematically to keep only simple job templates...

    Looks like a quite heavy change.

  2. jhamman commented on Nov 15, 2018

    @jhamman
    Member

    @sntgluca - in the early days of dask on hpc, we explored using job arrays as a tool for deploying dask (dask/distributed#1260 (comment)). IIRC, we found this approach was generally difficult to abstract to generic array jobs. It might we worth reading https://docs.dask.org/en/latest/setup/hpc.html if you have not already.

    I think there is probably a use case for array jobs with dask but I don't think dask-jobqueue is the right place. While I do see how they may lighten the load on the (SGE) scheduler, they are far less capable of dynamic scaling than what we have now.

  3. mrocklin commented on Nov 16, 2018

    @mrocklin
    Member
  4. belledon commented on Nov 19, 2018

    @belledon

    Not sure if this will help as I am relatively new to using dask but I have played around with using job arrays. Right now you can force

            n = 100
            params = {
                'cores' : 2,
                'memory' : '1000MB',
                'processes' : 1,
                'walltime' : '180',
                'job_extra' : [
                    '--array 0-{0:d}'.format(n - 1), # submit array of sizen
                    '--requeue',
                ],
                'env_extra' : [
                    'JOB_ID=${SLURM_ARRAY_JOB_ID%;*}_${SLURM_ARRAY_TASK_ID%;*}',
                ],
            }

    which will result with each worker having a unique id by overwriting JOB_ID.

    #!/usr/bin/env bash
    
    #SBATCH -n 1
    #SBATCH --cpus-per-task=2
    #SBATCH --mem=954M
    #SBATCH -t 180
    #SBATCH --array 0-99
    #SBATCH --requeue
    JOB_ID=${SLURM_JOB_ID%;*}
    
    JOB_ID=${SLURM_ARRAY_JOB_ID%;*}_${SLURM_ARRAY_TASK_ID%;*}

    This works just fine when using simple setups since each worker gets added to the pool even if the scheduler complains that it is unknown. However, each call the scale will result in n new workers, so client.scale(i) means n * i workers.

  5. guillaumeeb commented on Nov 19, 2018

    @guillaumeeb
    Member

    Some IT groups prefer job arrays over many single jobs because it reduces stress of the resource manager (SLURM, SGE, etc..) They view submitting thousands of independent jobs as an anti-pattern.

    Yep, this is clearly the case at CNES, but it is when one doesn't use Dask :). We've a limitation of 200 concurrent individual jobs, or 10 job arrays, but with up to 100,000 jobs each. But 200 dask-jobqueue jobs with 24 cores is already 4800 cores, that's 2/3 of our cluster... More importantly, in my point of view, dask-jobqueue can play a role similar to job-arrays, as once you've booked a number of resources, you can start computing a lot of individual tasks, and you also don't have to wait for all resources to come up.

    However, I don't know if my understanding here is correct, and even if so I don't know if this would generalize.

    I think your understanding is correct, but as you say we first need here to check if this generalize on all job queue system. It seems to be the case for PBS, Slurm and SGE at least.

    I think that the general answer here is that "if this can be made to work without adding much complexity, and if it demonstrably improves the experience for some users or administrators then we'd be happy to have it".

    I'm perfectly fine with that, though I don't know if it is worth the effort.

  6. mrocklin commented on Nov 19, 2018

    @mrocklin
    Member
  7. sntgluca commented on Nov 27, 2018

    @sntgluca
    Author

    Hi all,

    thanks for the all the follow up and sorry for delaying my answer. I personally find it an important asset. I speak from my personal experience as a HPC user working in close contact with my system administrators.

    One thing to keep in mind is that dask is pretty new, and I am not sure how many syadmin are actually following your progress :) So it's not easy to measure the real impact there.

    one question if we implemented this, how will we able to easily implement scale_up and scale_down functions with arrays? Is it always easy to qdel or equivalent only part of an array of jobs? Will this be compatible with the internal state (running_jobs, pending_jobs ...) we store?
    I think if we wanted to use arrays, we should do it systematically to keep only simple job templates...

    I am positive this can be done in scale_up and scale_down. But there are other parts of the code requiring attention. For instance, a task array is returned as a unique job, not the whole list of jobs, messing up with the pending_jobs list.

    Before you decide to close this, is it ok if I give it a try? What would you expect a newcomer do ;)?

  8. mrocklin commented on Nov 27, 2018

    @mrocklin
    Member
  9. sntgluca commented on Nov 27, 2018

    @sntgluca
    Author

    Thanks for the guidelines @mrocklin,
    will follow up as soon as I have something to say!

  10. sntgluca commented on Nov 30, 2018

    @sntgluca
    Author

    Hi, I have a working proof of concept to use job arrays for the SGECluster class.
    I can achieve it by rewriting the start_cluster() method and modifying the self._command_template attribute.

    Before moving further, I have a design question.

    How do you think the change shall be hooked into the current code? I suggest the use of job arrays be optional, for instance activated by a boolean

    dask_jobqueue.SGECluster(use_task_array=True)

    This idea seems consistent with the rest of the code and shall be robust, but might make the design a bit dull: if use_task_array do this else do that...

  11. guillaumeeb commented on Nov 30, 2018

    @guillaumeeb
    Member

    This idea seems consistent with the rest of the code and shall be robust, but might make the design a bit dull: if use_task_array do this else do that...

    I'm a bit afraid of this yes... But defaulting to job arrays sounds bad too. Is there a lot of places where the if statement would be used? Can we limit this? If it is only in start_cluster() or above, this should be okay.

    So I'm slightly in favor of using the boolean activator you propose.

  12. lesteve commented on Jan 30, 2019

    @lesteve
    Member

    I commented on the the #217 but I'll comment on the issue too with more complete thoughts. My feeling echoes the feeling of others in this issue: task array support is not worth the effort at this point of time in dask-jobqueue.

    IMO task array support is a "nice to have" feature but I am not convinced it is one of the main bottleneck for dask-jobqueue users in practice. I may be wrong about this and I would be happy to get more details about your particular use case if you can not use dask-jobqueue because it does not support task array. If we get many reports like this, I would be very happy to reprioritise task array support.

    My experience with open-source projects is the following: there is quite a long (and ever growing) list of "nice to have" features but not that much time and energy on people's hands to actually implement them, review PRs, test them thoroughly, etc ... deciding what to focus on is key.

  13. halsafar commented on Sep 11, 2019

    @halsafar

    Coming from a compute center with 30,000 SGE nodes. Job arrays are a must. The head node cannot handle the load without job arrays. In one of our software products we were debating a migration to Dask (from our in-house solution) and this is the only feature missing but it is enough to prevent our migration.

  14. lesteve commented on Sep 11, 2019

    @lesteve
    Member

    Full disclosure: I am not very familiar with big clusters. 30_000 nodes seems like a lot though, is it number of nodes or number of cores? I know dask-jobqueue is used at Cheyenne which is ~40 in the TOP 500 and has roughly ~4000 nodes according to this

    Other than this:

    • what is an acceptable number of jobs to launch on your cluster with qsub, in other words what is the threshold of job numbers where you have to use job arrays?
    • what is the typical size of your job arrays?
    • what is the typical time a single job takes?

    Something that may be worth noting: dask can be more flexible than job arrays so this may allow you to do more with the limited amount of qsub you are allowed to have (as hinted in #196 (comment)). Typically there is not a 1-to-1 mapping between "chunk or work" and job and you can use many "chunks of work" inside the same job.

    Here is a snippet to demonstrate what I mean:

    from dask_jobqueue import SGECluster
    cluster = SGECluster(cores=1, memory='1GB')
    # this will launch 4 jobs
    cluster.scale(cores=4)
    
    from dask.distributed import Client
    client = Client(cluster)
    
    def my_function(i):
        return i
    
    argument_list = range(1000)
    
    # the number of times you call my_function is not related to the number of jobs
    futures = [client.submit(my_function, arg) for arg in argument_list]
  15. jmichel-otb commented on Oct 31, 2019

    @jmichel-otb

    Just popping in this long thread because I am a user of @guillaumeeb cluster and I have started to use dask a lot, and I currently encounter the limitation of maximum number of jobs in queue. Our maximum number of jobs in queue is 100, which is not much.

    I understand that using job arrays is off the table, but maybe we could make dask jobqueue aware of those limits, and inform it that it needs to start say 200 jobs but it needs to ensure that there are never more than 100 queuing ?

    I am not familiar with jobqueue code but I expect this to be a much smaller patch than enabling job arrays.

  16. 46 remaining items

  17. halsafar commented on Jun 2, 2020

    @halsafar

    We mandate use of job-arrays because our SGE head node cannot keep up if everyone submits single jobs.

    When you submit each job directly with qsub the easiest thing to do is to launch one job per parameter (and then you gradually move to job array because that's best practice).

    Exactly the opposite. There is no 'gradually move to job arrays' for us. We start with a large job array request and then as nodes die/crash/etc we spawn them with single qsub requests.

  18. lesteve commented on Jun 3, 2020

    @lesteve
    Member

    @halsafar interesting I would be curious to learn a bit more about your cluster best practice. IIUC you can submit single job (e.g. when a single job crashed and you need to resubmit it) so what is the recommended threshold of number of jobs for which it is acceptable for launching a few very similar single jobs. Say you launch a job array of 100 jobs and 10 crash. Can you relaunch the 10 with single jobs, do you have to do a job array? Say 5 job crash, same question.

    Also, just a small comment but rather important comment. You probably did not mean it that way, but "Exactly the opposite" could be easily interpreted as "How could you possibly say this you damn moron" (obviously I am exaggerating a little bit here to make my point, but on this particular one I was indeed a bit annoyed by your "Exactly the opposite" and it took me 5-10 minutes before I was ready to compose a calm reply). IMO terms like this can easily be removed or toned down which makes for a more happy and productive discussion. A good recent related blog post from @GaelVaroquaux: http://gael-varoquaux.info/programming/technical-discussions-are-hard-a-few-tips.html.

    Something that could be mentioned somewhere also in the doc is that Dask-Jobqueue may not be the right tool for you if you need a lot more flexibility than what it provides. An alternative while still using Dask on a HPC cluster is https://docs.dask.org/en/latest/setup/hpc.html?highlight=hpc#using-a-shared-network-file-system-and-a-job-scheduler. So it is more manual in the sense that you submit the dask-worker yourself but you have more control for example you can chose to use job arrays when you submit the dask-worker jobs (as it is shown in the documentation).

  19. ericmjl commented on Jun 4, 2020

    @ericmjl
    Contributor

    IMO terms like this can easily be removed or toned down which makes for a more happy and productive discussion.

    @lesteve thank you for pointing this out. I noticed many on GitHub do not practice communicating "neutrally" and/or "effusively", and simply write out what's on their mind. This is a wonderful reminder.

  20. lesteve commented on Jun 5, 2020

    @lesteve
    Member

    I opened dask/distributed#3855 to allow SpecCluster name to be used in the worker names. That would allow to use job arrays with something like this:

    cluster = SGECluster( 
    	cores=1, memory='1GB', 
    	job_extra=['-t 1-3'],
        name='test_$SGE_TASK_ID')

    Notes:

    • this is a work-around with caveats as noted in this issue. .scale(jobs=1) would actually launch 3 jobs (length of the job arrays) and create 3 Dask workers (one of each job inside the job arrays)
    • this PR is not a replacement at all for the documentation improvements mentioned above would still be extremely useful.

    I tested dask/distributed#3855 and it seems to be working as intended. There could still be weird things with the spec group, I have to say I don't really understand this and don't have the time to look at it more in the near future.

  21. sntgluca commented on Jun 28, 2020

    @sntgluca
    Author

    Hi @lesteve ,
    I apologise, I could not find time to follow up.

    So, given the implementation on dask/distributed, do you think there's a reasonable implementation, and it would be best to work on the documentation?

  22. lesteve commented on Jan 15, 2021

    @lesteve
    Member

    That was the kind of work-around I had in mind for job arrays: dask/dask#7070 (comment).

    The known caveats are:

    • scaling is weird .scale(jobs=1) would actually submit full job-array so you get length(job-array) jobs
    • adaptive very likely doesn't behave correctly because of the scaling quirk above

    Of course there may be unknown caveats ...

  23. jmuchovej commented on Jan 15, 2021

    @jmuchovej
    Contributor

    @lesteve If I'm understanding "adaptive" – I was actually using .adapt(minimum_jobs=2, maximum_jobs=8) in my script, and it scaled up with no hiccups. Never had to scale down, so I can't speak to it, but this work-around could be clearly labeled with "use at your own risk, it's minimally supported, but it works". (I'm sure you had this in mind already, just iterating for clarity.)

    There might also be some logic that could be user-implemented to adapt the size of the array with .scale/.adapt, but it probably needs a clearer implementation/more thought.

  24. lesteve commented on Jan 15, 2021

    @lesteve
    Member

    With my maintainer had on I would rather be even more conservative and say "use at your own risk, this may explode in your face at any moment" 😉

  25. lesteve commented on Jan 20, 2021

    @lesteve
    Member

    In the development version this is a bit easier to use job arrays thanks to #480, see dask/dask#7070 (reply in thread)

  26. shaohao99 commented on Apr 21, 2021

    @shaohao99

    @guillaumeeb For this comment,

    We've a limitation of 200 concurrent individual jobs, 
    or 10 job arrays, but with up to 100,000 jobs each. 
    

    do you use Slurm or other job schedulers? If it is Slurm, would you like to share how to implement that? Thank you.

    We use Slurm on our cluster and would want to implement this: N concurrent individual jobs and M concurrent jobs in all job arrays (e.g. m job arrays with n jobs in each and M=n*m), and M is much larger than N. I have read the Slurm documentation, but it seems there is no way to separate the individual jobs and jobs in arrays. We can only set the maximum number of all jobs. Not sure if I am correct.

  27. guillaumeeb commented on May 2, 2021

    @guillaumeeb
    Member

    do you use Slurm or other job schedulers? If it is Slurm, would you like to share how to implement that? Thank you.

    No, we are currently using PBS Pro. And since a recent update, we cannot do that anymore. We just have now a limit of 100,000 jobs in queue, be it standard job (which is huge) or jobs in array. So same limitation you seem to have.

    I cannot help with Slurm, but surely you can find some channel to ask Slurm developers? Maybe on github https://github.com/SchedMD/slurm?

  28. gezmi commented on Jan 20, 2025

    @gezmi

    Hi,

    I cannot find it in a documentation - was this feature ever implemented for SLURMCluster? It would be super useful for HPC users.

    Thank you!

  29. gezmi commented on Jan 20, 2025

    @gezmi

    Sorry for the question, I found it in the end. It works great!

  30. jmuchovej commented on Jan 21, 2025

    @jmuchovej
    Contributor

    was this feature ever implemented for SLURMCluster?

    its been a while since i looked at this code, so the latest iteration might have changed – but when i ran into this issue, i was on a SLURM cluster; so it definitely worked with a SLURM cluster (back then).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions