Skip to content

Commit 84df81e

Browse files
authored
update autotuner input tensor random range (#2116)
<!-- .github/pull_request_template.md --> ## πŸ“Œ Description Update autotuner input tensor random range from [0,1) to [-5,5) for larger range and closer to real tensor ## πŸ” Related Issues <!-- Link any related issues here --> ## πŸš€ Pull Request Checklist Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete. ### βœ… Pre-commit Checks - [x] I have installed `pre-commit` by running `pip install pre-commit` (or used your preferred method). - [x] I have installed the hooks with `pre-commit install`. - [x] I have run the hooks manually with `pre-commit run --all-files` and fixed any reported issues. > If you are unsure about how to set up `pre-commit`, see [the pre-commit documentation](https://pre-commit.com/). ## πŸ§ͺ Tests - [ ] Tests have been added or updated as needed. - [ ] All tests are passing (`unittest`, etc.). ## Reviewer Notes <!-- Optional: anything you'd like reviewers to focus on, concerns, etc. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved tensor initialization used during autotuning: values are now drawn from a symmetric range around zero ([-5, 5]) with a more uniform-like distribution, yielding more consistent and stable parameter tuning results. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: jiahanc <173873397+jiahanc@users.noreply.github.com>
1 parent 5e11004 commit 84df81e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

β€Žflashinfer/autotuner.pyβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def __post_init__(self):
6161
# Set default tensor_initializers if not provided
6262
if self.tensor_initializers is None:
6363
self.tensor_initializers = [
64-
lambda shapes, dtype, device: torch.randn(shapes, device=device).to(
65-
dtype
66-
)
64+
lambda shapes, dtype, device: (
65+
torch.rand(shapes, device=device) * 10 - 5
66+
).to(dtype)
6767
for _ in range(len(self.input_idx))
6868
]
6969

@@ -761,8 +761,8 @@ def _create_tensor_like(
761761
def _prepare_input_tensors(
762762
self, profile: OptimizationProfile, inputs: List[torch.Tensor]
763763
) -> List[torch.Tensor]:
764-
default_initializer = lambda shapes, dtype, device: torch.rand(
765-
shapes, device=device
764+
default_initializer = lambda shapes, dtype, device: (
765+
torch.rand(shapes, device=device) * 10 - 5
766766
).to(dtype)
767767
tensors = []
768768
for i, p in enumerate(profile.shapes):

0 commit comments

Comments
Β (0)