EC2: choose the instance type from each task's resource requests, including GPUs

Open
#4,283 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
18/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
aws, docker, python
Domain
cloud

Research direction

Start with the EC2 environment's instance_type option and its RunInstances call, then the existing check of the storage request against root_volume_size_gb. Compare with the Docker environment's GPU device reservation and the GPU rejection message. The work is design-heavy: choosing types with DescribeInstanceTypes, a GPU-ready image and the bootstrap change are open questions. Done means the maintainers agree on a design, after which per-task selection and an early error can be built.

Written by the indexing model from the issue text.

Description

Summary

The EC2 environment uses one fixed instance_type for every task in a job and does not support GPU tasks. It would help if it could pick an instance type per task from the task's cpus, memory_mb and gpus requests, the way the Modal environment sizes each sandbox.

Checked on Harbor 0.25.0 and on main as of 2026-11-13.

Current behaviour

  • instance_type is a single option, defaulting to m7i-flex.large, and is passed to RunInstances unchanged. The task's cpus and memory_mb are applied only as limits on the container inside the VM.
  • Nothing checks a task's CPU or memory request against the chosen instance before launch (only the storage request is checked, against root_volume_size_gb). An under-sized instance can therefore fail partway through a trial, which looks like an agent failure.
  • A task with gpus > 0 is rejected before launch with "Task requires N GPU(s) but ec2 environment does not support GPU allocation", because the EC2 environment does not declare GPU capability.
  • The bootstrap installs plain Docker, so even a GPU instance type would not expose the GPU to the task container.

Why it matters

Benchmarks often mix task sizes, and some include a few GPU tasks. On EC2 today the options are to size every sandbox for the largest task, or to split the dataset by hand into several jobs with task_names and exclude_task_names and send GPU tasks to another provider. Results then span jobs and providers.

Possible approach

Happy to hear a different preference; this is only a sketch.

  1. Per-task sizing. Accept an ordered list of allowed instance types (for example instance_types: [m7i-flex.large, m7i-flex.2xlarge, g5.xlarge]). For each trial, pick the first type whose vCPUs, memory and GPUs cover the task's request, using DescribeInstanceTypes. Keep today's behaviour when only instance_type is set.
  2. GPU support. When the chosen type has a GPU, use a GPU-ready image (a separate gpu_ami_id, or install the NVIDIA container toolkit during bootstrap), pass the task's GPU request to Compose as a device reservation as the Docker environment does, and declare the capability.
  3. Fail early when nothing fits. If no allowed type covers a task's request, raise a clear error before launch instead of running it under-sized.

Workaround in use

One job per size class, selected with task_names / exclude_task_names, launched together, with GPU tasks on Modal.

Dominant language
Python
Stars
5.6k
Forks
1.9k
Avg merge
1d 17h
Merged PRs (30d)
156

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from harbor-framework/harbor

All issues in harbor-framework/harbor

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.