Skip to content

Proposing GPU booking constraints: Rolling window and advance booking limits#150

Open
chriskuipers wants to merge 2 commits into
masterfrom
RCS-534/gpu-booking-constraint
Open

Proposing GPU booking constraints: Rolling window and advance booking limits#150
chriskuipers wants to merge 2 commits into
masterfrom
RCS-534/gpu-booking-constraint

Conversation

@chriskuipers

Copy link
Copy Markdown
Collaborator

Motivation

To ensure fair access to GPU resources and maximize their utilization, I'm proposing booking constraints that help distribute GPU availability across all users. These changes aim to:

  • Promote fairness: Ensure all users have the opportunity to access GPU resources by preventing early and repeated bookings
  • Encourage efficient utilization: Promote more intentionally booking GPUs, reducing idle time and wasted resources
  • Improve availability: Distribute bookings more evenly so GPUs don't sit idle while others wait

Changes added

  • Rolling window limit: Users can book a maximum of 7 days within any 4-week rolling period. This ensures you can still use GPUs regularly, but not continuously block them for weeks on end.
  • Advance booking limit: Bookings can only be made up to 5 weeks in advance. This prevents people from locking up GPUs months ahead when they're not sure they'll actually need them.
  • Both constraints include clear error messages that explain why a booking was rejected and how many days are still available.

@lwinckers

Copy link
Copy Markdown
Collaborator

Got the following error when deployed on test and trying to book a GPU.

INFO:     172.19.0.4:58062 - "OPTIONS /gpu/request HTTP/1.1" 200 OK
INFO:     172.19.0.4:58062 - "POST /gpu/request HTTP/1.1" 500 Internal Server Error
2025-10-15 14:22:31,030 ERROR: [httptools_impl:run_asgi] Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 375, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 93, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 148, in simple_response
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 72, in app
    response = await func(request)
  File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 278, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 193, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/usr/local/lib/python3.9/site-packages/starlette/concurrency.py", line 42, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/usr/local/lib/python3.9/site-packages/anyio/to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/app/./api/gpus.py", line 141, in create_gpu_schedule
    if schedule.starting_date > max_advance_date:
TypeError: can't compare offset-naive and offset-aware datetimes

Convert incoming datetime objects to timezone-naive to prevent
"TypeError: can't compare offset-naive and offset-aware datetimes"
when validating advance booking constraints. The incoming dates from
the request are timezone-aware while datetime.now() is naive, causing
comparison failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants