Skip to content

Fix rand interval #3321

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

Merged
merged 12 commits into from
Jul 2, 2025
Merged

Fix rand interval #3321

merged 12 commits into from
Jul 2, 2025

Conversation

laggui
Copy link
Member

@laggui laggui commented Jun 25, 2025

Checklist

  • Confirmed that cargo run-checks command has been executed.

Related Issues/PRs

  failures:
  
  ---- tests::cube::kernel::scatter::tests::scatter_should_work_with_multiple_workgroups_3d_dim2 stdout ----
  
  thread 'tests::cube::kernel::scatter::tests::scatter_should_work_with_multiple_workgroups_3d_dim2' panicked at /home/runner/work/burn/burn/crates/burn-ndarray/src/ops/base.rs:593:23:
  ndarray: index [5, 256] is out of bounds for array of shape [36, 256]
  
  
  failures:
      tests::cube::kernel::scatter::tests::scatter_should_work_with_multiple_workgroups_3d_dim2
  
  test result: FAILED. 3059 passed; 1 failed; 22 ignored; 0 measured; 0 filtered out; finished in 663.28s

Changes

  • Updated cubecl with the rand kernel fix
  • Changed assert_within_range to support different element types for comparison

Testing

Given the randomness of the source, the issue is not always reproducible. Best way is to generate a bunch of random numbers many times, but this might not be suitable for actual unit tests:

#[test]
    fn values_all_within_interval_uniform() {
        TestBackend::seed(0);
        let device = Default::default();

        let low = 5.;
        let high = 12.;
        for i in 0..1000 {
            println!("Test #{i}");
            let tensor =
                TestTensor::<1>::random([100_000], Distribution::Uniform(low, high), &device);

            tensor
                .into_data()
                .assert_within_range::<FT>(low.elem()..high.elem());
        }
    }

@laggui laggui mentioned this pull request Jun 25, 2025
4 tasks
Copy link

codecov bot commented Jun 26, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 46.30%. Comparing base (14811c6) to head (cad03da).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/burn-tensor/src/tensor/data.rs 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3321      +/-   ##
==========================================
- Coverage   46.31%   46.30%   -0.01%     
==========================================
  Files         414      414              
  Lines       60979    60976       -3     
==========================================
- Hits        28240    28234       -6     
- Misses      32739    32742       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Cargo.toml Outdated
Comment on lines 160 to 161
cubecl = { git = "https://github.com/tracel-ai/cubecl", default-features = false, rev = "88031fed04483e317169d41057e95c531b387fae" }
cubecl-common = { git = "https://github.com/tracel-ai/cubecl", default-features = false, rev = "88031fed04483e317169d41057e95c531b387fae" }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linked: tracel-ai/cubecl#753

TODO: update rev

@laggui laggui marked this pull request as draft July 2, 2025 12:42
@laggui
Copy link
Member Author

laggui commented Jul 2, 2025

Marking it as draft before we accidentally merge this 😅 need to wrap some things up on the cubecl side to fix the no-std build which was previously failing due to new profiling stuff.

@laggui laggui marked this pull request as ready for review July 2, 2025 13:54
@laggui laggui merged commit 232f1b1 into main Jul 2, 2025
11 checks passed
@laggui laggui deleted the fix/rand branch July 2, 2025 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants