Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ReplacePrefixContext withmodel.prefix#1011

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
penelopeysm wants to merge7 commits intomain
base:main
Choose a base branch
Loading
frompy/no-prefix-context

Conversation

@penelopeysm
Copy link
Member

@penelopeysmpenelopeysm commentedAug 5, 2025
edited
Loading

What?

This PR removesPrefixContext, and replaces it with an equivalent field on theModel struct.

Really?

I actually quite dislike this PR, and I don't think this is the correct direction to go in.

I thinkPrefixContext was easier to reason about because it allowed for a cleaner isolation of prefixing-related code. The absence of PrefixContext means that prefixes now get handled at different levels of the codebase, and is particularly messy when it comes to submodels.

But, well, the work's done, so I may as well put it up.

More details?

There are two main 'types' of changes in this PR:

(1) Compiler

Inside the compiler, instead of justvn (which is the lhs of tilde) we now have to handle bothleft_vn (which is the lhs of tilde) as well asvn (which is the result of applying any currently active prefixes).

In effect, because the prefixing no longer happens in the tilde-pipeline, prefixes have to be handled at a higher level. For example, previously you could do something like:

f(ctx::PrefixContext, vn::VarName)=f(childcontext(ctx),prefix(ctx.prefix, vn))f(ctx::OtherContext, vn::VarName)=...

SincePrefixContext no longer exists, you have to prefix the VarName in the compiler itself before passing that to the general methodf(ctx, vn).

This strategy works for functions likegetconditioned,hasconditioned, etc.

(2) tilde-pipeline

Fortilde_assume!!, the above strategy is not enough. We also have to threadmodel.prefix through totilde_assume!!.

The reason for this is quite subtle and has to do with submodels. Consider the following:

@modelfunctionf()    x~Normal()# (2)end@modelfunctiong()return a~to_submodel(f())# (1)endpg=prefix(g(),@varname(hello))

In this case, we want the sampled variable to be calledhello.a.x. If we use automatic prefixing as is shown here, this is easy to do: insidetilde_assume!! of thetop-level model (1),a will already have been prefixed withhello, so theleft argument totilde_assume!! will behello.a. We can thus simply set this as the appropriate 'prefix' for the inner model.

The problem arises if we don't automatically prefix:

@modelfunctionf()    x~Normal()# (2)end@modelfunctiong()return a~to_submodel(f(),false)# (1)endpg=prefix(g(),@varname(hello))

If we run this, everything is the same as before: when we get to (1),tilde_assume!! knows that the prefixed left-hand side ishello.a.However, because we don't want to prefix the submodel, the inner variable should only be calledhello.x, andnothello.a.x.

This means that we have to store the prefixhello separately so that we can apply it to the submodelwithout thea as well.

Note that in the absence of submodels, this would be entirely unnecessary.

@penelopeysmpenelopeysm changed the base branch frommain topy/remove-samplingcontextAugust 5, 2025 16:28
@github-actions
Copy link
Contributor

github-actionsbot commentedAug 5, 2025
edited
Loading

Benchmark Report for Commitcaa0c0f

Computer Information

Julia Version 1.11.7Commit f2b3dbda30a (2025-09-08 12:10 UTC)Build Info:  Official https://julialang.org/ releasePlatform Info:  OS: Linux (x86_64-linux-gnu)  CPU: 4 × AMD EPYC 7763 64-Core Processor  WORD_SIZE: 64  LLVM: libLLVM-16.0.6 (ORCJIT, znver3)Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

Benchmark Results

@codecov
Copy link

codecovbot commentedAug 5, 2025
edited
Loading

Codecov Report

❌ Patch coverage is89.79592% with5 lines in your changes missing coverage. Please review.
⚠️ Pleaseupload report for BASE (breaking@79150ba).Learn more about missing BASE report.

Files with missing linesPatch %Lines
src/prefix.jl85.18%4 Missing⚠️
src/compiler.jl88.88%1 Missing⚠️
Additional details and impacted files
@@             Coverage Diff             @@##             breaking    #1011   +/-   ##===========================================  Coverage            ?   80.88%           ===========================================  Files               ?       40             Lines               ?     3746             Branches            ?        0           ===========================================  Hits                ?     3030             Misses              ?      716             Partials            ?        0

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

@github-actions
Copy link
Contributor

DynamicPPL.jl documentation for PR#1011 is available at:
https://TuringLang.github.io/DynamicPPL.jl/previews/PR1011/

@penelopeysmpenelopeysmforce-pushed thepy/no-prefix-context branch 2 times, most recently from180816d to93ceec4CompareAugust 6, 2025 00:08
@penelopeysmpenelopeysm mentioned this pull requestAug 8, 2025
6 tasks
@penelopeysmpenelopeysmforce-pushed thepy/remove-samplingcontext branch from5278370 to331279cCompareAugust 8, 2025 10:23
@penelopeysmpenelopeysmforce-pushed thepy/remove-samplingcontext branch 3 times, most recently from0bd4e02 to8e3dcacCompareAugust 10, 2025 23:26
@penelopeysmpenelopeysmforce-pushed thepy/remove-samplingcontext branch 2 times, most recently from0b87d0d to992569fCompareSeptember 18, 2025 13:03
Base automatically changed frompy/remove-samplingcontext tobreakingSeptember 24, 2025 15:48
@penelopeysm
Copy link
MemberAuthor

holy merge conflicts

Base automatically changed frombreaking tomainOctober 21, 2025 17:06
@penelopeysmpenelopeysm mentioned this pull requestOct 21, 2025
@penelopeysm
Copy link
MemberAuthor

Agh, this is frustrating.

@penelopeysmpenelopeysm changed the base branch frommain tobreakingNovember 4, 2025 17:33
@penelopeysmpenelopeysm marked this pull request as ready for reviewNovember 4, 2025 17:33
Base automatically changed frombreaking tomainDecember 2, 2025 12:45
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

@penelopeysmpenelopeysm

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@penelopeysm@mhauru

[8]ページ先頭

©2009-2025 Movatter.jp