Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jeertmans
Copy link
Owner

@jeertmans jeertmans commented Jul 28, 2025

Triangles / rays are grouped by batch_size to (possibly) accelerate the scan procedure. Moreover, jax.lax.dynamic_slice_in_dim is used to avoid having to reshape the arrays the have the batched dimension as the first dimension (required by jax.lax.scan).

See jax-ml/jax#30470


Comments

For an unknown reason (maybe the machine on which CI runs), the CodSpeed benchmarks report a regression for some tests, while I cannot reproduce this locally. All my tests show a significant improvement for related benchmarks. See timings on my machine:

Before

                                   Benchmark Results                                   
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┓
┃                        Benchmark ┃     Time (best) ┃ Rel. StdDev ┃ Run time ┃ Iters ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━┩
│                test_image_method │        87,736ns │       16.8% │    3.00s │ 8,850 │
│                      test_fermat │    86,295,515ns │        2.9% │    2.90s │    32 │
│ test_rays_intersect_any_triangle │   168,445,920ns │        7.6% │    2.62s │    14 │
│      test_transmitter_visibility │   586,894,693ns │        1.6% │    2.39s │     4 │
│ test_first_triangles_hit_by_rays │   310,131,980ns │        4.9% │    2.98s │     9 │
│   test_compute_paths[exhaustive] │     6,087,314ns │        7.9% │    3.00s │   440 │
│       test_compute_paths[hybrid] │ 2,727,340,928ns │        0.0% │    2.73s │     1 │
│                  test_train_step │     1,443,286ns │        8.4% │    2.80s │ 1,686 │
└──────────────────────────────────┴─────────────────┴─────────────┴──────────┴───────┘

After

                                  Benchmark Results                                  
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┓
┃                        Benchmark ┃   Time (best) ┃ Rel. StdDev ┃ Run time ┃ Iters ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━┩
│                test_image_method │      87,710ns │       18.9% │    2.89s │ 8,238 │
│                      test_fermat │  85,544,866ns │        2.6% │    2.75s │    31 │
│ test_rays_intersect_any_triangle │ 170,510,130ns │        8.9% │    2.44s │    13 │
│      test_transmitter_visibility │ 101,174,437ns │        3.6% │    2.88s │    27 │
│ test_first_triangles_hit_by_rays │ 268,347,521ns │        2.9% │    2.52s │     9 │
│   test_compute_paths[exhaustive] │   4,729,915ns │        7.5% │    2.94s │   540 │
│       test_compute_paths[hybrid] │ 633,988,360ns │        3.1% │    2.66s │     4 │
│                  test_train_step │   1,535,796ns │       16.0% │    3.00s │ 1,708 │
└──────────────────────────────────┴───────────────┴─────────────┴──────────┴───────┘

In the future, we might want to better fine-tune the default value for batch_size (here it was chosen to maximize the above performance).

@github-actions github-actions bot added the python Changes Python code label Jul 28, 2025
@codecov
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 91.89189% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.14%. Comparing base (55c7259) to head (580aa82).
⚠️ Report is 42 commits behind head on main.

Files with missing lines Patch % Lines
differt/src/differt/rt/_utils.py 92.53% 5 Missing ⚠️
differt/src/differt/em/_antenna.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #300      +/-   ##
==========================================
- Coverage   83.31%   83.14%   -0.17%     
==========================================
  Files          32       32              
  Lines        3020     3055      +35     
==========================================
+ Hits         2516     2540      +24     
- Misses        504      515      +11     

☔ 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.

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 28, 2025

CodSpeed Performance Report

Merging #300 will degrade performances by 15.84%

Comparing vmap (580aa82) with main (55c7259)

Summary

⚡ 2 improvements
❌ 1 (👁 1) regressions
✅ 5 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
👁 test_compute_paths[exhaustive] 29.7 ms 35.3 ms -15.84%
test_compute_paths[hybrid] 18.1 s 5.8 s ×3.1
test_transmitter_visibility 3,877.9 ms 962.9 ms ×4

@github-actions github-actions bot added documentation Improvements or additions to documentation ci Continuous integration (tests, lints, ...) visualization Related to visualization utilities labels Jul 29, 2025
@github-actions github-actions bot added the tests Changes tests label Jul 29, 2025
Triangles / rays are grouped by `batch_size` to accelerate the scan procedure. Moreover, `jax.lax.dynamic_slice_in_dim` is used to avoid having to reshape the arrays the have the `batched` dimension as the first dimension (required by `jax.lax.scan`).

See jax-ml/jax#30470
@jeertmans jeertmans merged commit 5ad0c9a into main Jul 30, 2025
64 checks passed
@jeertmans jeertmans deleted the vmap branch July 30, 2025 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

benchmarks Changes benchmarks ci Continuous integration (tests, lints, ...) documentation Improvements or additions to documentation python Changes Python code tests Changes tests visualization Related to visualization utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants