← Back to Pull requests

[Feature] Add `functional_vmap` to call a module with stacked parameter sets #3327

Closed
unknown closed this pull request without merging on Oct 24, 2026 16:36 UTC
View on GitHub
unknown unknown commented on Oct 23, 2026 19:39 UTC
Author

Description

Adds tensordict.nn.functional_vmap.

Tests:


  • TestFunctionalVmap in test/nn/test_nn.py covers:

  • - a plain module with inputs in args and in kwargs
    - a TensorDictModule
    - a module that takes its own params argument
    - params with batch sizes [], [6] and [2, 3]
    - mapped and shared inputs
    - the shape and name errors
    - chunk_size and randomness
    - nn.GRU with loop=True
    - loop=True against vmap, for both outputs and gradients.
  • test_functional_vmap in test/compile/test_compile.py runs both paths with torch.compile(fullgraph=True).
  • Motivation and Context

    Closes #2813.

    Adds a function to call a module with a stack of parameter sets, with a loop fallback for modules that vmap rejects.

    Types of changes

    What types of changes does your code introduce? Remove all that do not apply:

  • Bug fix (non-breaking change which fixes an issue)

  • New feature (non-breaking change which adds core functionality)

  • Breaking change (fix or feature that would cause existing functionality to change)

  • Documentation (update in the documentation)

  • Example (update in the folder of examples)
  • Checklist

    Go over all the following points, and put an x in all the boxes that apply.
    If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide (required)

  • My change requires a change to the documentation.

  • I have updated the tests accordingly (required for a bug fix or a new feature).

  • I have updated the documentation accordingly.
  • Diff: 214 lines (+160 / -54) across 2 files Reviewer: phoeenniixx Review duration: 1256m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 214 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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
    Diff Size diff_size
    0.321
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3327"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 36.6% (MEDIUM) · Higher = larger blast radius
    36.6%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 14.4% · Safe to merge
    14.4%