-
Notifications
You must be signed in to change notification settings - Fork 64
add priority to Bach, Job, and run_async #2758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 6 comments
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/web/api/autograd/autograd.pyLines 306-314 306 Interface for submitting several :class:`Simulation` objects to sever.
307 """
308 # validate priority if specified
309 if priority is not None and (priority < 1 or priority > 10):
! 310 raise ValueError("Priority must be between '1' and '10' if specified.")
311
312 if is_valid_for_autograd_async(simulations):
313 return _run_async(
314 simulations=simulations, Lines 1294-1302 1294 """Run a batch of simulations using regular web.run()."""
1295
1296 batch_init_kwargs = parse_run_kwargs(**run_kwargs)
1297 path_dir = run_kwargs.pop("path_dir", None)
! 1298 priority = run_kwargs.get("priority")
1299 batch = Batch(simulations=simulations, **batch_init_kwargs)
1300 td.log.info(f"running {batch.simulation_type} batch with '_run_async_tidy3d()'")
1301
1302 if batch.simulation_type == "autograd_fwd": Lines 1314-1324 1314 task_id = task_ids[task_name]
1315 upload_sim_fields_keys(sim_fields_keys, task_id=task_id, verbose=verbose)
1316
1317 if path_dir:
! 1318 batch_data = batch.run(path_dir, priority=priority)
1319 else:
! 1320 batch_data = batch.run(priority=priority)
1321
1322 task_ids = {key: job.task_id for key, job in batch.jobs.items()}
1323 return batch_data, task_ids Lines 1333-1342 1333 _ = run_kwargs.pop("path_dir", None)
1334 batch = Batch(simulations=simulations, **batch_init_kwargs)
1335 td.log.info(f"running {batch.simulation_type} batch with '_run_async_tidy3d_bwd()'")
1336
! 1337 priority = run_kwargs.get("priority")
! 1338 batch.start(priority=priority)
1339 batch.monitor()
1340
1341 vjp_traced_fields_dict = {}
1342 for task_name, job in batch.jobs.items(): tidy3d/web/api/container.pyLines 247-255 247 self.upload()
248 if priority is None:
249 self.start()
250 else:
! 251 self.start(priority=priority)
252 self.monitor()
253 return self.load(path=path)
254
255 @cached_property Lines 638-646 638 self.to_file(self._batch_path(path_dir=path_dir))
639 if priority is None:
640 self.start()
641 else:
! 642 self.start(priority=priority)
643 self.monitor()
644 return self.load(path_dir=path_dir)
645
646 @cached_property Lines 766-774 766 for _, job in self.jobs.items():
767 if priority is None:
768 executor.submit(job.start)
769 else:
! 770 executor.submit(job.start, priority=priority)
771
772 def get_run_info(self) -> dict[TaskName, RunInfo]:
773 """get information about a each of the tasks in the :class:`Batch`. |
a8f9b33
to
e6f936f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 files reviewed, no comments
e6f936f
to
2993156
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 files reviewed, 1 comment
2993156
to
be8452c
Compare
be8452c
to
145dd95
Compare
Greptile Summary
Updated On: 2025-09-03 11:18:45 UTC
This PR adds priority parameter support to the Tidy3D web API's batch processing system, specifically for vGPU queue management. The implementation enables users to specify task priority levels from 1 (lowest) to 10 (highest) when submitting simulations to the vGPU queue, with priority only affecting vGPU licenses and not FlexCredits simulations.
The changes follow a clear architectural pattern, threading the
priority
parameter through the entire web API call chain:run_async()
→Batch.run()
→Batch.start()
→ individualJob.start()
→webapi.start()
→SimulationTask.submit()
. The parameter is consistently implemented as optional withNone
as the default value, maintaining backward compatibility throughout the system.Key modifications include:
webapi.py
): Added priority validation (1-10 range) and proper parameter forwarding to the underlying task submission layercontainer.py
): Bothrun()
andstart()
methods now accept priority parameters with proper ThreadPoolExecutor implementation ensuring all jobs in a batch inherit the same priorityasynchronous.py
): Therun_async()
function supports priority specification and passes it through to batch operationstask_core.py
):SimulationTask.submit()
includes priority in the HTTP request payload sent to the serverautograd.py
): Priority parameter added to wrapper functions, though implementation has gaps in internal execution pathstest_webapi.py
): Updated mock functions to handle the new parameter signatureThe implementation integrates well with existing codebase architecture and follows established patterns for parameter passing. Documentation clearly specifies the vGPU-specific nature of this feature, helping users understand when priority applies.
Important Files Changed
Changed Files
tidy3d/web/core/task_core.py
tidy3d/web/api/webapi.py
tidy3d/web/api/container.py
tidy3d/web/api/asynchronous.py
tidy3d/web/api/autograd/autograd.py
tests/test_web/test_webapi.py
Confidence score: 3/5
_run_tidy3d()
and_run_async_tidy3d()
callstidy3d/web/api/autograd/autograd.py
where priority is missing from several internal function calls that could result in priority being ignored in autograd workflowsSequence Diagram