-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Bugfix] Fix PP+PCP and PP+flashcomm1 bugs #5416
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 all commits
de163f5
b2cbbee
ef8622a
1db5067
6626a60
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 |
|---|---|---|
|
|
@@ -1133,8 +1133,10 @@ def _generate_process_reqs_hidden_states(self, maybe_padded_num_tokens, | |
| hidden_states, IntermediateTensors): | ||
| hidden_states = self._all_gather_hidden_states_and_aux( | ||
| hidden_states) | ||
| return hidden_states if self.pcp_size == 1 else self.pcp_manager.get_restore_hidden_states( | ||
| hidden_states) | ||
| if self.pcp_size > 1 and get_pp_group().is_last_rank: | ||
| hidden_states = self.pcp_manager.get_restore_hidden_states( | ||
| hidden_states) | ||
| return hidden_states | ||
|
|
||
| def _build_attn_state(self, num_reqs, num_scheduled_tokens, | ||
| num_valid_tokens): | ||
|
|
@@ -2173,19 +2175,24 @@ def _dummy_run( | |
| else: | ||
| # When PP and flashcomm1 are enabled, during dummy_run the estimated space should divide num_tokens by tp_size; | ||
| # otherwise, on non-first PP ranks it would effectively perform an extra all-gather, leading to incorrect memory estimation and potentially causing OOM. | ||
| actual_tokens = num_tokens | ||
| intermediate_tokens = num_tokens_padded | ||
| if enable_sp(): | ||
| tp_size = get_tensor_model_parallel_world_size() | ||
| actual_tokens = num_tokens // tp_size | ||
| intermediate_tokens = (num_tokens_padded + tp_size - | ||
| 1) // tp_size | ||
| if self.intermediate_tensors is None: | ||
| max_actual_tokens = self.max_num_tokens | ||
| if enable_sp(): | ||
| max_actual_tokens = (self.max_num_tokens + tp_size - | ||
| 1) // tp_size | ||
| self.intermediate_tensors = ( | ||
| self.model.make_empty_intermediate_tensors( | ||
| batch_size=actual_tokens, | ||
| batch_size=max_actual_tokens, | ||
| dtype=self.dtype, | ||
| device=self.device)) | ||
| intermediate_tensors = IntermediateTensors({ | ||
| k: | ||
| v[:num_tokens_padded] | ||
| v[:intermediate_tokens] | ||
| for k, v in self.intermediate_tensors.items() | ||
| }) | ||
|
Comment on lines
+2178
to
2197
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. This change correctly handles
These changes are critical for preventing OOM errors and ensuring correctness in memory estimation during dummy runs. |
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.