← Back to Pull requests

Remove static dimension type parameter #42

Open
unknown opened this pull request with 298 lines diff across 3 files
View on GitHub
unknown unknown commented on Mar 16, 2026 15:16 UTC
Author

Currently, the "dimension" of the Sobol sequence is implemented as a static type parameter. However, the whole code never makes any use that the value is known at compile time. Instead, all it does is iterating over 1:ndims (which will typically be not so small that loop unrolling would be favorable in any way, and the loop bodies are too long for this anyway) and creating vectors of length ndims, which turns the static parameter into a runtime variable.

I would say that the whole point why for example Array uses a static dimension parameter instead of dynamic ones is:

  • code for efficient striding will be different for each dimension count and can then be efficiently compiler-generated and inlined

  • the "size" property can be a dimension-sized tuple with a size for each dimension, leading to type stability

  • and a very minor point is that dispatch will already do type checking when using arrays of wrong dimension, though since the design decision was made long before JET or PackageCompiler, this is not really be relevant here
  • For multiple SobolSeq of different dimension, instead, the compiler has to regenerate the code for every single method with the only difference between them being an integer constant in the function body, which is very inefficient. On top on this, any package that uses this one and needs to generate a SobolSeq with only runtime-known length (actually, I'm here because of MultistartOptimization.jl), unavoidably now has type instabilities and uninferrability (or it follows the same approach and "staticizes" the dynamical value, leading to dynamical dispatch and compiler overhead by method generation).
    Given that there is no technical reason or benefit for the static type parameter, I propose to change it to a field of the struct instead, which solves all the mentioned problems. SobolSeq is now unparametrized and ScaledSobolSeq only contains the type of the boundaries as a type parameter.
    This is a breaking change if people explicitly wrote SobolSeq{N} before, therefore this would be a major version increment.
    Note that I increased the Julia version to 1.8 since I declared the ndims field const; however, this is the only reason for the compatibility reduction and can of course also be removed if you'd rather like to keep compatibility.

    Closes #18 as obsolete (see also my comment there).

    Diff: 298 lines (+223 / -75) across 3 files Reviewer: projekter Review duration: 358090m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.47) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 298 lines diff across 3 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.341
    Real PR Conversation Timeline
    1 comments
    "Review active on #42"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47% (MEDIUM) · Higher = larger blast radius
    47%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26% · Safe to merge
    26%