Skip to content

Commit ca5d4b1

Browse files
Merge pull request #65 from ChrisRackauckas-Claude/precompile-improvements-20260102-013724
Add PrecompileTools for improved TTFX
2 parents b31f223 + 0f5a820 commit ca5d4b1

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "0.4.7"
44

55
[deps]
66
LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
7+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
78
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
89

910
[compat]
@@ -13,6 +14,7 @@ Distributions = "0.25"
1314
ExplicitImports = "1.14.0"
1415
JET = "0.9, 0.10, 0.11"
1516
LogExpFunctions = "0.3"
17+
PrecompileTools = "1"
1618
Random = "1.10"
1719
Statistics = "1"
1820
Test = "1"

src/PoissonRandom.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module PoissonRandom
22

33
using Random: Random, AbstractRNG, randexp
44
using LogExpFunctions: log1pmx
5+
using PrecompileTools: @compile_workload
56

67
export pois_rand, PassthroughRNG
78

@@ -136,4 +137,14 @@ pois_rand(PoissonRandom.PassthroughRNG(), λ)
136137
pois_rand::Real) = pois_rand(Random.GLOBAL_RNG, λ)
137138
pois_rand(rng::AbstractRNG, λ::Real) = λ < 6 ? count_rand(rng, λ) : ad_rand(rng, λ)
138139

140+
@compile_workload begin
141+
# Precompile the most common code paths
142+
# Small λ uses count_rand, large λ uses ad_rand
143+
pois_rand(3.0) # count_rand path (λ < 6)
144+
pois_rand(50.0) # ad_rand path (λ >= 6)
145+
# PassthroughRNG for GPU compatibility
146+
pois_rand(PassthroughRNG(), 3.0)
147+
pois_rand(PassthroughRNG(), 50.0)
148+
end
149+
139150
end # module

0 commit comments

Comments
 (0)