Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Complete Phase 2 of the IR Container Refactor: transition IrContainer from
unique_ptrtoshared_ptrownership, enabling multiple Fusions to share one container while maintaining independent IR graphs. This lays the foundation for Phase 3 scalar unification and Host IR JIT Intermediate compilation.The work is organized into two layers: foundation changes (PRs A–B) that restructure Fusion to own all per-Fusion state and control statement registration, and shared_ptr changes (PRs 1–4) that add shared ownership, per-Fusion tracking, copy/move/swap semantics, and thread safety.
Motivation
The nvFuser segmenter splits a user-authored Fusion into segment Fusions, each of which currently gets a full clone of all IR nodes — including scalars that are identical across segments. This duplication prevents a single
ExpressionEvaluatorfrom evaluating buffer sizes across segment boundaries, requiring expensive per-segment evaluation.Phase 2 enables shared container storage so that Phase 3 can reuse scalars:
What Changed
Foundation (PRs #5954 – #5958) — Restructure Fusion as owner of per-Fusion state:
zero_val_,one_val_, etc. moved from IrContainer to Fusion (lazy-cached)axioms_,metadata_moved from IrContainer to FusionregisterVal/registerExpr/removeVal/removeExprinlined into Fusionshared_ptr transition (PRs #5960, #5961, #5964, #5971) — Enable shared container storage:
unique_ptr<IrContainer>→shared_ptr<IrContainer>sharing_fusions_setper_fusion_vals_,per_fusion_exprs_maps for ownership queriesvals(),deterministic_vals(), etc. return only the calling Fusion's nodesval_type_name_map_ensures cloned Vals get matching namesstd::shared_mutexwith two-layer locking (IrContainer self-locking + Fusion ContainerMutator)removeStatementsOwnedBy(this)instead ofir_container()->clear()Architecture Before and After
Key Design Invariants
fusion->vals()=/=ir_container()->vals().Fusion::clear()only clears this Fusion's state. Not the shared container.Validation Results
Zero regressions from the shared_ptr changes. All failures are pre-existing CUDA out-of-memory errors.
PR Chain
This comprehensive PR is composed of six atomic, individually CI-green increments:
Foundation (standalone, CI-clean Fusion API restructuring):
shared_ptr transition: