Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backports for 1.12 #57444

Open
wants to merge 16 commits into
base: release-1.12
Choose a base branch
from
Open

Backports for 1.12 #57444

wants to merge 16 commits into from

Conversation

KristofferC
Copy link
Member

@KristofferC KristofferC commented Feb 17, 2025

Backported PRs:

Need manual backport:

Non-merged PRs with backport label:

…57421)

When loading a pkgimage, the new bpart validation code needs to check if
the export set of any using'd packages differs from what it would have
been during precompile. This could e.g. happen if somebody (or Revise)
eval'd a new `export` statement into a package that was `using`'d.
However, this case is somewhat rare, so let's optimize it by keeping a
bit in `Module` that keeps track of whether anything like that has
happened and if not skipping the revalidation. This slightly improves
pkgimage load time in the ordinary case. More optimizations to follow.

(cherry picked from commit 39255d4)
@KristofferC KristofferC added the release Release management and versioning. label Feb 17, 2025
Keno added 4 commits February 17, 2025 19:36
This addresses post-commit review
#57230 (comment).
This change was left-over from before I decided to also change the type
of the `source` argument (at which point `source.module` was unavailable
in the function). This module was supposed to be the same, but it turns
out that both the julia tests and several packages use this code
manually and use different modules for the two places. Use the same one
we used before (which is probably more correct anyway) to fix #57417

(cherry picked from commit 0c5372f)
)

This applies the existing prohibition against introducing new bindings
in a closed module to binding replacement as well (for the same reason -
the change won't be persisted after reload). It is pretty hard to even
reach this point, since `eval` into closed modules is already prohibited
and there's no surface syntax for cross-module declaration, but it is
technically reachable from lowered IR. Further, in the future we may
make all of these builtins, which would make it easier. Thus, be
consistent now and fully disallow binding replacement in closed modules
during precompile.

(cherry picked from commit 56aed62)
…57426)

An upcoming optimization will skip most binding validation if no binding
replacement has taken place in (sysimage, pkgimage) modules. However, as
a special case, we would like to treat `Main` as a non-sysimage module
because the addition of new bindings in `Main` is common and we would
like this to not ruin the optimization. To make this legal, we have to
prohibit `import`ing or `using` any `Main` bindings in pkgimages. I
don't think anybody actually does this, particularly, since `Main` is
not considered loading during precompile (so you have to use the main
binding via (Core|Base|).Main), and I can't think of any good semantic
reason to want to do this, but regardless, it does add additional
restrictions to `using`/`import`, so I wanted to break it out into its
own PR.

(cherry picked from commit 726c816)
…dules (#57433)

This implements the optimization proposed in #57426 by keeping track of
whether any bindings were replaced in image modules (excluding `Main` as
facilitated by #57426). In addition, we augment serialization to keep
track of whether a method body contains any GlobalRefs that point to a
loaded (system or package) image. If both of these flags are true, we
can skip scanning the body of the method, since we know that we neither
need to add any additional backedges nor were any of the referenced
bindings invalidated. The performance impact on end-to-end load time is
small, but measurable. Overall `@time using ModelingToolkit`
consistently improves about 5% using this PR. However, I should note
that using time is still about 40% slower than 1.11. This is not
necessarily an Apples-to-Apples comparison as there were substantial
other changes on 1.12 (as well as current load-time-tunings targeting
older versions), but I wanted to put the number context.

(cherry picked from commit f6e2b98)
dkarrasch and others added 10 commits February 20, 2025 19:08
I was playing with strengthening the semantics around #57290. However,
the particular change I was trying turned out too breaking (I may try a
weaker version of it). Still, there were a number of good changes found
in two categories:

1. We should explicitly import types when defining constructors. This
has been allowed for a long time, but we may want to consider removing
it, especially given the new binding semantics which make it more
confusing as in #57290.

2. There were a couple of places where I don't think it was intended for
generic functions in question not to extend Base.

(cherry picked from commit 778e079)
Other backends (in this case NVPTX) require that `invariant.load`
metadata is maintained to generate non-coherent loads.

Currently, we unconditionally strip that metadata from all loads,
since our other uses of it may have become invalid.

x-ref: llvm/llvm-project#112834
JuliaGPU/CUDA.jl#2531

---------

Co-authored-by: Gabriel Baraldi <[email protected]>
(cherry picked from commit 29da86b)
This reverts a portion of commit
50833c8.

This algorithm is not able to handle simple cases where there is any
internal padding, such as the example of:
```
struct LotsBytes
    a::Int8
    b::NTuple{256,Int}
    c::Int
end
```

Unfortunately fixing it is a bit of a large project right now, so
reverting now to fix correctness while working on that.

Fixes #55513 (indirectly, by removing broken code) Maybe reopens #54109,
although the latency issue it proposes to fix doesn't occur on master
even with this revert (just the mediocre looking IR result output
returns)

(cherry picked from commit a65c2cf)
also add nsw/nuw flags whenever possible.

(cherry picked from commit b9a8d46)
…57471)

The buffer may end up reallocated by the additional writes performed to
it in this function.

(cherry picked from commit 0fb5fa0)
Fixes #56904.

The associated PR (#55876) compiles a finally block, then compiles a
renumbered version of it. This works if `compile` doesn't mutate its
input, but in reality, lambda bodies were being `set!` when linearized.
The "invalid syntax" error was a result of attempting to linearize a
lambda twice.

(cherry picked from commit 414aca2)
…al (#57447)

The `_DECLARED` partition kind used to be considered `guard`, but we now
consider it equivalent to an Any-typed `_GLOBAL` (but with weaker
redefinition properties). That said, its `->restriction` is NULL, so add
it to the list of bindings that should return `nothing` here (and thus
`Any` from the bulitin) to fix #57446.

(cherry picked from commit 0163991)
@KristofferC
Copy link
Member Author

@nanosoldier runtests(["SIMDTypes", "LazyBroadcast", "DontMaterialize", "RiemannComplexNumbers", "MistyClosures", "SyntaxTree", "Fuzzy", "Syslogs", "TraceFuns", "TypeTree", "CatViews", "ProtoStructs", "FindDefinition", "Bits", "MultiThreadedCaches", "ExprTools", "CoverageTools", "FuzzyCompletions", "WidthLimitedIO", "SingleFloats", "Requires", "CountFlops", "InterProcessCommunication", "StringAlgorithms", "CellLists", "MappedArrays", "MallocArrays", "PtrArrays", "CompTime", "InternedStrings", "Recyclers", "OperatorScaling", "BasesAndSamples", "PrecompileTools", "OptimalSortingNetworks", "Adapt", "RNGPool", "NarrativeTest", "RoundingEmulator", "ReferenceImplementations", "EnzymeCore", "StarAlgebras", "ThreadLocalCounters", "YaoHIR", "Match", "ChangePrecision", "Results", "BracedErrors", "Stuffing", "FieldFlags", "RuntimeGeneratedFunctions", "FlatBuffers", "TypeStability", "BSON", "Interfaces", "KeywordCalls", "Umlaut", "JACC", "LoweredCodeUtils", "Spec", "Abaco", "BorrowChecker", "FileCmp", "LambertW", "Baobzi", "CSTParser", "TypedSyntax", "LMDB", "ResumableFunctions", "LoopFieldCalc", "DotCall", "BibInternal", "GAFramework", "TPSAInterface", "GridMaps", "Hygienic", "COESA", "DRIPs", "SortedVectors", "TrixiBase", "StaticArraysBlasInterfaces", "Colors", "RBNF", "Tracy", "SimpleExpressions", "CircularArrayBuffers", "MaybeInplace", "DataScienceTraits", "ForwardMethods", "ProgressMeter", "OpenQASM", "JuliaWorkspaces", "FactorLoadingMatrices", "RollingWindowArrays", "SimJulia", "Mueller", "PlutoHooks", "BioAtomsCount", "DimensionfulAngles", "BitBasis", "AStarGridSearch", "BioVossEncoder", "FixedPointDecimals", "Functors", "StaticLint", "ConstraintCommons", "GeometryTypes", "UnitfulChainRules", "PiecewiseLinearFunctions", "SimpleI18n", "GenericSchur", "AdaptiveSparseGrids", "QuanticsGrids", "Accessors", "BioMarkovChains", "PDMats", "LaTeXEscapes", "GraphQLGen", "ConcurrentSim", "Divergences", "ADTypes", "SHTns", "GCMAES", "FileIO", "MultiBroadcastFusion", "DiscretePIDs", "DispatchDoctor", "HypertextTemplates", "XDiag", "PolarizedTypes", "MCP2221Driver", "CallableExpressions", "LaTeXTabulars", "InteractiveErrors", "Binning2D", "GitCommand", "Delaunator", "FCSFiles", "SMCExamples", "DocSeeker", "Cosmology", "ExponentialAction", "GenericLinearAlgebra", "CannotWaitForTheseOptimisers", "RustFFT", "SigmaProofs", "CellArrays", "YaoBase", "FiniteDifferences", "LinearOperators", "MarchingCubes", "FastPower", "ConvexHulls2d", "SpectralKit", "Cthulhu", "DifferentiableFlatten", "JuliaInterpreter", "RRTMGP", "MarkovKernels", "FastCholesky", "UnitfulAssets", "ColPack", "PositionalEmbeddings", "BoundedDegreeGraphs", "DynamicQuantumCircuits", "ControllerFormats", "OpenSSLGroups", "Oracle", "ShuffleProofs", "UCX", "SquashFS", "InPartS", "QuadGK", "ParameterHandling", "InteratomicPotentials", "CryptoGroups", "ParameterSchedulers", "Stencils", "AllocCheck", "NearestNeighborDescent", "Polyester", "NLSolvers", "ArrayLayouts", "PlayingCards", "OpticalPropagation", "ADOLC", "TerminalGat", "NestedGraphs", "AtomicSymmetries", "TypedMatrices", "WannierIO", "PrimitiveOneHot", "LatinHypercubeSampling", "StableHashTraits", "StructArrays", "QuasiArrays", "GridWorlds", "DiffImageRotation", "MolecularMinimumDistances", "LinkedInAPI", "Proj", "QXZoo", "NeidArchive", "AdmittanceModels", "RuleMiner", "ExaTron", "LFRBenchmarkGraphs", "AllocArrays", "Presentation", "RadonKA", "CometLogger", "LinearElasticityBase", "Roots", "DedekindCutArithmetic", "YAAD", "AbstractDifferentiation", "UnitfulLinearAlgebra", "EcRequests", "DoubleFloats", "EnergyExpressions", "MetaGraphsNext", "DictArrays", "PyCallJLD2", "PyArrow", "IntervalLinearAlgebra", "XmlStructWriter", "Sixel", "FiniteHorizonGramians", "AtiyahBott", "MathematicalSystems", "SwarmAgents", "CCBlade", "Kronecker", "DataToolkit", "AngularMomentumAlgebra", "ForwardDiffPullbacks", "DistanceTransforms", "Polylabel", "FoldRNA", "ScHoLP", "Quante", "JMPReader", "BibParser", "ToyPublicKeys", "FiberNlse", "IsingModels", "Rotations", "MonotonicSplines", "FunctionFusion", "NomnomlJS", "ProximalAlgorithms", "TransformVariables", "MvNormalCalibration", "SparseMatricesCOO", "Optimisers", "StandardizedRestrictedBoltzmannMachines", "LandauDistribution", "ConstitutiveModels", "DiscreteChoiceCalculations", "ClimaUtilities", "Tensorial", "TreeTools", "AdvRBMs", "Bibliography", "TestTools", "MatrixFactorizations", "Tensors", "TensorCrossInterpolation", "ExampleJuggler", "WaterLily", "GaloisFields", "SliceMap", "TrustRegionMethods", "RegionGrids", "Seaborn", "Experimenter", "FinancialToolbox", "SparseMatrixColorings", "CCDReduction", "HePPCAT", "CenteredRBMs", "QuadraticFormsMGHyp", "DataToolkitCommon", "DistributionFits", "TimeseriesFeatures", "Ephemerides", "NCDatasets", "ChunkedCSV", "SLEEFMath", "ConvolutionalOperatorLearning", "GrafCSV", "ImageSmooth", "CatBoost", "HopTB", "QuantumGradientGenerators", "GPLikelihoods", "SymFEL", "SoleBase", "NeutralLandscapes", "JuDGE", "Transducers", "ConstrainedShortestPaths", "SMLMMetrics", "TensorGames", "SDeMo", "LibSndFile", "FlashAttentionWrapper", "RangeEnclosures", "FrechetDist", "BPGates", "RecurrenceAnalysis", "PlutoTeachingTools", "UnicodePlots", "ImplicitGlobalGrid", "SpatialEcology", "Bukdu", "GraphPPL", "ExtendableSparse", "PlutoStyles", "MonteCarloSummary", "LightBSON", "JupyterPlutoConverter", "BayesianLinearRegressors", "ReinforcementLearningTrajectories", "LaserTypes", "ConstraintDomains", "DifferentiableExpectations", "SunAsAStar", "MultiScaleTreeGraph", "PottsGumbelRBMLayers", "MAGEMin_C", "PlutoPlotly", "ShiftedProximalOperators", "StaticWebPages", "AbstractLogic", "Octavian", "ExplainableAI", "BaytesMCMC", "AutomotiveSimulator", "SPECTrecon", "PRASCapacityCredits", "TemporalGPs", "AbsSmoothFrankWolfe", "LinearMixingModels", "ImageFiltering", "StrategicGames", "SlidingDistancesBase", "BitSAD", "SciMLJacobianOperators", "PlantRayTracer", "UMAP", "BigO", "PowerModelsAnnex", "AbstractGPs", "CSDP", "CoordRefSystems", "ChowLiuTrees", "ComplexMixtures", "DistributionMeasures", "MLUtils", "WaterModels", "NeumannKelvin", "InventoryManagement", "MatrixProfile", "Santiago", "TimeseriesSurrogates", "GEMPIC", "ZarrDatasets", "FractalDimensions", "SlottedRandomAccess", "Stheno", "Mice", "FastTransforms", "EnergyModelsRenewableProducers", "PolynomialAmoebas", "JobSchedulers", "InfiniteOpt", "ElementaryFluxModes", "DifferentiableFrankWolfe", "RandomFeatureMaps", "VLBILikelihoods", "TransmuteDims", "RegressionDynamicCausalModeling", "TransferFunctions", "SeeToDee", "SymbolicUtils", "SimulationLogs", "Mango", "MTH229", "DACE", "OptimizationOptimisers", "GEOTRACES", "CTBase", "EwaldSummations", "DocstringAsImage", "GraphSignals", "FeynmanDiagram", "SignalTemporalLogic", "NASAPrecipitation", "TensorCast", "XCALibre", "MarkovChainHammer", "ReferenceFiniteElements", "KiteUtils", "SNOW", "AbstractCosmologicalEmulators", "GasPowerModels", "InfrastructureSystems", "TensorKitSectors", "FinEtools", "ApproxFunFourier", "Sensemakr", "SliceSampling", "VLBIImagePriors", "FourierTools", "Jadex", "ArDCA", "SignalAlignment", "TensorOperationsTBLIS", "EmpiricalPotentials", "EtherSPH", "OptimizationPRIMA", "ProfileView", "MultiData", "HuggingFaceDatasets", "SIMIlluminationPatterns", "FiniteElementContainers", "DynamicHMC", "NonconvexCore", "DecisionMakingPolicies", "MRFingerprintingRecon", "NonconvexSearch", "JOLI", "Gadfly", "PhysicalMeshes", "NonconvexSemidefinite", "NonconvexNLopt", "SpinGlassTensors", "Polynomials4ML", "DrugInteractions", "SMLMFrameConnection", "OptimizationNLopt", "GraphsOptim", "LowRankLayers", "FieldTracer", "AreaInterpolation", "TransitionsInTimeseries", "PassiveTracerFlows", "Zauner", "SUNRepresentations", "ThermodynamicIntegration", "PowerSystemCaseBuilder", "LinearRegressionKit", "PsychometricsBazaarBase", "GraphNets", "NonconvexMetaheuristics", "PhysicalFFT", "VisualRegressionTests", "DiscoDiff", "ConstraintExplorer", "SimpleBoundaryValueDiffEq", "ParallelAnalysis", "PhysicalFDM", "FusibleBroadcasts", "CaratheodoryFejerApprox", "CoordGridTransforms", "ConjugateComputationVI", "NonconvexMMA", "CategoryData", "NonconvexNOMAD", "MCMCDebugging", "JUDI", "RobustNeuralNetworks", "GaussianVariationalInference", "Wflow", "MPIMeasurements", "StartUpDG", "PALEOboxes", "Jabalizer", "UnderwaterAcoustics", "RecurrentLayers", "InvariantPointAttention", "OrdinaryDiffEqExtrapolation", "DynACof", "NonconvexPercival", "TaylorInversion", "TulipaEnergyModel", "GslibIO", "TimeSeriesClassification", "IESopt", "PyBraket", "UnROOT", "IterativeLQR", "GeoTables", "NDTensors", "Qaintmodels", "YaoPlots", "WordCloud", "TaylorDiff", "ParametricMCPs", "MarginalLogDensities", "RHEOS", "MeshIntegrals", "ElectronLiquid", "JetPack", "TuringBenchmarking", "OptimizationOptimJL", "QuantitativeSusceptibilityMappingTGV", "PALEOsediment", "ArviZPythonPlots", "ReinforcementLearning", "Gabs", "DIVAnd_HFRadar", "DerivableFunctions", "EnergySamplers", "DeconvOptim", "EquationsSolver", "BoundaryValueDiffEqMIRKN", "DrillHoles", "GeneralizedMonteCarlo", "DiffFusion", "SuperfluidRotSpec", "GridapTopOpt", "JsonGrinder", "UlamMethod", "ExponentialFamilyManifolds", "EvoLinear", "DifferentiableTrajectoryOptimization", "EvoDynamics", "FastMPOContractions", "ComputerAdaptiveTesting", "ConstrainedDynamicsVis", "BoundaryValueDiffEqAscher", "OptimizationFlux", "Swalbe", "ExpressionTreeForge", "GeoStatsBase", "ProbabilisticCircuits", "Dolo", "Bcube", "DirectTrajectoryOptimization", "SwitchOnSafety", "DistributedStwdLDA", "SurrogatesRandomForest", "ClosedLoopReachability", "PowerPlots", "QSFit", "GlobalSensitivity", "CountriesBorders", "SymbolicAnalysis", "MGVI", "PartiallySeparableNLPModels", "SourceCodeMcCormick", "SpinGlassNetworks", "GlobalApproximationValueIteration", "WaveOpticsPropagation", "ReinforcementLearningFarm", "GeoStatsModels", "ImageQuilting", "GenericCharacterTables", "DIVAnd", "Yao", "ReinforcementLearningCore", "TropicalYao", "JointEnergyModels", "Walrus", "ParametrisedConvexApproximators", "GeoStatsFunctions", "FluxTraining", "GeoEstimation", "ExponentialFamilyProjection", "BattMo", "Attractors", "YaoSubspaceArrayReg", "Omniscape", "TropicalNN", "Phonetics", "RvSpectML", "DynamicMovementPrimitives", "ObjectDetector", "DeepQLearning", "Tasmanian", "ReinforcementLearningZoo", "Images", "LogicCircuits", "Gogeta", "Eikonal", "BloqadeExpr", "FastBEAST", "ImageFeatures", "ColorSchemeTools", "GeometricalOptics", "GeoGrids", "SpaSM", "NonconvexJuniper", "MaxEntropyGraphs", "NonconvexIpopt", "DecomposingPolynomialSystems", "ImageTracking", "BloodFlowTrixi", "CompressedBeliefMDPs", "PALEOmodel", "HierarchicalEOM", "GeoStatsTransforms", "MultiStateSystems", "FractionalSystems", "StarFormationHistories", "ColBERT", "NonconvexPavito", "RvLineList", "PyGDatasets", "ODEProblemLibrary", "ImageUtils", "MatrixProductBP", "Fronts", "LocalAnisotropies", "vSmartMOM", "DynamicalSystems", "DiffusionGarnet", "PubChem", "ClimatePlots", "PRONTO", "BloqadeQMC", "LiquidElectrolytes", "GeoStats", "SolverBenchmark", "TensorQEC", "AstrodynamicalModels", "DataDrivenSparse", "MNPDynamics", "DataDrivenDMD", "OptimizationMOI", "ClapeyronHANNA", "GpABC", "ChargeTransport", "CitableImage", "BloqadeKrylov", "NetworkJumpProcesses", "ElectrochemicalKinetics", "GeometricFlux", "GeoMakie", "ChainPlots", "PortfolioAnalytics", "Fable", "CitablePhysicalText", "WGPUgfx", "Supernovae", "TaijaData", "Pesto", "InternalFluidFlow", "Psychrometrics", "PDMPFlux", "HetaSimulator", "Bactos", "NuclearToolkit", "OpenQuantumSystems", "ModiaPlot_CairoMakie", "MINDFulMakie", "StateSpacePartitions", "SimulatedNeuralMoments", "MixedComplementarityProblems", "SequentialSamplingModels", "NVMagnetometer", "FSimPlots", "QuanEstimationBase", "MAGEMinApp", "EditorsRepo", "BoxCox", "CropRootBox", "HmtGutenberg", "Collide", "NighttimeLights", "Biofilm", "GeoIO", "Microstructure", "DiskArrayEngine", "BaryPlots", "HmtArchive", "MiseEnPage", "RigorousInvariantMeasures", "SBMLToolkitTestSuite", "MathepiaModels", "TidierPlots", "BloqadeGates", "SwissVAMyKnife", "IonSim", "SMLMSim", "TaijaPlotting", "CalibrateEmulateSample", "NeuroAnalysis", "Chamber"], vs = ":release-1.11")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release Release management and versioning.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants