Make RNG seed optional and improve per-core seed generation for bernoulli/uniform/rand#37906
Open
suzusuzu wants to merge 1 commit intotenstorrent:mainfrom
Open
Make RNG seed optional and improve per-core seed generation for bernoulli/uniform/rand#37906suzusuzu wants to merge 1 commit intotenstorrent:mainfrom
suzusuzu wants to merge 1 commit intotenstorrent:mainfrom
Conversation
…ulli/uniform/rand
Author
|
I verified the behavior of the updated bernoulli / uniform / rand operations as follows: >>> ttnn.rand([3, 3], device=device)
ttnn.Tensor([[ 0.2637, 0.6328, 0.0532],
[ 0.8672, 0.9336, 0.4629],
[ 0.6523, 0.8281, 0.6133]], shape=Shape([3, 3]), dtype=DataType::BFLOAT16, layout=Layout::TILE)
>>> input = ttnn.to_device(ttnn.from_torch(torch.empty(3, 3, dtype=torch.bfloat16).uniform_(0, 1), layout=ttnn.TILE_LAYOUT), dev
ice=device)
>>> ttnn.bernoulli(input)
ttnn.Tensor([[ 0.0000, 1.0000, 1.0000],
[ 1.0000, 0.0000, 1.0000],
[ 0.0000, 0.0000, 0.0000]], shape=Shape([3, 3]), dtype=DataType::FLOAT32, layout=Layout::TILE)
>>> input = ttnn.to_device(ttnn.from_torch(torch.ones(3, 3, dtype=torch.bfloat16), layout=ttnn.TILE_LAYOUT), device=device)
>>> ttnn.uniform(input)
ttnn.Tensor([[ 0.9102, 0.9531, 0.6406],
[ 0.4531, 0.2266, 0.8164],
[ 0.5195, 0.7578, 0.0889]], shape=Shape([3, 3]), dtype=DataType::BFLOAT16, layout=Layout::TILE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket
Problem description
ttnn.bernoulli,ttnn.uniform, andttnn.randcurrently take auint32_tseed with 0 acting as a "no-seed / random" sentinel.This has two issues:
tt-metal/ttnn/cpp/ttnn/operations/rand/device/rand_program_factory.cpp
Lines 109 to 110 in 0839f47
What's changed
std::optional<uint32_t>for seeds:seed=Noneinstead of0.std::optional<uint32_t>rather than auint32_twith a sentinel.std::nullopt(consistent with prior behavior where the seed should not affect compilation/caching).std::mt19937once per program creation/override using either the user-provided seed orstd::time(nullptr)when no seed is provided.Checklist
Model tests
If your changes cover model-related code, you should run tests corresponding to affected models and platforms (Single card, T3K, Galaxy). "Choose your pipeline" workflows facilitate running multiple kinds of tests in a single run. Each offers
models-mandatoryandmodels-extendedpresets.The former includes a minimal set of tests, to be run always. The latter extends that with additional ones - use your best judgement in deciding which is the most appropriate for your PR.
models-mandatorypreset (runs: Device perf regressions and Frequent model and ttnn tests)models-extendedpreset (runs: the mandatory tests, plus Demo and Model perf tests)models-mandatorypreset (runs: Unit tests)models-extendedpreset (runs: the mandatory tests, plus Demo and Model perf tests)models-mandatorypreset (runs: Quick tests)models-extendedpreset (runs: the mandatory tests, plus Demo and Model perf tests)