diff --git a/.github/workflows/StanCI.yml b/.github/workflows/StanCI.yml deleted file mode 100644 index 78cfb817a..000000000 --- a/.github/workflows/StanCI.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Stan-CI - -on: - push: - branches: - - master - pull_request: - -jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - matrix: - version: - - '1.6' - - '1' - os: - - ubuntu-latest - arch: - - x64 - steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 - with: - version: ${{ matrix.version }} - arch: ${{ matrix.arch }} - - uses: actions/cache@v1 - env: - cache-name: cache-artifacts - with: - path: ~/.julia/artifacts - key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} - restore-keys: | - ${{ runner.os }}-test-${{ env.cache-name }}- - ${{ runner.os }}-test- - ${{ runner.os }}- - - uses: julia-actions/julia-buildpkg@latest - - uses: julia-actions/julia-runtest@latest - with: - coverage: false - env: - STAGE: stan diff --git a/src/Turing.jl b/src/Turing.jl index 86eeb9be3..06ab9644b 100644 --- a/src/Turing.jl +++ b/src/Turing.jl @@ -57,16 +57,6 @@ using .Inference include("variational/VariationalInference.jl") using .Variational -# TODO: re-design `sample` interface in MCMCChains, which unify CmdStan and Turing. -# Related: https://github.com/TuringLang/Turing.jl/issues/746 -#@init @require CmdStan="593b3428-ca2f-500c-ae53-031589ec8ddd" @eval begin -# @eval Utilities begin -# using ..Turing.CmdStan: CmdStan, Adapt, Hmc -# using ..Turing: HMC, HMCDA, NUTS -# include("utilities/stan-interface.jl") -# end -# end - @init @require DynamicHMC="bbc10e6e-7c05-544b-b16e-64fede858acb" begin @eval Inference begin import ..DynamicHMC diff --git a/src/utilities/stan-interface.jl b/src/utilities/stan-interface.jl deleted file mode 100644 index 76e2430e5..000000000 --- a/src/utilities/stan-interface.jl +++ /dev/null @@ -1,88 +0,0 @@ -#### -#### Stan interface -#### - -# NOTE: -# Type fields -# fieldnames(CmdStan.Sample) -# num_samples, num_warmup, save_warmup, thin, adapt, algorithm - -# fieldnames(CmdStan.Hmc) -# engine, metric, stepsize, stepsize_jitter - -# fieldnames(CmdStan.Adapt) -# engaged, gamma, delta, kappa, t0, init_buffer, term_buffer, window - -# Ref -# http://goedman.github.io/Stan.jl/latest/index.html#Types-1 - -function sample(mf, ss::CmdStan.Sample) - return sample(mf, ss.num_samples, ss.num_warmup, - ss.save_warmup, ss.thin, ss.adapt, ss.alg) -end - -function sample( - mf, - num_samples::Int, - num_warmup::Int, - save_warmup::Bool, - thin::Int, - ss::CmdStan.Sample -) - return sample(mf, num_samples, num_warmup, save_warmup, thin, ss.adapt, ss.alg) -end - -function sample( - mf, - num_samples::Int, - num_warmup::Int, - save_warmup::Bool, - thin::Int, - adapt::CmdStan.Adapt, - alg::CmdStan.Hmc -) - if alg.stepsize_jitter != 0.0 - @warn("[Turing.sample] Turing does not support adding noise to stepsize yet.") - end - if !adapt.engaged - if isa(alg.engine, CmdStan.Static) # hmc - stepnum = alg.engine.int_time ÷ alg.stepsize - sample(mf, HMC(alg.stepsize, stepnum), num_samples; adaptor=NUTSAdaptor(adapt)) - elseif isa(alg.engine, CmdStan.Nuts) # error - error("[Turing.sample] CmdStan.Nuts cannot be used with adapt.engaged set as false") - end - else - if isa(alg.engine, CmdStan.Static) # hmcda - sample(mf, HMCDA(num_warmup, adapt.delta, alg.engine.int_time), num_samples; - adaptor=NUTSAdaptor(adapt)) - elseif isa(alg.engine, CmdStan.Nuts) # nuts - if isa(alg.metric, CmdStan.diag_e) - sample(mf, NUTS(num_warmup, adapt.delta), num_samples; - adaptor=NUTSAdaptor(adapt)) - else # TODO: reove the following since Turing support this feature now. - @warn("[Turing.sample] Turing does not support full covariance matrix for pre-conditioning yet.") - end - end - end -end - -# FIXME: where is `spl` in the code below? -function AHMCAdaptor(adaptor) - if :engaged in fieldnames(typeof(adaptor)) # CmdStan.Adapt - adaptor.engaged ? spl.alg.n_adapts : 0, - AHMC.MassMatrixAdaptor(metric), - AHMC.StepSizeAdaptor(adaptor.gamma, - adaptor.t0, adaptor.kappa, adaptor.δ, init_ϵ), - adaptor.init_buffer, - adaptor.term_buffer, - adaptor.window - else # default adaptor - @warn "Invalid adaptor type: $(typeof(adaptor)). Default adaptor is used instead." - adaptor = AHMC.StanHMCAdaptor( - AHMC.MassMatrixAdaptor(:DiagEuclideanMetric), - AHMC.StepSizeAdaptor(spl.alg.δ, init_ϵ) - ) - AHMC.initialize!(adaptor, spl.alg.n_adapts) - adaptor - end -end diff --git a/test/Project.toml b/test/Project.toml index 450ad8b04..4f7a48ad2 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -4,7 +4,6 @@ AdvancedMH = "5b7e9947-ddc0-4b3f-9b55-0d8042f74170" AdvancedPS = "576499cb-2369-40b2-a588-c64705576edc" AdvancedVI = "b5ca4192-6429-45e5-a2d9-87aec30a685c" Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5" -CmdStan = "593b3428-ca2f-500c-ae53-031589ec8ddd" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" DistributionsAD = "ced4e74d-a319-5a8a-b0ac-84af2272839c" DynamicHMC = "bbc10e6e-7c05-544b-b16e-64fede858acb" @@ -37,7 +36,6 @@ AdvancedMH = "0.6" AdvancedPS = "0.3" AdvancedVI = "0.1" Clustering = "0.14" -CmdStan = "6.0.8" Distributions = "0.25" DistributionsAD = "0.6.3" DynamicHMC = "2.1.6, 3.0" diff --git a/test/runtests.jl b/test/runtests.jl index 5e0c1f0e2..ae73d2be3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -102,7 +102,6 @@ macro timeit_include(path::AbstractString) :(@timeit TIMEROUTPUT $path include($ end @testset "utilities" begin - # include("utilities/stan-interface.jl") @timeit_include("inference/utilities.jl") end end diff --git a/test/utilities/stan-interface.jl b/test/utilities/stan-interface.jl deleted file mode 100644 index dd6874ea5..000000000 --- a/test/utilities/stan-interface.jl +++ /dev/null @@ -1,7 +0,0 @@ -@stage_testset "stan" "stan-interface.jl" begin - using CmdStan - - chn = sample(gdemo_default, 2000, 1000, false, 1, - CmdStan.Adapt(), CmdStan.Hmc(stepsize_jitter=0)) - check_gdemo(chn) -end