-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
[Bugfix][TPU][V1] Fix recompilation #15553
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
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 |
|---|---|---|
|
|
@@ -88,6 +88,8 @@ def __init__( | |
| self.max_model_len = model_config.max_model_len | ||
| self.max_num_blocks_per_req = cdiv(self.max_model_len, self.block_size) | ||
| self.max_num_tokens = scheduler_config.max_num_batched_tokens | ||
| # InputBatch needs to work with sampling tensors greater than padding | ||
| # to avoid dynamic shapes. Also, avoid suboptimal alignment. | ||
| self.max_num_reqs = max(scheduler_config.max_num_seqs, MIN_NUM_SEQS) | ||
|
|
||
| # Model-related. | ||
|
|
@@ -787,6 +789,7 @@ def capture_model(self) -> None: | |
| dummy_hidden = torch.randn((num_tokens, hsize), | ||
| device=device, | ||
| dtype=torch.bfloat16) | ||
| # Compile for [8, 16, .., 128,.., `self.max_num_reqs`] | ||
| while True: | ||
| indices = torch.zeros( | ||
| num_reqs_to_sample, | ||
|
|
@@ -803,7 +806,9 @@ def capture_model(self) -> None: | |
| out = out.cpu() | ||
|
||
| if num_reqs_to_sample >= self.max_num_reqs: | ||
| break | ||
| num_reqs_to_sample *= 2 | ||
| # Make sure to compile the `max_num_reqs` upper-limit case | ||
|
||
| num_reqs_to_sample = _get_padded_num_reqs_with_upper_limit( | ||
| num_reqs_to_sample + 1, self.max_num_reqs) | ||
| xm.wait_device_ops() | ||
| end = time.perf_counter() | ||
| logger.info("Compilation finished in in %.2f [secs].", end - start) | ||
|
|
@@ -896,7 +901,6 @@ def forward( | |
|
|
||
| return hidden_states | ||
|
|
||
| # @torch.compile(backend="openxla", fullgraph=True, dynamic=False) | ||
|
||
| def sample_from_hidden( | ||
| self, | ||
| hidden_states: torch.Tensor, | ||
|
|
||
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.
Does it make sense to also enable the following in test_basic.py?
enforce_eager=FalseThere 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.
I think so. We should use the default value of
enforce_eager(which is False) in most cases.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.
indeed, it is set to True in test_basic.py