Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

Summary

Adds resource specification support for components to enable Ray actor resource allocation and Tuner placement group optimization.

Changes

Core Schema

  • Added Resource Pydantic class in plugboard_schemas.component with fields: cpu, gpu, memory, resources (custom dict)
  • Supports Kubernetes-style string formats: "250m" → 0.25 CPU, "10Mi" → 10,485,760 bytes
  • Default: cpu=0.001, others zero
  • Implements to_ray_options() for Ray actor configuration

Component Integration

  • Extended Component.__init__() with optional resources parameter
  • Updated ComponentArgsDict, ComponentArgsSpec for YAML support
  • Resources auto-exported and reconstructed from configuration

Ray Execution

  • Modified RayProcess._create_component_actor() to apply resource requirements via ray.remote(**ray_options)
  • Falls back to default Resource() when unspecified

Tuner Optimization

  • Added Tuner._calculate_placement_bundles() to aggregate component resources
  • Creates PlacementGroupFactory with tuner overhead (0.5 CPU) + component bundle

Usage Example

from plugboard.schemas import Resource

# Python API
component = MyComponent(
    name="worker",
    resources=Resource(cpu=2.0, gpu=1, memory="512Mi")
)

# YAML config
resources:
  cpu: "500m"
  gpu: 1
  memory: "100Mi"
  resources:
    custom_accelerator: 2

Tests

  • Unit tests: Resource parsing, validation, Ray conversion
  • Integration tests: Component/ProcessSpec/Tuner scenarios
  • Manual verification (full test suite requires Ray dependencies)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: /usr/bin/curl curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>feat: Implement resource requirements for components</issue_title>
<issue_description>### Summary

Users would like to be able to specify custom resource requirements on Component objects. These can be passed to Ray when a RayProcess is used or a Tuner object is run.

Requirements:

  • Must be able to specify Resource requirements for cpu, gpu, memory, resources. These should be defined as a Pydantic class in plugboard_schemas.
  • Must be able to specify resources as a numerical value, or as a string (to be validated by Pydantic), e.g. 250m for 0.25 or 10Mi for 1024 * 1024 * 10. resources should be a dictionary of string key, numerical value pairs.
  • Must be able to convert these requirements to their Ray equivalents, see https://docs.ray.io/en/latest/ray-core/api/doc/ray.actor.ActorClass.options.html, i.e. cpu = "250m" gets converted to num_cpus=0.25.
  • Must be able to pass a Resource to a Component when instantiating it. This will require changes to the Component and its schema, so that we can specify resource requirements in YAML config.
  • The default requirement should be {"cpu": 0.001}, to be used if the user does not provide anything.
  • Resource requirements should be passed to the actor options in RayProcess.
  • They should be used in the resource placement group inside Tuner.

Example

No response

Alternatives

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add resource requirements for components feat: Implement resource requirements for components Jan 28, 2026
Copilot AI requested a review from toby-coleman January 28, 2026 20:01
"""Parse a resource value from string or number.

Supports:
- Direct numerical values: 1, 0.5, 2.0
Copy link
Contributor

@toby-coleman toby-coleman Jan 28, 2026

Choose a reason for hiding this comment

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

@copilot Can you make this more general? For example by using/supporting any of the following suffixes:

    suffixes = {
        'n': 1e-9, 'u': 1e-6, 'm': 1e-3,  # Decimal SI
        'k': 1e3, 'M': 1e6, 'G': 1e9, 'T': 1e12, 'P': 1e15, 'E': 1e18,
        'Ki': 1024, 'Mi': 1024**2, 'Gi': 1024**3, 'Ti': 1024**4, 'Pi': 1024**5, 'Ei': 1024**6
    }


cpu: float = 0.001
gpu: float = 0
memory: float = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Memory should be specified as an integer number of bytes

initial_values: _t.NotRequired[dict[str, _t.Any] | None]
parameters: _t.NotRequired[dict[str, _t.Any] | None]
constraints: _t.NotRequired[dict[str, _t.Any] | None]
resources: _t.NotRequired["Resource | None"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
resources: _t.NotRequired["Resource | None"]
resources: _t.NotRequired[Resource | None]

).remote(**args)

# Get resource requirements from component
from plugboard.schemas import Resource
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this import to the top

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.

feat: Implement resource requirements for components

2 participants