Skip to content
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

[minor] allow overriding args/kwargs behavior in Runtime #587

Merged
merged 4 commits into from
Aug 25, 2023

Conversation

justheuristic
Copy link
Member

@justheuristic justheuristic commented Aug 25, 2023

This PR extracts a part of runtime that is responsible for calling pool's process func.
This is to allow developer to extend this behavior in petals downstream applications without having to rewrite the whole runtime.run method.

Comment on lines 109 to 110
if self.stats_report_interval is not None:
self.stats_reporter.report_stats(pool.name, batch_size, batch_processing_time)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might lead to unintended "0 batches processed" log entries if the user overrides this without carefully considering the original function. Best to leave only the batch size computation inside the function and keep all the logging/time measuring logic outside the function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, fixed it now, please take another look

@codecov
Copy link

codecov bot commented Aug 25, 2023

Codecov Report

Merging #587 (cad9848) into master (6f5c471) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #587      +/-   ##
==========================================
+ Coverage   85.38%   85.42%   +0.04%     
==========================================
  Files          81       81              
  Lines        8006     8009       +3     
==========================================
+ Hits         6836     6842       +6     
+ Misses       1170     1167       -3     
Files Changed Coverage Δ
hivemind/moe/server/runtime.py 75.60% <100.00%> (+0.60%) ⬆️

... and 6 files with indirect coverage changes

hivemind/moe/server/runtime.py Show resolved Hide resolved
@@ -108,6 +105,11 @@ def run(self):
if not self.shutdown_trigger.is_set():
self.shutdown()

def process_batch(self, pool: TaskPoolBase, batch_index: int, *batch: torch.Tensor) -> Tuple[Any, int]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

batch_index is not used, is it okay?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, it is meant to be exposed for subclassing

@justheuristic justheuristic merged commit 33a9a41 into master Aug 25, 2023
15 checks passed
@justheuristic justheuristic deleted the runtime_process_func branch August 25, 2023 23:13
mryab pushed a commit that referenced this pull request Aug 31, 2023
* allow overriding args/kwargs in Runtime
* switch stats time to time.perf_counter

---------

Co-authored-by: Your Name <[email protected]>
Co-authored-by: Max Ryabinin <[email protected]>
(cherry picked from commit 33a9a41)
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.

None yet

3 participants