-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix profiles do not have consistent names #6811
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -429,7 +429,7 @@ def __init__( | |
| self.torch_profiler = None | ||
| self.torch_profiler_output_dir: Optional[str] = None | ||
| self.profiler_activities: Optional[List[str]] = None | ||
| self.profiler_id: Optional[str] = None | ||
| self.profile_id: Optional[str] = None | ||
| self.profiler_target_forward_ct: Optional[int] = None | ||
| self.profiler_target_prefill_ct: Optional[int] = None | ||
| self.profiler_target_decode_ct: Optional[int] = None | ||
|
|
@@ -2144,6 +2144,7 @@ def profile(self, recv_req: ProfileReq): | |
| recv_req.with_stack, | ||
| recv_req.record_shapes, | ||
| recv_req.profile_by_stage, | ||
| recv_req.profile_id, | ||
| ) | ||
| else: | ||
| self.init_profile( | ||
|
|
@@ -2153,6 +2154,7 @@ def profile(self, recv_req: ProfileReq): | |
| recv_req.with_stack, | ||
| recv_req.record_shapes, | ||
| recv_req.profile_by_stage, | ||
| recv_req.profile_id, | ||
| ) | ||
| return self.start_profile(True) | ||
| else: | ||
|
|
@@ -2166,6 +2168,7 @@ def init_profile( | |
| with_stack: Optional[bool], | ||
| record_shapes: Optional[bool], | ||
| profile_by_stage: bool, | ||
| profile_id: str, | ||
| ) -> ProfileReqOutput: | ||
| if self.profile_in_progress: | ||
| return ProfileReqOutput( | ||
|
|
@@ -2184,6 +2187,7 @@ def init_profile( | |
| self.torch_profiler_with_stack = with_stack | ||
| self.torch_profiler_record_shapes = record_shapes | ||
| self.profiler_activities = activities | ||
| self.profile_id = profile_id | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If This would subsequently cause a To prevent this, it's crucial to ensure if profile_id is None:
# Generate a default profile ID if not provided.
# Using a timestamp and a short random hex ensures reasonable uniqueness.
self.profile_id = f"profile_{int(time.time())}_{os.urandom(4).hex()}"
else:
self.profile_id = profile_id |
||
|
|
||
| if num_steps: | ||
| self.profile_steps = num_steps | ||
|
|
@@ -2283,7 +2287,7 @@ def stop_profile( | |
| self.torch_profiler.export_chrome_trace( | ||
| os.path.join( | ||
| self.torch_profiler_output_dir, | ||
| str(time.time()) | ||
| self.profile_id | ||
| + f"-TP-{self.tp_rank}" | ||
| + stage_suffix | ||
| + ".trace.json.gz", | ||
|
|
||
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.
The
profile_idparameter is typed asstrhere, but it's derived fromrecv_req.profile_idwhich is defined asOptional[str]in theProfileReqdataclass (inio_struct.py).If
recv_req.profile_idisNone(which is its default value if not provided by the client), passingNoneto this parameter, which expects astr, could lead to unexpected behavior or type-related issues, especially if strict type checking were enforced or if subsequent code assumes it's always a string without further checks.Consider changing the type hint to
Optional[str]to accurately reflect thatNonemight be passed. The handling of aNonevalue should then be done explicitly in the method body (see related comment for line 2190).