Skip to content

Commit 40bafb7

Browse files
author
Zeke Chadron Blair Morton
committed
spec_14: add or-slot and xor-slot documentation
Add comprehensive documentation for or-slots and xor-slots to RFC 14 (Canonical Job Specification): - Extend the slot resource type definition to explain or-slot behavior when multiple sibling slot resources appear at the same level - Add new xor_slot reserved resource type with full specification - Add comparison table contrasting or-slots vs xor-slots - Add Section 3 with three use cases demonstrating: - Use Case 3.1: Or-slots for same-level alternatives - Use Case 3.2: Xor-slots for different hierarchy prefixes - Use Case 3.3: Nested xor-slots - Update JSON schema to include xor_slot as a valid resource vertex type Or-slots allow sibling slot resources to be evaluated as alternatives during traversal using dynamic programming. Xor-slots expand into distinct jobspec branches before traversal and use first-match selection. Both features require the flexible traverser implementation. Assisted-by: Claude <noreply@anthropic.com>
1 parent 18becad commit 40bafb7

2 files changed

Lines changed: 218 additions & 1 deletion

File tree

data/spec_14/schema.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,38 @@
7070
}
7171
]
7272
},
73+
"resource_vertex_xor_slot": {
74+
"description": "special xor_slot resource type - exclusive alternative slot that is expanded before traversal",
75+
"allOf": [
76+
{ "$ref": "#/definitions/resource_vertex_base" },
77+
{
78+
"properties": {
79+
"type": { "const": "xor_slot" }
80+
},
81+
"required": ["label"]
82+
}
83+
]
84+
},
7385
"resource_vertex_other": {
7486
"description": "other (non-slot) resource type",
7587
"allOf": [
7688
{ "$ref": "#/definitions/resource_vertex_base" },
7789
{
7890
"properties": {
79-
"type": { "not": { "const": "slot" } }
91+
"type": {
92+
"allOf": [
93+
{ "not": { "const": "slot" } },
94+
{ "not": { "const": "xor_slot" } }
95+
]
96+
}
8097
}
8198
}
8299
]
83100
},
84101
"resource_vertex": {
85102
"oneOf":[
86103
{ "$ref": "#/definitions/resource_vertex_slot" },
104+
{ "$ref": "#/definitions/resource_vertex_xor_slot" },
87105
{ "$ref": "#/definitions/resource_vertex_other" }
88106
]
89107
}

spec_14.rst

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,67 @@ Reserved Resource Types
244244
to the program described in the jobspec, unless otherwise specified
245245
in the ``exclusive`` field of the associated resource.
246246

247+
When multiple ``slot`` resources appear as siblings at the same hierarchical
248+
level (referred to informally as "or-slots"), they represent alternative slot
249+
configurations. The flexible traverser MAY select any one of the sibling slots
250+
to satisfy the request. This form is useful when alternatives share the same
251+
task slot label and live at the same jobspec level. The traverser uses a
252+
dynamic-programming approach to choose the slot configuration that yields the
253+
largest total number of satisfiable slot matches. Once a slot shape has been
254+
selected, concrete resources for each matched slot are chosen according to
255+
the active match policy.
256+
257+
**xor_slot**
258+
A resource type of ``type: xor_slot`` SHALL indicate an exclusive alternative
259+
resource grouping that is expanded into distinct jobspec branches before
260+
traversal. Each ``xor_slot`` is converted into a normal ``slot`` candidate
261+
internally, and the flexible traverser tries the expanded branches sequentially
262+
until a match is found (first-match strategy).
263+
264+
An ``xor_slot`` SHALL follow the same structural requirements as ``slot``,
265+
including the requirement for a ``label`` key and at least one edge specified
266+
using ``with:``.
267+
268+
This type is particularly useful when alternatives carry different subtree
269+
prefixes (e.g., different hierarchical paths from the root) or when exclusive
270+
same-level alternatives are needed. Unlike sibling ``slot`` resources which
271+
are evaluated during traversal, ``xor_slot`` resources are expanded into
272+
separate candidate jobspecs before matching begins.
273+
274+
Nested ``xor_slot`` resources are supported. When processing nested xor-slots,
275+
the expansion produces all combinations of the xor branches, and each
276+
combination is tried as a separate candidate jobspec.
277+
278+
Support for ``xor_slot`` requires the use of a flexible traverser
279+
implementation. The expansion of ``xor_slot`` alternatives MAY be subject
280+
to implementation-defined limits to prevent combinatorial explosion.
281+
282+
Or-Slots vs Xor-Slots
283+
---------------------
284+
285+
The following table summarizes the differences between or-slots (sibling
286+
``slot`` resources) and xor-slots (``xor_slot`` resources):
287+
288+
.. list-table::
289+
:widths: 30 35 35
290+
:header-rows: 1
291+
292+
* - Feature
293+
- Or-slots (sibling ``slot``)
294+
- Xor-slots (``xor_slot``)
295+
* - Expansion timing
296+
- During traversal
297+
- Before traversal
298+
* - Selection algorithm
299+
- Dynamic programming (optimal)
300+
- First-match (sequential)
301+
* - Use case
302+
- Same-level alternatives with shared label
303+
- Different hierarchy prefixes, exclusive same-level alternatives
304+
* - Nesting support
305+
- No
306+
- Yes
307+
247308
Tasks
248309
=====
249310

@@ -721,6 +782,144 @@ Jobspec YAML
721782
.. literalinclude:: data/spec_14/use_case_2.9.yaml
722783
:language: yaml
723784

785+
Section 3: Alternative Resource Configurations
786+
===============================================
787+
788+
The following use cases demonstrate or-slots and xor-slots, which allow
789+
expressing alternative resource configurations within a single jobspec.
790+
These require the use of a flexible traverser implementation.
791+
792+
Use Case 3.1
793+
Request alternative slot configurations (or-slots)
794+
795+
Specific Example
796+
Request either a GPU-capable slot with 8 cores or a larger CPU-only
797+
slot with 10 cores. Sibling ``slot`` resources at the same level
798+
represent alternatives that are evaluated during traversal using
799+
dynamic programming to maximize the number of satisfiable slots.
800+
801+
Jobspec YAML
802+
.. code-block:: yaml
803+
804+
version: 1
805+
resources:
806+
- type: slot
807+
count: 1
808+
label: default
809+
with:
810+
- type: core
811+
count: 8
812+
- type: gpu
813+
count: 1
814+
- type: slot
815+
count: 1
816+
label: default
817+
with:
818+
- type: core
819+
count: 10
820+
attributes:
821+
system:
822+
duration: 3600
823+
tasks:
824+
- command: [ "app" ]
825+
slot: default
826+
count:
827+
per_slot: 1
828+
829+
Use Case 3.2
830+
Request exclusive alternative branches (xor-slots)
831+
832+
Specific Example
833+
Request either a socket-local GPU configuration or a node-scoped
834+
memory configuration. The ``xor_slot`` type causes these alternatives
835+
to be expanded into separate candidate jobspecs before matching begins.
836+
The flexible traverser tries each candidate sequentially until one matches.
837+
838+
Jobspec YAML
839+
.. code-block:: yaml
840+
841+
version: 1
842+
resources:
843+
- type: xor_slot
844+
count: 1
845+
label: default
846+
with:
847+
- type: socket
848+
count: 1
849+
with:
850+
- type: core
851+
count: 8
852+
- type: gpu
853+
count: 1
854+
- type: xor_slot
855+
count: 1
856+
label: default
857+
with:
858+
- type: node
859+
count: 1
860+
with:
861+
- type: socket
862+
count: 1
863+
with:
864+
- type: core
865+
count: 6
866+
- type: memory
867+
count: 2
868+
attributes:
869+
system:
870+
duration: 3600
871+
tasks:
872+
- command: [ "app" ]
873+
slot: default
874+
count:
875+
per_slot: 1
876+
877+
Use Case 3.3
878+
Nested xor-slots with multiple hierarchy levels
879+
880+
Specific Example
881+
Request a slot with nested xor alternatives. This demonstrates
882+
that ``xor_slot`` resources can be nested, allowing complex
883+
alternative resource hierarchies to be expressed.
884+
885+
Jobspec YAML
886+
.. code-block:: yaml
887+
888+
version: 1
889+
resources:
890+
- type: node
891+
count: 1
892+
with:
893+
- type: xor_slot
894+
count: 1
895+
label: default
896+
with:
897+
- type: socket
898+
count: 2
899+
with:
900+
- type: xor_slot
901+
count: 1
902+
label: accel
903+
with:
904+
- type: core
905+
count: 4
906+
- type: gpu
907+
count: 1
908+
- type: xor_slot
909+
count: 1
910+
label: accel
911+
with:
912+
- type: core
913+
count: 8
914+
attributes:
915+
system:
916+
duration: 3600
917+
tasks:
918+
- command: [ "app" ]
919+
slot: default
920+
count:
921+
per_slot: 1
922+
724923
References
725924
**********
726925

0 commit comments

Comments
 (0)