DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
Current state: Under Discussion
Discussion thread: here (<- link to https://mail-archives.apache.org/mod_mbox/flink-dev/)
JIRA: here (<- link to https://issues.apache.org/jira/browse/FLINK-XXXX)
Released: <Flink Version>
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Motivation
As noted in FLIP-577: AI-Native Flink, with the proliferation of AI workloads such as multimodal data processing, model inference, and real-time feature engineering, accelerators like GPUs, NPUs, and TPUs have become indispensable computing resources in Flink jobs. Flink needs to elevate accelerators to first-class citizen resources, providing end-to-end native support spanning user APIs, resource scheduling, deployment integration, device discovery, and metrics collection.
Limitations of the Existing ExternalResource Mechanism
FLIP-108: Add GPU support in Flink introduced the ExternalResource framework, which provides a generic external resource abstraction and addresses device discovery and information passing on the TM side. However, it still has the following shortcomings for accelerator scenarios:
Lack of accelerator-specific APIs: Users can only configure accelerators through the generic
setExternalResource()method, with no semantically clear dedicated interface.Scheduling layer does not support heterogeneous TMs:
DefaultResourceAllocationStrategyuses a fixed-spec strategy where all TMs share the sametotalResourceProfile. It cannot request and allocate TMs with different specifications for accelerator operators and CPU-only operators, leading to waste of expensive accelerator resources.Lack of accelerator metrics collection framework: There is no unified collection mechanism for runtime metrics such as utilization and memory usage.
Goals of This FLIP
This FLIP aims to provide end-to-end native accelerator support for Flink:
Accelerator API: Provide accelerator resource declaration interfaces on `SlotSharingGroup` and `RosDescriptor` ([FLIP-582](https://cwiki.apache.org/confluence/display/FLINK/FLIP-582%3A+Support+RpcOperator+Service)).
Heterogeneous TM Scheduling: Introduce a heterogeneous TM scheduling strategy (
DynamicResourceAllocationStrategy) that determines TM specifications based on slot resource requirements, allowing accelerator operators and CPU-only operators to be allocated to TMs with different specifications, avoiding accelerator resource waste.Deployment Integration: Automatically generate accelerator-related configurations in the K8s/YARN deployment layer.
Device Discovery: A unified accelerator discovery framework supporting multi-vendor devices through SPI.
Metrics Collection: A unified accelerator metrics collection framework for collecting core metrics such as utilization and memory usage.
All new capabilities are optional, maintaining full backward compatibility with existing behavior.
Usage Guide
When using the new accelerator interfaces introduced by this FLIP, users do not need to manually configure the ExternalResource-related APIs (e.g., setExternalResource()) or configurations — the framework handles accelerator resource management end-to-end.
The accelerator interfaces introduced by this FLIP (SlotSharingGroup.setAccelerator() / RosDescriptor.setAccelerator()) and accelerator.* configurations support two resource allocation strategies, each suitable for different deployment scenarios.
DEFAULT strategy (default): Suitable for deployment scenarios where TMs pre-exist, such as Session mode and Standalone mode. Users need to declare the number of accelerator devices per TM via
accelerator.<type>.amount. The framework uses this to build the TM's resource declaration, enabling correct identification of accelerator resources on TMs during slot allocation.DYNAMIC strategy (
slotmanager.resource-allocation.strategy: DYNAMIC): Suitable for K8s Application mode and YARN Application mode. The framework automatically derives TM specifications from the accelerator requirements declared in SSGs, dynamically requests dedicated TMs, and automatically manages accelerator resources on TMs. Theaccelerator.<type>.amountconfiguration is ignored under this strategy. This strategy also supports heterogeneous TM scheduling for pure CPU/memory scenarios (without declaring accelerators); see the Resource Allocation Strategy section in Proposed Changes for details.
Note: The DYNAMIC strategy requires the underlying resource manager to support on-demand requests for TMs with different specifications. Currently, only K8s Application mode and YARN Application mode fully support this. In Standalone or Session mode, even if the DYNAMIC strategy is explicitly configured, the framework will automatically fall back to the DEFAULT strategy. If the existing TM specifications cannot satisfy job requirements, the job will fail due to slot request timeout.
Public Interfaces
1. Resource Declaration
SlotSharingGroup API
New accelerator configuration methods are added to org.apache.flink.api.common.operators.SlotSharingGroup and its Builder:
public class SlotSharingGroup {
public static class Builder {
/**
* Sets the accelerator resource requirement for this SlotSharingGroup.
*
* <p>Note: A SlotSharingGroup currently supports only one type of accelerator.
* Multiple calls to this method will override previous accelerator requirements,
* with the last call taking precedence.
*
* @param type accelerator type, e.g., "A10", "Ascend910B"
* @param value number of accelerators required per slot, supports fractions
* (e.g., 0.5 means two slots share one device).
* This is the total accelerator budget for the slot. At runtime,
* the framework evenly divides this value among all operators
* within the SSG, and each operator sees its per-operator share
* via {@code AcceleratorInfo.getAmount()}.
* @return this builder
*/
public Builder setAccelerator(String type, double value);
}
/**
* Gets the accelerator requirement for this SSG.
*
* <p>A SlotSharingGroup currently supports only one type of accelerator,
* so the return value contains at most one entry.
*
* @return accelerator type and required amount (per-slot total), or empty
* if no accelerator is set
*/
public Optional<Tuple2<String, Double>> getAccelerator();
}Single-accelerator constraint: In the current phase, a SlotSharingGroup can specify at most one type of accelerator. If multiple accelerator types were supported, TM specifications would need to satisfy the rounding constraints of all accelerators simultaneously, easily leading to resource waste and reduced utilization. It is recommended to split different accelerator requirements into different SlotSharingGroups, allowing the dynamic resource strategy to generate optimally-sized TMs for each, thereby achieving full utilization of each accelerator type.
Per-operator amount: The accelerator amount declared on the SSG is a per-slot total. During JobGraph construction, the framework evenly divides this total among all operators in the SSG and writes each operator's share into its StreamConfig. At runtime, AcceleratorInfo.getAmount() returns this per-operator value. For example, if an SSG declares accelerator.A10 = 1.0 and contains 2 operators, each operator sees getAmount() = 0.5.
RosDescriptor API
The RosDescriptor (FLIP-582) Builder provides an accelerator configuration interface with the same semantics as SlotSharingGroup.
public class RosDescriptor {
public static class Builder {
/**
* Sets the accelerator resource requirement for this RpcOperator.
*
* <p>Semantics are consistent with SlotSharingGroup.Builder.setAccelerator():
* an RpcOperator currently supports only one type of accelerator, and multiple
* calls will override previous settings with the last call taking precedence.
*
* @param type accelerator type, e.g., "A10", "Ascend910B"
* @param value number of accelerators required per RpcOperator instance,
* supports fractions. Unlike SSG, this value is not divided
* further — each RpcOperator instance exclusively owns the
* declared amount.
* @return this builder
*/
public Builder setAccelerator(String type, double value);
}
/**
* Gets the accelerator requirement for this RosDescriptor.
* @return accelerator type and required amount, or empty if no accelerator is set
*/
public Optional<Tuple2<String, Double>> getAccelerator();
}2. Configuration
Configuration Key | Type | Default | Description |
| Enum |
| Resource allocation strategy: `DEFAULT` (existing fixed-spec strategy) or `DYNAMIC` (accelerator-aware dynamic allocation strategy). Note: DYNAMIC strategy only fully takes effect in K8s/YARN Application mode; it automatically falls back to DEFAULT in Standalone/Session mode |
| Integer | TM-level configuration declaring the number of accelerator devices of the specified type per TM. Only effective under the DEFAULT strategy, used as the resource declaration when building TMs so that slot allocation can correctly identify accelerator resources on TMs. Ignored under the DYNAMIC strategy, which determines TM specifications from slot resource requests | |
| String | The resource key for the accelerator in K8s environments, used to declare accelerator resource requests in the Pod spec. Defaults to | |
| Map<String, String> | Node selector for K8s environments. Accelerator nodes in a cluster typically carry specific labels (e.g., | |
| Map<String, String> | Pod annotations for K8s environments, used to interface with cluster device managers or scheduling plugins to declare accelerator resource requirements or device allocation strategies. Not required if the cluster does not use such plugins. Format e.g., | |
| String | The resource key for the accelerator in YARN environments, used to declare accelerator requirements in container resource requests. Since different YARN clusters have no unified naming standard for accelerator resources, users must specify this explicitly. e.g., | |
| String |
| Accelerator discovery driver factory class name. Defaults to the built-in Nvidia implementation, which discovers devices via |
| String | Custom parameters passed through to | |
| String |
| Metrics collector factory class name. Defaults to the built-in Nvidia implementation, which collects metrics via |
| String | Custom parameters passed through to | |
| Duration |
| Metrics collection interval. The framework schedules collection tasks at this period (reference: |
3. Runtime Information
New Methods in RuntimeContext / FunctionContext
New getAcceleratorInfos() methods are added to RuntimeContext (DataStream API) and FunctionContext (Table API / SQL), allowing operators to obtain their per-operator accelerator device information at runtime:
public interface RuntimeContext {
/**
* Gets the accelerator device information for this operator.
*
* <p>The returned {@code AcceleratorInfo.getAmount()} is the per-operator share,
* computed by evenly dividing the SSG's per-slot accelerator total among all
* operators in the SSG. Device type, name, and index remain the same for all
* operators within the same slot.
*
* <p>In the current phase, a SlotSharingGroup can specify at most one type of
* accelerator, so the returned collection typically contains only entries of
* the same type.
*
* @return set of accelerator device information; returns an empty set if no
* accelerator requirements exist
*/
Set<AcceleratorInfo> getAcceleratorInfos();
}
public interface FunctionContext {
/**
* Gets the accelerator device information for this operator.
* Semantics are consistent with RuntimeContext.getAcceleratorInfos().
*/
Set<AcceleratorInfo> getAcceleratorInfos();
}AcceleratorInfo Interface
AcceleratorInfo is the return type of getAcceleratorInfos(), located in the org.apache.flink.api.common.accelerator package, used to wrap accelerator device information:
public interface AcceleratorInfo {
/** User-specified accelerator type, e.g., "A10" */
String getType();
/** Actual device name reported by AcceleratorDriver, e.g., "NVIDIA A10" */
String getName();
/** Device index, e.g., 0, 1 */
int getIndex();
/**
* Per-operator accelerator amount.
*
* <p>For SSG API: this is the SSG's per-slot total evenly divided by
* the number of operators in the SSG. For example, if SSG declares 1.0 and
* contains 4 operators, each operator sees 0.25.
*
* <p>For ROS API: this is the value declared in
* {@code RosDescriptor.setAccelerator()} directly, with no division.
*/
double getAmount();
}4. Device Discovery
Device discovery is used to automatically detect available accelerator devices when a TM starts, eliminating the need for users to manually configure the number of devices on each TM. Based on the device list discovered by the Driver and the accelerator requirements declared by operators, the framework automatically assigns specific device indices to corresponding slots. Operators can then obtain the device information (type, index, amount) allocated to the current slot through RuntimeContext.getAcceleratorInfos().
Flink provides a built-in NvidiaAcceleratorDriverFactory as the default driver-factory.class implementation, which performs full device discovery via the nvidia-smi command. Users with Nvidia GPUs do not need any additional configuration for device discovery. For non-Nvidia accelerators or scenarios requiring special discovery logic, users can override accelerator.<type>.driver-factory.class by implementing the following SPI interfaces:
public interface AcceleratorDriver {
/**
* Discovers accelerator devices on the TM.
* @return set of device information
*/
Set<AcceleratorInfo> discover();
}
public interface AcceleratorDriverFactory {
/**
* Creates an AcceleratorDriver instance.
* @param config accelerator-type-related configuration (key-values under driver-factory.param.*)
* @return driver instance
*/
AcceleratorDriver create(Configuration config);
}After implementation, specify the fully-qualified name of the custom factory class via the accelerator.<type>.driver-factory.class configuration. The framework will automatically call create() to instantiate the Driver during TM startup, then call discover() to complete device discovery.
5. Metrics Collection
Metrics collection is used to periodically collect runtime status of accelerator devices (such as utilization, memory usage, etc.), helping users observe the usage efficiency and health of accelerator resources.
Flink provides a built-in NvidiaAcceleratorMetricsCollectorFactory as the default metrics-collector-factory.class implementation, which collects metrics via the nvidia-smi command. Users with Nvidia GPUs do not need any additional configuration for metrics collection. For non-Nvidia accelerators or scenarios requiring custom collection logic, users can override accelerator.<type>.metrics-collector-factory.class by implementing the following SPI interfaces:
public interface AcceleratorMetricsCollector {
/**
* Collects metrics for specified devices.
* @param deviceIndices set of device indices
* @return Map<deviceIndex, Map<metricName, value>>
*/
Map<String, Map<String, Number>> probe(Set<String> deviceIndices);
/** Returns the set of supported metric names */
Set<String> getSupportedMetrics();
}
public interface AcceleratorMetricsCollectorFactory {
AcceleratorMetricsCollector create(Configuration configuration);
}After implementation, specify the fully-qualified name of the custom factory class via the accelerator.<type>.metrics-collector-factory.class configuration. The framework will automatically call create() to instantiate the Collector during TM startup, dynamically register corresponding Gauges for each device based on the metric names returned by getSupportedMetrics(), and then periodically call probe() to collect and update metric values according to the interval configured in accelerator.<type>.metrics-collector.probing-interval.
Metrics Path Specification
<host>.<tm_id>.Status.Accelerator.<accelerator_type>.<device_index>
└── <metric_name> // Dynamically determined by AcceleratorMetricsCollector.getSupportedMetrics()The framework dynamically registers corresponding Gauges for each device based on the set of metric names returned by getSupportedMetrics(). Different Collector implementations can expose different sets of metrics.
Built-in Nvidia Collector Metrics Example:
<host>.<tm_id>.Status.Accelerator.A10.0
├── Utilization (%)
├── MemoryUsed (MiB)
└── MemoryUtilization (%)End-to-End Example
The following example demonstrates how to use accelerator resource declarations in a DataStream job, combined with the Dynamic scheduling strategy to achieve isolated deployment of accelerator operators and CPU-only operators:
// 1. Declare accelerator resource group: 0.5 A10 per slot → 2 slots per TM, 1 A10 per TM
SlotSharingGroup gpuSsg = SlotSharingGroup.builder("gpu-group")
.setAccelerator("A10", 0.5)
.build();
// 2. Build the job: accelerator operators bound to gpuSsg, other operators use default SSG (regular TMs)
DataStream<String> source = env.fromSource(...); // Default SSG, uses regular TMs
DataStream<Result> inference = source
.map(new ModelInferenceFunction()) // Inference operator uses TMs with A10
.slotSharingGroup(gpuSsg);
inference.sinkTo(...); // Default SSG, uses regular TMsThe inference operator obtains accelerator device information through RuntimeContext internally:
public class ModelInferenceFunction extends RichMapFunction<String, Result> {
@Override
public void open(Configuration parameters) throws Exception {
// getAcceleratorInfos() returns Set<AcceleratorInfo>, each element contains:
// - getType(): accelerator type, e.g., "A10"
// - getName(): actual device name reported by AcceleratorDriver, e.g., "NVIDIA A10"
// - getIndex(): device index, e.g., 0
// - getAmount(): per-operator accelerator amount.
// Since gpu-group has only 1 operator, getAmount() = 0.5 / 1 = 0.5.
// If gpu-group contained 2 operators, each would see getAmount() = 0.5 / 2 = 0.25.
Set<AcceleratorInfo> accelerators = getRuntimeContext().getAcceleratorInfos();
}
}Corresponding configuration:
# Enable dynamic resource allocation strategy
slotmanager.resource-allocation.strategy: DYNAMIC
# A10 accelerator configuration
# Assuming the A10 nodes in the K8s cluster carry the label "gpu-type: a10"
accelerator.A10.kubernetes.node-selector: gpu-type:a10
# kubernetes.resource-key defaults to nvidia.com/gpu
# driver-factory.class defaults to NvidiaAcceleratorDriverFactory
# metrics-collector-factory.class defaults to NvidiaAcceleratorMetricsCollectorFactorySince kubernetes.resource-key, driver-factory.class, and metrics-collector-factory.class all default to Nvidia GPU implementations, users with Nvidia GPUs only need to configure node-selector to direct Pods to the correct nodes. With the above configuration, Flink will automatically request TMs with A10 for operators in gpu-group (2 slots per TM, 1 GPU per TM), while other operators are allocated to regular TMs via the default SSG. The two do not interfere with each other, preventing accelerator resources from being occupied by non-accelerator operators.
If using the DEFAULT strategy in Session or Standalone mode, the corresponding configuration is:
# Accelerator configuration for DEFAULT strategy in Session/Standalone mode
# Default: slotmanager.resource-allocation.strategy: DEFAULT
accelerator.A10.amount: 2
# driver-factory.class and metrics-collector-factory.class default to Nvidia implementationsIn this case, the framework does not dynamically request TMs. Instead, it uses accelerator.A10.amount to build the resource declaration for existing TMs, enabling correct identification of A10 devices on TMs during slot allocation. The built-in Nvidia driver and metrics collector are used by default. The job code is identical to the DYNAMIC example above and requires no modifications.
Proposed Changes
1. Overall Architecture
┌─────────────────────────────────────────────────────────┐
│ 1. Accelerator API │
│ SlotSharingGroup.setAccelerator("A10", 0.5) │
└──────────────────────┬──────────────────────────────────┘
│ Passed via externalResources
▼
┌─────────────────────────────────────────────────────────┐
│ 2. Accelerator-Aware Scheduling (JM) │
│ DynamicResourceAllocationStrategy │
│ - Automatically computes TM specs and slot count │
│ based on accelerator requirements │
│ - TaskManagerResourceInfoCache indexes TMs by │
│ profile │
└──────────────────────┬──────────────────────────────────┘
│ PendingTaskManager / resource profile
▼
┌─────────────────────────────────────────────────────────┐
│ 3. Deployment Integration (K8s / YARN) │
│ - resource requests/limits (nvidia.com/gpu: "1") │
│ - nodeSelector / annotations │
└──────────────────────┬──────────────────────────────────┘
│ TM container starts
▼
┌─────────────────────────────────────────────────────────┐
│ 4. Device Discovery (TM startup, one-time) │
│ AcceleratorDriver (SPI extension) → │
│ Set<AcceleratorInfo> │
├─────────────────────────────────────────────────────────┤
│ 5. Metrics Collection (TM runtime, periodic) │
│ AcceleratorMetricsCollector (SPI extension) → │
│ Metrics │
└─────────────────────────────────────────────────────────┘2. Accelerator Resource Data Flow
Accelerator requirements are internally stored by reusing externalResources, distinguished semantically by the accelerator. prefix, minimizing intrusion into existing code.
Data Flow Chain:
Accelerator data flows through two independent paths: one for scheduling (slot-level, determines TM specifications) and one for runtime information (operator-level, informs each operator of its share).
SlotSharingGroup.externalResources = {"accelerator.A10": 0.5} │ ├──── Scheduling Path (per-slot total, unchanged) ──────────────────────── │ ▼ SlotSharingGroupUtils.extractResourceSpec() │ (full copy of externalResources → extendedResources, no modification needed) ▼ ResourceSpec.extendedResources = {"accelerator.A10": ExternalResource(0.5)} │ ▼ ResourceProfile.fromResourceSpec() ▼ ResourceProfile.extendedResources = {"accelerator.A10": ExternalResource(0.5)} │ ▼ ResourceRequirement → SlotManager │ ├──── Runtime Info Path (per-operator amount) ──────────────────────────── │ ▼ JobGraph construction │ Compute: perOperatorAmount = perSlotTotal / numOperatorsInSSG │ e.g., 0.5 / 2 operators = 0.25 ▼ StreamConfig (per-operator accelerator amount written to each operator's config) │ ▼ Task startup ▼ RuntimeContext.getAcceleratorInfos() → AcceleratorInfo.getAmount() = 0.25
SlotSharingGroupUtils.extractResourceSpec already performs a full copy of externalResources to extendedResources, so accelerator entries naturally flow into the Runtime side without additional modifications.
The per-operator amount is computed during JobGraph construction by evenly dividing the SSG's per-slot accelerator total by the number of operators in the SSG, and written into each operator's StreamConfig. This division only affects the runtime informational value returned by AcceleratorInfo.getAmount() — it does not affect the scheduling path, which always uses the per-slot total for TM specification calculation and slot matching.
3. Resource Allocation Strategy
To achieve efficient accelerator scheduling, a prerequisite problem must be solved: the current DefaultResourceAllocationStrategy uses a fixed-spec strategy where all TMs have the same specifications, making it impossible to allocate TMs with different specifications for accelerator operators and CPU-only operators. Therefore, this FLIP introduces DynamicResourceAllocationStrategy as the infrastructure for accelerator scheduling.
3.1 Strategy Selection Mechanism
The strategy is selected via the configuration slotmanager.resource-allocation.strategy:
Value | Strategy | Description |
|
| Existing fixed-spec strategy, completely unchanged |
|
| Allocation strategy that dynamically determines TM specifications based on resource requirements, supporting heterogeneous scheduling of accelerator and non-accelerator resources |
The DYNAMIC strategy uses different TM specification determination mechanisms based on whether the resource request includes accelerator requirements. See section 3.2 for details. Accelerator operators and CPU-only operators are deployed in isolation to avoid resource waste.
Example: Assume a job contains three operators, with default slot resource specification of 1 CPU / 2GB memory, and `taskmanager.numberOfTaskSlots = 4`:
Operator | SSG | Resource Declaration | Derivation Process |
Source | default | None | Non-GPU TM, slot count = |
Inference | gpu-group |
|
|
Sink | default | None | Belongs to default SSG same as Source, shares the same batch of non-GPU TMs |
Final requested TM specifications:
TM Type | Slots/TM | Per-Slot Resources | TM Total Resources | Hosted Operators |
Regular TM | 4 | 1 CPU / 2GB | 4 CPU / 8GB | Source, Sink |
A10 TM | 2 | 1 CPU / 2GB + 0.5 A10 | 2 CPU / 4GB + 1 A10 | Inference |
3.2 TM Specification Determination Logic
3.2.1 With Accelerator
For SSGs that declare accelerator requirements, the TM's slot count is determined by exact division of ceil(devicesPerSlot) / devicesPerSlot (where devicesPerSlot comes from the SSG's declared accelerator requirements).
// For accelerator accelerator.<type> = value (amount required per slot)
// value must be a positive integer or 1/n (where n is a positive integer),
// i.e., ceil(value) / value must divide evenly,
// otherwise the job is rejected at submission time with an error.
BigDecimal gpuPerSlot = BigDecimal.valueOf(value);
BigDecimal acceleratorsPerTm = BigDecimal.valueOf(Math.ceil(value));
BigDecimal[] divAndRemainder = acceleratorsPerTm.divideAndRemainder(gpuPerSlot);
Preconditions.checkArgument(
divAndRemainder[1].compareTo(BigDecimal.ZERO) == 0,
"Accelerator value must be a positive integer or 1/n (e.g. 0.5, 0.25, 1, 2), got: %s", value);
int slotsPerTm = divAndRemainder[0].intValueExact();Examples:
SSG Requirement | Derivation Process | TM Specification |
|
| 2 slots per TM, 1 A10 |
|
| 4 slots per TM, 1 A10 |
|
| 1 slot per TM, 1 A10 |
|
| 1 slot per TM, 2 A10s |
Rejection examples: The following values are rejected at job submission time because they cannot divide evenly:
SSG Requirement | Rejection Reason |
|
|
|
|
TM total resources are calculated as slot resources multiplied by the number of slots:
ResourceProfile taskManagerResource = slotResource.multiply(slotsPerTm);
new PendingTaskManager(taskManagerResource, slotsPerTm);Under the Dynamic strategy, idle TMs are released immediately without retaining redundancy — accelerator devices are expensive, and holding them idle causes significant waste.
3.2.2 Without Accelerator
For SSGs that do not declare accelerator requirements (e.g., the default SSG), the TM's slot count is taken directly from taskmanager.numberOfTaskSlots, and TM total resources = single slot resources × taskmanager.numberOfTaskSlots.
int slotsPerTm = configuration.get(TaskManagerOptions.NUM_TASK_SLOTS);
ResourceProfile taskManagerResource = slotResource.multiply(slotsPerTm);
new PendingTaskManager(taskManagerResource, slotsPerTm);Example: Assuming taskmanager.numberOfTaskSlots = 4 and single slot resources of 1 CPU / 1GB memory, the TM specification is 4 slots/TM, 4 CPU / 4GB memory.
3.3 TaskManagerResourceInfoCache
A new cache is introduced that indexes TMs by defaultSlotProfile, replacing the original linear traversal:
defaultSlotProfile A (accelerator.A10=0.5, cpu=2, mem=1G)
└── TM-1, TM-2, TM-5
defaultSlotProfile B (accelerator.A10=0.25, cpu=1, mem=512M)
└── TM-3, TM-4Slots cannot be reused across TMs with different defaultSlotProfiles.
4. Deployment Integration
The deployment layer reads accelerator.<type>.kubernetes.* / yarn.* configurations and automatically generates accelerator-related resource requests. Using K8s as an example, the generated pod spec is as follows:
spec:
containers:
- name: taskmanager
resources:
limits:
nvidia.com/gpu: "1"
nodeSelector:
gpu-type: a10
annotations:
vllm.ai/accelerator: a105. Device Discovery
The framework loads the factory class specified by the configuration accelerator.<type>.driver-factory.class via reflection during TM startup, calls create() to instantiate the Driver, and then calls discover() to complete device discovery. This "configuration-driven + factory creation + interface contract" pattern allows the framework to avoid hard-coding any accelerator types.
The default driver-factory.class is the built-in NvidiaAcceleratorDriverFactory, which performs full device discovery via nvidia-smi. Users with Nvidia GPUs do not need any additional configuration. For non-Nvidia accelerators or scenarios requiring special discovery logic, users can override the default by implementing the AcceleratorDriverFactory interface.
Note that AcceleratorDriver does not directly inherit the existing ExternalResourceDriver interface because the latter's retrieveResourceInfo(long) method has the semantics of "query resource information by requested quantity," whereas accelerator device discovery needs to "enumerate all available accelerators on the TM." The two have different invocation patterns.
6. Metrics Collection
The framework loads the factory class specified by the configuration accelerator.<type>.metrics-collector-factory.class via reflection during TM startup, calls create() to instantiate the Collector, dynamically registers corresponding Gauges for each device based on the metric names returned by getSupportedMetrics(), and then periodically calls probe() to collect and update metric values according to the interval configured in accelerator.<type>.metrics-collector.probing-interval. This "configuration-driven + factory creation + interface contract" pattern is consistent with Device Discovery, allowing the framework to avoid hard-coding any metrics collection logic.
The default metrics-collector-factory.class is the built-in NvidiaAcceleratorMetricsCollectorFactory, which collects metrics via nvidia-smi. Users with Nvidia GPUs do not need any additional configuration. For non-Nvidia accelerators or scenarios requiring custom collection logic, users can override the default by implementing the AcceleratorMetricsCollectorFactory interface.
External commands for collection (such as nvidia-smi) may hang for tens of seconds during device failures. Timeout control is handled internally by the Collector implementation (e.g., via process.waitFor(timeout) to set timeouts on subprocesses), because only the Collector itself knows what resources need to be terminated (subprocesses, JNI calls, socket connections, etc.). Timeout parameters are passed in via metrics-collector-factory.param.* and are read and applied by the specific implementation. On the framework side, ScheduledExecutorService.scheduleAtFixedRate() is used for periodic scheduling, which naturally prevents collection task accumulation.
Compatibility, Deprecation, and Migration Plan
This FLIP is fully backward compatible:
Behavioral compatibility: The default strategy is DEFAULT. All new configurations are optional. When not configured, cluster behavior is identical to the current behavior.
API compatibility: All new interfaces (
setAccelerator(),getAcceleratorInfos(),AcceleratorInfo, etc.) are purely additive and do not affect the usage of the existingsetExternalResource()or any other existing interfaces.
This FLIP does not deprecate any existing interfaces or configuration items. No migration is required.
Test Plan
Unit Tests & Integration Tests & Manual Tests will be used to verify this change.