| ############################################################################ | |
| # Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
| ############################################################################ | |
| """Test LLN placement of a multi-node-capable job on nodes of different sizes. | |
| Ticket 26135: in an LLN partition, a job that may span nodes and needs more | |
| CPUs than the least-loaded node has must start, rather than be held with | |
| "sync loop not progressing". | |
| """ | |
| import pytest | |
| import atf | |
| SMALL_CPUS = 2 | |
| LARGE_CPUS = 4 | |
| # More than the small node has and less than the large node has | |
| TASKS = 3 | |
| PARTITIONS = {"flat": "flat_topo", "tree": "tree_topo"} | |
| @pytest.fixture(scope="module", autouse=True) | |
| def setup(): | |
| atf.require_version( | |
| (26, 11), | |
| "sbin/slurmctld", | |
| reason="Ticket 26135: LLN fix for jobs larger than the least-loaded node", | |
| ) | |
| small_node, large_node = atf.require_nodes(2, [("CPUs", LARGE_CPUS)])[:2] | |
| # Index order decides ties between equally loaded nodes, so the small node | |
| # must come first and the large node must be the last one scanned. | |
| atf.set_node_parameter(small_node, "CPUs", SMALL_CPUS) | |
| atf.require_config_parameter("SelectType", "select/cons_tres") | |
| # Overwrite rather than append: the CR_* allocation types are mutually | |
| # exclusive, so adding CR_Core_Memory to a config already setting CR_CPU | |
| # yields "cr_cpu,CR_Core_Memory", which slurmctld rejects. | |
| atf.require_config_parameter("SelectTypeParameters", "CR_Core_Memory") | |
| atf.require_config_file( | |
| "topology.yaml", | |
| f""" | |
| - topology: flat_topo | |
| cluster_default: true | |
| flat: true | |
| - topology: tree_topo | |
| cluster_default: false | |
| tree: | |
| switches: | |
| - switch: root | |
| children: s[1-2] | |
| - switch: s1 | |
| nodes: {small_node} | |
| - switch: s2 | |
| nodes: {large_node} | |
| """, | |
| ) | |
| atf.require_config_parameter( | |
| "PartitionName", | |
| { | |
| name: { | |
| "Nodes": f"{small_node},{large_node}", | |
| "LLN": "YES", | |
| "Topology": topology, | |
| } | |
| for name, topology in PARTITIONS.items() | |
| }, | |
| ) | |
| atf.require_slurm_running() | |
| return [small_node, large_node] | |
| @pytest.fixture(scope="function") | |
| def cr_lln_only(setup, partition): | |
| # A restart discards runtime partition updates, so turn the flag off after. | |
| atf.set_config_parameter( | |
| "SelectTypeParameters", "CR_Core_Memory,CR_LLN", restart=True | |
| ) | |
| atf.wait_for_node_state(setup, "IDLE", fatal=True) | |
| atf.run_command( | |
| f"scontrol update PartitionName={partition} LLN=no", | |
| user=atf.properties["slurm-user"], | |
| fatal=True, | |
| ) | |
| yield | |
| # function_setup cancels jobs only after this teardown, too late for the wait | |
| atf.cancel_all_jobs(fatal=True) | |
| atf.set_config_parameter("SelectTypeParameters", "CR_Core_Memory", restart=True) | |
| atf.wait_for_node_state(setup, "IDLE", fatal=True) | |
| def assert_multi_node_job_starts(partition): | |
| job_id = atf.submit_job_sbatch( | |
| f'-p {partition} -n {TASKS} --mem=1 -t 5 --wrap "sleep infinity"', | |
| fatal=True, | |
| ) | |
| assert atf.wait_for_job_state( | |
| job_id, "RUNNING" | |
| ), "Job should start, got JobState={} Reason={}".format( | |
| atf.get_job_parameter(job_id, "JobState", fatal=True), | |
| atf.get_job_parameter(job_id, "Reason", fatal=True), | |
| ) | |
| @pytest.mark.parametrize("partition", PARTITIONS) | |
| def test_lln_multi_node_job_starts(partition): | |
| """Verify a job larger than the least-loaded node starts in an LLN partition""" | |
| assert_multi_node_job_starts(partition) | |
| @pytest.mark.parametrize("partition", PARTITIONS) | |
| def test_cr_lln_multi_node_job_starts(partition, cr_lln_only): | |
| """Verify a job larger than the least-loaded node starts with CR_LLN""" | |
| assert_multi_node_job_starts(partition) |