-
Notifications
You must be signed in to change notification settings - Fork 39
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
Refactoring more GenerateService functions across shortfin apps #1010
base: main
Are you sure you want to change the base?
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.
One thing that I find very useful is having ubiquitous type hints. It makes the code much more readable and code navigation/exploration is improved.
self.name = None | ||
self.model_params = None | ||
self.prog_isolation = None | ||
self.inference_programs = {} | ||
self.inference_functions = {} |
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.
Could you add type hints on these?
self.show_progress = False | ||
|
||
# Worker and fiber configuration | ||
self.workers = [] |
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.
Type hint.
*self.inference_modules[component], | ||
] | ||
|
||
def create_program(self, modules, devices, isolation=None, trace_execution=None): |
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.
Could you add type hints?
trace_execution=trace_execution, | ||
) | ||
|
||
def create_worker(self, device, index): |
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.
Type hints on the arguments as well on the return.
inference_programs: dict[int, dict[str, sf.Program]] | ||
inference_functions: dict[int, dict[str, sf.ProgramFunction]] |
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.
What is the point of this declarations? They are now moved to the base class.
inference_programs: dict[int, dict[str, sf.Program]] | ||
inference_functions: dict[int, dict[str, sf.ProgramFunction]] |
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.
These are now part of the GenerateService
base.
self.workers_per_device = 1 | ||
self.fibers_per_device = 1 | ||
self.fibers_per_worker = 1 |
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.
It would be cleaner if these were arguments to the __init__
function.
"""Base class for shortfin service implementations.""" | ||
|
||
def __init__(self, sysman: SystemManager): | ||
"""Initialize base service attributes.""" | ||
self.sysman = sysman | ||
self.inference_parameters: dict[str, list[sf.BaseProgramParameters]] = {} | ||
self.inference_modules: dict[str, list[sf.ProgramModule]] = {} | ||
self.name = None | ||
self.model_params = None |
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.
This should be an __init__
argument. Generally, the base class should be responsible for initialization of its members.
No description provided.