def test_lifo_scheduler_favor_cpu_for_requests_without_accelerators( example_mixed_agents, example_pending_sessions, ): # Check the reverse with the LIFO scheduler. # The result must be same. scheduler = LIFOSlotScheduler({}) for idx in range(3): picked_session_id = scheduler.pick_session(example_total_capacity, example_pending_sessions, []) assert picked_session_id == example_pending_sessions[-1].session_id picked_session = _find_and_pop_picked_session(example_pending_sessions, picked_session_id) agent_id = scheduler.assign_agent_for_session(example_mixed_agents, picked_session) if idx == 2: # example_mixed_agents do not have any agent with ROCM accelerators. assert agent_id is None elif idx == 1: assert agent_id == AgentId('i-gpu') elif idx == 0: # It should favor the CPU-only agent if the requested slots # do not include accelerators. assert agent_id == AgentId('i-cpu')
def example_mixed_agents(): return [ AgentContext( agent_id=AgentId('i-gpu'), agent_addr='10.0.1.1:6001', scaling_group='sg01', available_slots=ResourceSlot({ 'cpu': Decimal('4.0'), 'mem': Decimal('4096'), 'cuda.shares': Decimal('4.0'), }), occupied_slots=ResourceSlot({ 'cpu': Decimal('0'), 'mem': Decimal('0'), 'cuda.shares': Decimal('0'), }), ), AgentContext( agent_id=AgentId('i-cpu'), agent_addr='10.0.2.1:6001', scaling_group='sg02', available_slots=ResourceSlot({ 'cpu': Decimal('3.0'), 'mem': Decimal('2560'), 'cuda.shares': Decimal('0'), }), occupied_slots=ResourceSlot({ 'cpu': Decimal('0'), 'mem': Decimal('0'), 'cuda.shares': Decimal('0'), }), ), ]
def test_fifo_scheduler(example_agents, example_pending_sessions, example_existing_sessions): scheduler = FIFOSlotScheduler({}) picked_session_id = scheduler.pick_session(example_total_capacity, example_pending_sessions, example_existing_sessions) assert picked_session_id == example_pending_sessions[0].kernel_id picked_session = _find_and_pop_picked_session(example_pending_sessions, picked_session_id) agent_id = scheduler.assign_agent(example_agents, picked_session) assert agent_id == AgentId('i-001')
def example_agents_no_valid(): return [ AgentContext( agent_id=AgentId('i-001'), agent_addr='10.0.1.1:6001', scaling_group='sg01', available_slots=ResourceSlot({ 'cpu': Decimal('0'), 'mem': Decimal('0'), 'cuda.shares': Decimal('0'), 'rocm.devices': Decimal('0'), }), occupied_slots=ResourceSlot({ 'cpu': Decimal('4.0'), 'mem': Decimal('4096'), 'cuda.shares': Decimal('4.0'), 'rocm.devices': Decimal('2'), }), ), AgentContext( agent_id=AgentId('i-101'), agent_addr='10.0.2.1:6001', scaling_group='sg02', available_slots=ResourceSlot({ 'cpu': Decimal('0'), 'mem': Decimal('0'), 'cuda.shares': Decimal('0'), 'rocm.devices': Decimal('0'), }), occupied_slots=ResourceSlot({ 'cpu': Decimal('3.0'), 'mem': Decimal('2560'), 'cuda.shares': Decimal('1.0'), 'rocm.devices': Decimal('8'), }), ), ]
def scb(app_ctx: web.Application, agent_id: AgentId, event_name: str): assert app_ctx is app assert agent_id == AgentId('i-test') assert event_name == 'test-event-02' raise OverflowError
async def acb(app_ctx: web.Application, agent_id: AgentId, event_name: str): assert app_ctx is app assert agent_id == AgentId('i-test') assert event_name == 'test-event-02' raise ZeroDivisionError
def scb(app_ctx: web.Application, agent_id: AgentId, event_name: str): assert app_ctx is app assert agent_id == AgentId('i-test') assert event_name == 'test-event-01' records['test-var'].add('sync')