Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(tasks): codify fixed VM memory requests (#80972)

Adam Bowkeredf7cb3acbaf
diff --git a/products/tasks/backend/logic/services/modal_sandbox.py b/products/tasks/backend/logic/services/modal_sandbox.py
index 021893ed31e0..38dc116af424 100644
--- a/products/tasks/backend/logic/services/modal_sandbox.py
+++ b/products/tasks/backend/logic/services/modal_sandbox.py
@@ -224,17 +224,17 @@ def _resource_create_kwargs(config: SandboxConfig) -> dict[str, object]:
The burstable request floors come from the config's ``effective_*_request`` properties — the
same values the usage ledger records — so what Modal reserves and what pricing bills can't
- diverge. VM memory can't burst, so it stays the flat scalar (request == limit).
+ diverge.
"""
cpu_limit = float(config.cpu_cores)
memory_limit_mb = int(config.memory_gb * 1024)
if not config.burstable_resources:
return {"cpu": cpu_limit, "memory": memory_limit_mb}
- cpu_value = (config.effective_cpu_request_cores, cpu_limit)
- if config.is_vm:
- return {"cpu": cpu_value, "memory": memory_limit_mb}
- return {"cpu": cpu_value, "memory": (config.effective_memory_request_mb, memory_limit_mb)}
+ return {
+ "cpu": (config.effective_cpu_request_cores, cpu_limit),
+ "memory": (config.effective_memory_request_mb, memory_limit_mb),
+ }
LOCAL_MODAL_DOCKERFILES = {
diff --git a/products/tasks/backend/logic/services/tests/test_modal_sandbox.py b/products/tasks/backend/logic/services/tests/test_modal_sandbox.py
index 501abc62c50e..c9695458b994 100644
--- a/products/tasks/backend/logic/services/tests/test_modal_sandbox.py
+++ b/products/tasks/backend/logic/services/tests/test_modal_sandbox.py
@@ -1555,14 +1555,14 @@ class TestResourceCreateKwargs:
# Reserve the explicitly requested floor, burst up to the configured limit.
assert kwargs == {"cpu": (2.0, 8.0), "memory": (4096, 16384)}
- def test_vm_runtime_pins_memory_but_keeps_cpu_elastic(self):
+ def test_vm_runtime_uses_equal_memory_request_and_limit(self):
config = SandboxConfig(name="t", cpu_cores=4, memory_gb=16, burstable_resources=True, vm_runtime=True)
kwargs = _resource_create_kwargs(config)
- assert kwargs == {"cpu": (0.5, 4.0), "memory": 16384}
+ assert kwargs == {"cpu": (0.5, 4.0), "memory": (16384, 16384)}
- def test_vm_template_pins_memory_but_keeps_cpu_elastic(self):
+ def test_vm_template_uses_equal_memory_request_and_limit(self):
config = SandboxConfig(
name="t",
cpu_cores=4,
@@ -1573,7 +1573,7 @@ class TestResourceCreateKwargs:
kwargs = _resource_create_kwargs(config)
- assert kwargs == {"cpu": (0.5, 4.0), "memory": 16384}
+ assert kwargs == {"cpu": (0.5, 4.0), "memory": (16384, 16384)}
def test_explicit_request_floor_is_clamped_to_limit(self):
# A request floor above the configured limit is clamped down to the limit.