Updated on 2026-11-06 GMT+08:00

UDF Actor Placement Policy

scheduling_strategy is used to control the placement policy of UDF actor. Two policy types are supported.

Policy 1: InstanceSchedulingStrategy

This policy determines the placement relationship of multiple actor instances used for the same query (co-location or dispersion).

from aura_frame.ibis.expr.operations.scheduling_strategy import (
    InstanceSchedulingStrategy, InstanceAffinityMode
)

# Multiple instances must be deployed on the same node (shared cache/communication).
InstanceSchedulingStrategy(mode=InstanceAffinityMode.SAME_REQUIRED)

# Multiple instances must be deployed on different nodes (fault tolerance/load balancing).
InstanceSchedulingStrategy(mode=InstanceAffinityMode.DIFF_REQUIRED)

# Preferentially on the same node, with rollback allowed
InstanceSchedulingStrategy(mode=InstanceAffinityMode.SAME_PREFERRED)

# Preferentially on different nodes, with rollback allowed
InstanceSchedulingStrategy(mode=InstanceAffinityMode.DIFF_PREFERRED)
SAME_REQUIRED first distribution restriction: During the first distribution, if the POD does not have tags of instances used for the same query, the required constraint is not met, and an error is returned. This policy is valid only when multiple actors are distributed in sequence. SAME_PREFERRED or DIFF_PREFERRED is recommended for production. The following is an example:
from aura_frame.ibis.expr.operations.scheduling_strategy import (
    InstanceSchedulingStrategy,
    InstanceAffinityMode,
)

# Scenario: data preprocessing (dispersion first) + model inference (co-location required)
# Actor-A is distributed and placed first, and Actor-B traces it using the same label.

# Actor-A: DIFF_PREFERRED is used for distribution to different nodes.
ds = ds.map(
    fn="my_schema.preprocess",
    on=["raw_col"],
    as_col="preprocessed",
    scheduling_strategy=InstanceSchedulingStrategy(
        mode=InstanceAffinityMode.DIFF_PREFERRED,
        label="inference-pipeline",
    ),
)

# Actor-B: SAME_REQUIRED is used to trace the node where Actor-A is located and share the preprocessing cache.
ds = ds.map(
    fn="my_schema.inference",
    on=["preprocessed"],
    as_col="score",
    scheduling_strategy=InstanceSchedulingStrategy(
        mode=InstanceAffinityMode.SAME_REQUIRED,
        label="inference-pipeline",
    ),
)

Key points:

  • Same label: The two actors must use the same label string.
  • Non-REQUIRED first: Actors with DIFF_PREFERRED or SAME_PREFERRED are placed first.
  • REQUIRED second: Actors with SAME_REQUIRED are placed using labels.
If co-location is not required, use SAME_PREFERRED without customizing a label.
# Co-location is preferred and rollback is allowed —— simple scenario where SAME_REQUIRED is not required
scheduling_strategy=InstanceSchedulingStrategy(mode=InstanceAffinityMode.SAME_PREFERRED),

Label naming rules:

  • It contains a maximum of 63 characters.
  • It must start and end with a letter or digit.
  • Only letters, digits, hyphens (-), and underscores (_) are allowed.
  • The reserved prefix actor_ is not allowed.

Policy 2: NodeLabelSchedulingStrategy

This policy controls the locations of actors based on Kubernetes node tags:
from aura_frame.ibis.expr.operations.scheduling_strategy import (
    NodeLabelSchedulingStrategy, In, NotIn, Exists, DoesNotExist
)

# Hard constraint: The node must be in the gpu pool.
NodeLabelSchedulingStrategy(hard={"pool": In("gpu")})

# Soft constraint: High-bandwidth nodes are preferred. If the requirement is not met, perform a roll back.
NodeLabelSchedulingStrategy(soft={"high_speed_net": Exists()})

# Combined use
NodeLabelSchedulingStrategy(
    hard={"pool": In("gpu")},            # The requirement must be met.
    soft={"high_mem": In("true")},       # The requirement should be preferentially met.
)

The four operators are as follows.

Operator

Syntax

Description

In

{"pool": In("gpu", "npu")}

The label value matches one of the specified values.

NotIn

{"env": NotIn("test")}

The label value is not within the specified range.

Exists

{"npu_type": Exists()}

The label key exists.

DoesNotExist

{"maintenance": DoesNotExist()}

The label key does not exist.

Scheduling in the Multi-Workgroup Scenario

Devices of the same type (such as GPUs) in a cluster may be divided into multiple workgroups (resource pools). Each workgroup is identified by the endpointId tag key on the node, and the tag value is the workgroup name. When there are multiple workgroups, parameters such as device="GPU" can schedule actors to GPU nodes, but cannot distinguish which workgroup the nodes belong to.

endpointId is the ID of an Aura endpoint. It may vary depending on the cluster. You can view your endpoint ID on the tenant plane.

You can use NodeLabelSchedulingStrategy to specify the target workgroup during runtime:
from aura_frame.ibis.expr.operations.scheduling_strategy import (
    NodeLabelSchedulingStrategy, InstanceSchedulingStrategy,
    InstanceAffinityMode, In,
)

# Schedule different instances in the GPU workgroup named "gpu-pool-a".
# The label key is endpointId (obtained from the tenant plane), and the value is the workgroup name.
ds = ds.map(
    fn="my_schema.inference",
    on=["feature_col"],
    as_col="result",
    device="GPU",
    model="A100",
    num_models=1,
    scheduling_strategy=[
        NodeLabelSchedulingStrategy(hard={"<endpointId>": In("gpu-pool-a")}),
        InstanceSchedulingStrategy(mode=InstanceAffinityMode.DIFF_PREFERRED),
    ],
)
Table 1 Workgroup scheduling priorities and coexistence rules

Source

Level

Priority

Description

work_group_name

DDL registration

Highest

Specified in CREATE FUNCTION and added as an AND constraint by the kernel using LabelInOperator(endpointId, {workgroup_name})

NodeLabelSchedulingStrategy

Runtime call

Medium

Specified in WITH ARGUMENTS, and flexible and variable.

Key rules:

  • Coexistence of work_group_name and scheduling_strategy: work_group_name is added to the label list as an AND constraint (the key is endpointId) and does not overwrite or clear the scheduling_strategy constraints.
  • Explicit selection of multiple workgroups: If there are multiple workgroups of the same type, you must specify the target using NodeLabelSchedulingStrategy or work_group_name. Otherwise, the scheduling result is unpredictable.
Table 2 Differences between registration and runtime settings

Dimension

work_group_name

scheduling_strategy

Setting time

UDF registration (CREATE FUNCTION)

Query and call (WITH ARGUMENTS)

Flexibility

One-time registration, always effective

Varies depending on the query

Scope

All calls to the UDF

Only the current query

Change cost

UDF re-registration

Code modification

SQL level

DDL

DML

Table 3 Selection recommendations

Scenario

Recommendation

The UDF always runs in the same workgroup.

Specify work_group_name during registration to avoid repeated settings for each query.

The UDF switches between different workgroups (gray release and multi-tenancy)

Do not set work_group_name during registration. Flexibly specify it using scheduling_strategy.