Skip to content

Conversation

@mdavis36
Copy link
Collaborator

@mdavis36 mdavis36 commented Feb 2, 2026

No description provided.

@mdavis36 mdavis36 linked an issue Feb 2, 2026 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Description

  • Replaced std::unique_ptr<std::vector<Val*>> with direct std::vector<Val*> for axioms_ member

  • Updated all container operations to use direct vector methods instead of pointer dereferencing

  • Simplified memory management by removing unnecessary unique_ptr wrapper

  • Modified copy, clear, and initialization logic to work with direct vector storage

Changes walkthrough

Relevant files
Enhancement
container.cpp
Replace unique_ptr with direct vector for axioms_

csrc/ir/container.cpp

  • Changed axioms_ from unique_ptr to direct vector usage
  • Updated copy function to use vector reserve and push_back instead of
    unique_ptr operations
  • Modified clear function to use vector clear instead of reset
  • Updated lazyInitAxioms to work with direct vector storage
  • Changed assumePositive and assumeNonNegative to use vector
    emplace_back
  • +12/-13 
    container.h
    Update axioms_ member declaration to use direct vector     

    csrc/ir/container.h

  • Changed axioms_ member from std::unique_ptr> to std::vector
  • Updated axioms() accessor method to return reference to direct vector
  • +2/-2     

    PR Reviewer Guide

    Here are some key observations to aid the review process:

    🧪 PR contains tests
    ⚡ Recommended focus areas for review
    Memory Management

    The refactoring from unique_ptr to direct vector member is sound, but verify that all existing axioms are properly cloned during the copy operation and that there are no memory leaks or dangling references introduced by this change.

    if (!from->axioms_.empty()) {
      to->axioms_.reserve(from->axioms_.size());
      for (auto pred : from->axioms_) {
        to->axioms_.push_back(ir_cloner.clone(pred));
      }
    }
    Lazy Initialization Logic

    The lazyInitAxioms() function now checks for empty() instead of null pointer. Ensure this logic correctly handles all initialization scenarios and that the axioms vector is properly initialized before use.

      if (axioms_.empty()) {
        axioms_.reserve(kParallelTypeThreads.size() * 3);
        auto zero = zeroVal();
        for (auto p : kParallelTypeThreads) {
          auto pidx = NamedScalar::getParallelIndex(p);
          auto pdim = NamedScalar::getParallelDim(p);
          axioms_.push_back(SimplifyingIrBuilder::geExpr(pidx, zero));
          axioms_.push_back(SimplifyingIrBuilder::gtExpr(pdim, zero));
          axioms_.push_back(SimplifyingIrBuilder::ltExpr(pidx, pdim));
        }
      }
    }

    Test failures

    • (Medium, 3) Shape mismatch in thunderfx nvFuser higher-order inplace alias update tests

      Test Name A100 GB200 H100 Source
      thunder.tests.test_update_aliases.test_higher_order_inplace_alias_update_nvfuser_cuda_thunder.dtypes.float32
    • (Medium, 1) Thunder–Torch scalar mismatch in nanogpt autograd test (thunder.tests.test_networks)

      Test Name GB200 Source
      thunder.tests.test_networks.test_nanogpt_complete_autograd_nvfuser_cuda_thunder.dtypes.float32

    @greptile-apps
    Copy link
    Contributor

    greptile-apps bot commented Feb 2, 2026

    Greptile Overview

    Greptile Summary

    Refactored axioms_ member variable from std::unique_ptr<std::vector<Val*>> to a direct std::vector<Val*>, simplifying memory management and eliminating unnecessary heap allocation.

    Key changes:

    • Removed unique_ptr wrapper around axioms_ vector
    • Simplified null checks from axioms_ != nullptr to axioms_.empty()
    • Changed cleanup from axioms_.reset() to axioms_.clear()
    • Removed dereference operators (*axioms_) throughout the codebase
    • Updated copy operation to use direct vector operations instead of make_unique

    This change aligns with the pattern used for other member variables like metadata_ and simplifies the code by removing an unnecessary level of indirection.

    Confidence Score: 5/5

    • This PR is safe to merge with no identified issues
    • The refactoring is straightforward and correctly updates all references to axioms_. The change simplifies memory management by removing an unnecessary unique_ptr wrapper while maintaining identical semantics. All operations (copy, clear, swap, lazy initialization) are properly updated.
    • No files require special attention

    Sequence Diagram

    sequenceDiagram
        participant Client
        participant IrContainer
        participant axioms_
    
        Note over IrContainer,axioms_: Before: std::unique_ptr<std::vector<Val*>>
        Note over IrContainer,axioms_: After: std::vector<Val*>
    
        Client->>IrContainer: axioms()
        IrContainer->>IrContainer: lazyInitAxioms()
        alt axioms_.empty()
            IrContainer->>axioms_: reserve(size)
            IrContainer->>axioms_: push_back(expr1)
            IrContainer->>axioms_: push_back(expr2)
            IrContainer->>axioms_: push_back(expr3)
        end
        IrContainer-->>Client: return axioms_
    
        Client->>IrContainer: assumePositive(val)
        IrContainer->>IrContainer: lazyInitAxioms()
        IrContainer->>axioms_: emplace_back(gtExpr)
    
        Client->>IrContainer: copy(from, to)
        alt !from->axioms_.empty()
            IrContainer->>axioms_: reserve(size)
            loop for each pred
                IrContainer->>axioms_: push_back(clone(pred))
            end
        end
    
        Client->>IrContainer: clear()
        IrContainer->>axioms_: clear()
    
        Client->>IrContainer: swap(a, b)
        IrContainer->>axioms_: std::swap(a.axioms_, b.axioms_)
    
    Loading

    Copy link
    Contributor

    @greptile-apps greptile-apps bot left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    No files reviewed, no comments

    Edit Code Review Agent Settings | Greptile

    @mdavis36
    Copy link
    Collaborator Author

    mdavis36 commented Feb 2, 2026

    !test

    Base automatically changed from md/rename-storage-files to md/fusion-base February 2, 2026 17:44
    @mdavis36 mdavis36 force-pushed the md/fusion-base branch 3 times, most recently from 3057d13 to 915d08f Compare February 3, 2026 07:48
    Base automatically changed from md/fusion-base to main February 3, 2026 16:17
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    unique_ptr axioms in Ir Containers

    1 participant