Skip to content

Homeless in the ecosystem adoption: to_constrained (+ free_dimension/flat_dimension naming) — where should the unconstrained-space layer live? #845

Description

@seabbs-bot

Found while re-scoping #831 (CD adoption of the standalone dist-ops packages). Not a blocker — a design decision needed before the inference-layer migration lands.

Context

The inference layer is now adoptable: ComposedDistributions main is a strict superset of CD's composers/logdensity.jl. params_table upstream is 5-col (edge | param | value | support | prior) and emits :thin rows, so the #90 uncertain-first precondition is met. Upstream ComposedLogDensity{D,P,T,L,FP,CP} already carries fixed-param rows (covering CD's _FixPlan, #752/#761) and pool groups, and flatten/unflatten/as_logdensity/logdensity are public with matching names.

So CD can delete its generic logdensity half and sit on upstream. Two pieces have no upstream counterpart.

(1) to_constrained has no upstream home

  • CD: src/composers/logdensity.jl:499 (function to_constrained end), declared public at src/public.jl:126, with the actual method living in CD's BijectorsExt.
  • Upstream: no to_constrained anywhere in ComposedDistributions src/ or ext/ (grepped against current main).

to_constrained(prob, z) -> (x, logjac) is the unconstrained→constrained transform + log-Jacobian, i.e. the sampler-facing layer over the prior support. It is generic over any composed tree — nothing about it is censoring-specific — so on the "generic composition lives upstream" principle it arguably belongs in ComposedDistributions next to flatten/unflatten, as a Bijectors extension there.

Decision needed: does CD keep to_constrained (a CD-owned method on upstream types — legal, since it adds a new signature), or does it go upstream so any ComposedDistributions user gets NUTS-ready unconstrained sampling for free?

(2) free_dimension vs flat_dimension — same concept, two names

  • CD declares free_dimension public (src/public.jl:126).
  • Upstream declares flat_dimension public (ComposedDistributions/src/composers/logdensity.jl:94).

Same concept (the length of the flat parameter vector). If CD adopts upstream's logdensity layer, one name should win. Suggest CD adopts flat_dimension and deprecates/aliases free_dimension, unless there is a reason to prefer CD's spelling.

Related

This was opened by a bot. Please ping @seabbs for any questions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions