Skip to content

Commit bfb760a

Browse files
committed
chore: determine docker runtime from executor class definition
Impacts: sdk, facilitator, validator, miner
1 parent d9a8f54 commit bfb760a

12 files changed

Lines changed: 15 additions & 19 deletions

File tree

compute_horde/compute_horde/fv_protocol/facilitator_requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class V2JobRequest(SignedRequest, BaseModel, extra="forbid"):
6161
docker_image: str
6262
args: list[str]
6363
env: dict[str, str]
64-
use_gpu: bool
64+
use_gpu: bool = True # DEPRECATED: this field has no effect
6565
volume: Volume | None = None
6666
output_upload: OutputUpload | None = None
6767
artifacts_dir: str | None = None

compute_horde_sdk/src/compute_horde_core/signature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class SignedFields(BaseModel):
5757
docker_image: str
5858
args: list[str]
5959
env: dict[str, str]
60-
use_gpu: bool
60+
use_gpu: bool # DEPRECATED: this field has no effect
6161
artifacts_dir: str
6262
on_trusted_miner: bool
6363
download_time_limit: int

compute_horde_sdk/src/compute_horde_sdk/_internal/sdk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ async def create_job(self, job_spec: ComputeHordeJobSpec, on_trusted_miner: bool
528528
"job_namespace": job_spec.job_namespace,
529529
"args": job_spec.args or [], # type: ignore
530530
"env": job_spec.env or {}, # type: ignore
531-
"use_gpu": True,
531+
"use_gpu": True, # DEPRECATED: this field has no effect
532532
"artifacts_dir": job_spec.artifacts_dir,
533533
"on_trusted_miner": on_trusted_miner,
534534
"download_time_limit": job_spec.download_time_limit_sec,

executor/app/src/compute_horde_executor/executor/job_driver.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import packaging.version
55
import sentry_sdk
6+
from compute_horde.executor_class import EXECUTOR_CLASS
67
from compute_horde.job_errors import HordeError, JobError
78
from compute_horde.protocol_consts import (
89
HordeFailureReason,
@@ -151,8 +152,9 @@ async def _startup_stage(self) -> V0InitialJobRequest:
151152
self._enter_stage(JobStage.EXECUTOR_STARTUP)
152153
if not settings.DEBUG_NO_GPU_MODE:
153154
self.specs = await get_machine_specs()
154-
await self.run_security_checks_or_fail()
155155
initial_job_request = await self.miner_client.initial_msg
156+
has_gpu = EXECUTOR_CLASS[initial_job_request.executor_class].has_gpu
157+
await self.run_security_checks_or_fail(has_gpu)
156158
await self.runner.prepare_initial(initial_job_request)
157159
await self.miner_client.send_executor_ready()
158160
if initial_job_request.streaming_details is not None:
@@ -189,9 +191,9 @@ async def _upload_stage(self):
189191
job_result.specs = self.specs
190192
await self.miner_client.send_result(job_result)
191193

192-
async def run_security_checks_or_fail(self):
194+
async def run_security_checks_or_fail(self, has_gpu: bool):
193195
await self.run_cve_2022_0492_check_or_fail()
194-
if not settings.DEBUG_NO_GPU_MODE:
196+
if has_gpu and not settings.DEBUG_NO_GPU_MODE:
195197
await self.run_nvidia_toolkit_version_check_or_fail()
196198

197199
async def run_cve_2022_0492_check_or_fail(self):

facilitator/app/src/project/core/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class Job(ExportModelOperationsMixin("job"), models.Model):
151151
help_text="arguments passed to the script or docker image",
152152
)
153153
env = models.JSONField(blank=True, default=dict, help_text="environment variables for the job")
154-
use_gpu = models.BooleanField(default=False, help_text="Whether to use GPU for the job")
154+
use_gpu = models.BooleanField(default=False, help_text="DEPRECATED: Whether to use GPU for the job")
155155
target_validator_hotkey = models.TextField(help_text="target validator")
156156
volumes = SchemaField(schema=list[MuliVolumeAllowedVolume], blank=True, default=list)
157157
uploads = SchemaField(schema=list[SingleFileUpload], blank=True, default=list)

facilitator/app/src/project/core/tests/test_api.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ def check_docker_job(job_result):
113113
assert job_result["docker_image"] == "hello-world"
114114
assert job_result["args"] == ["my", "args"]
115115
assert job_result["env"] == {"MY_ENV": "my value"}
116-
assert job_result["use_gpu"] is True
117116
assert set(job_result.keys()) & generated_fields == generated_fields
118117

119118

@@ -168,7 +167,6 @@ def test_docker_job_viewset_create(api_client, user, connected_validator, mock_s
168167
assert job.docker_image == "hello-world"
169168
assert job.args == ["my", "args"]
170169
assert job.env == {"MY_ENV": "my value"}
171-
assert job.use_gpu is True
172170
assert job.user == user
173171

174172

validator/app/src/compute_horde_validator/validator/management/commands/debug_run_organic_job.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def add_arguments(self, parser):
6565
parser.add_argument(
6666
"--cmd_args", default="", help="arguments passed to the script or docker image"
6767
)
68-
parser.add_argument("--use_gpu", action="store_true", help="use gpu for job execution")
6968

7069
parser.add_argument(
7170
"--download_time_limit", default=10, type=int, help="download time limit in seconds"
@@ -120,7 +119,6 @@ def handle(self, *args, **options):
120119
docker_image=options["docker_image"],
121120
args=shlex.split(options["cmd_args"]),
122121
env={},
123-
use_gpu=options["use_gpu"],
124122
download_time_limit=options["download_time_limit"],
125123
execution_time_limit=options["execution_time_limit"],
126124
upload_time_limit=options["upload_time_limit"],

validator/app/src/compute_horde_validator/validator/organic_jobs/miner_driver.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sentry_sdk
77
from asgiref.sync import sync_to_async
88
from channels.layers import get_channel_layer
9+
from compute_horde.executor_class import EXECUTOR_CLASS
910
from compute_horde.fv_protocol.facilitator_requests import OrganicJobRequest
1011
from compute_horde.fv_protocol.validator_requests import (
1112
HordeFailureDetails,
@@ -299,11 +300,14 @@ async def streaming_ready_callback(msg: V0StreamingJobReadyRequest) -> None:
299300
miner_client.notify_streaming_readiness = streaming_ready_callback # type: ignore[method-assign]
300301
# TODO: remove method assignment above and properly handle notify_* cases
301302

303+
executor_class = ExecutorClass(job_request.executor_class)
304+
has_gpu = EXECUTOR_CLASS[executor_class].has_gpu
305+
302306
job_details = OrganicJobDetails(
303307
job_uuid=str(job.job_uuid),
304-
executor_class=ExecutorClass(job_request.executor_class),
308+
executor_class=executor_class,
305309
docker_image=job_request.docker_image,
306-
docker_run_options_preset="nvidia_all" if job_request.use_gpu else "none",
310+
docker_run_options_preset="nvidia_all" if has_gpu else "none",
307311
docker_run_cmd=job_request.get_args(),
308312
env=job_request.env,
309313
total_job_timeout=OrganicJobDetails.total_job_timeout,

validator/app/src/compute_horde_validator/validator/routing/tests/test_job_routing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
docker_image="doesntmatter",
2929
args=[],
3030
env={},
31-
use_gpu=False,
3231
download_time_limit=1,
3332
execution_time_limit=1,
3433
streaming_start_time_limit=1,

validator/app/src/compute_horde_validator/validator/routing/tests/test_job_routing_incident.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class MinerScenario:
5353
docker_image="doesntmatter",
5454
args=[],
5555
env={},
56-
use_gpu=False,
5756
download_time_limit=1,
5857
execution_time_limit=1,
5958
streaming_start_time_limit=1,
@@ -140,7 +139,6 @@ async def _report_incidents(miner_hotkey: str, incidents: int, executor_class):
140139
docker_image=JOB_REQUEST.docker_image,
141140
args=list(JOB_REQUEST.args),
142141
env=dict(JOB_REQUEST.env),
143-
use_gpu=JOB_REQUEST.use_gpu,
144142
download_time_limit=JOB_REQUEST.download_time_limit,
145143
execution_time_limit=JOB_REQUEST.execution_time_limit,
146144
streaming_start_time_limit=JOB_REQUEST.streaming_start_time_limit,
@@ -348,7 +346,6 @@ async def fake_get_expected_miner_executor_count(**_kwargs):
348346
docker_image="ubuntu:latest",
349347
args=[],
350348
env={},
351-
use_gpu=False,
352349
download_time_limit=1,
353350
execution_time_limit=1,
354351
streaming_start_time_limit=1,

0 commit comments

Comments
 (0)