Skip to content

Commit 0f14cd3

Browse files
Fix Sophia optimizer: add Random import to resolve randn! error
The Sophia optimizer calls randn!() on line 155 of src/sophia.jl but Random was not imported. This caused UndefVarError when using Sophia. Changes: - Add Random to dependencies in Project.toml - Import Random in src/Optimization.jl Fixes #1004 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 4f072a7 commit 0f14cd3

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
1414
OptimizationBase = "bca83a33-5cc9-4baa-983d-23429ab6bcbb"
1515
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1616
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
17+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1718
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1819
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
1920
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

src/Optimization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if !isdefined(Base, :get_extension)
1212
end
1313

1414
using Logging, ProgressLogging, ConsoleProgressMonitor, TerminalLoggers, LoggingExtras
15-
using ArrayInterface, Base.Iterators, SparseArrays, LinearAlgebra
15+
using ArrayInterface, Base.Iterators, SparseArrays, LinearAlgebra, Random
1616

1717
import OptimizationBase: instantiate_function, OptimizationCache, ReInitCache
1818
import SciMLBase: OptimizationProblem,

0 commit comments

Comments
 (0)