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

Semi-concrete IR interpreter #44803

Merged
merged 1 commit into from
Sep 1, 2022
Merged

Conversation

ianatol
Copy link
Member

@ianatol ianatol commented Mar 30, 2022

Original PR description:

Background

in #43852, the compiler learned how to make use of the codegen'd version of a function in order to speed up constant propagation by 1000x, assuming two conditions are fulfilled:

  1. All arguments are known to be constant at inference time

  2. The evaluation is legal according to appropriate effect conditions

This mechanism works well, but leaves some very sharp performance edges in inference. For example, adding an unused argument to an otherwise consteval-eligible function will fall back to inference-based constant propagation and thus incur the 1000x penalty (even though the argument is entirely unused).

This PR attempts to address this by adding a new middle-of-the-road fallback that sits between the super fast constant, concrete evaluation from #43852 and the original inference based constant propagation.

This PR

The core idea is to use inference's existing abstract interpretation lattice, but rather than performing abstract interpretation over untyped source, we perform it over the typed/optimized julia IR that the non-constant inference pass produced.

Now, this is not legal to do in general, but the :consistent and :terminates_globally effects from #43852, do ensure legality (in the currently implementation we additionally require :effect_free for consistency with consteval, but that could be easily relaxed).

Why is this a good idea

There are several benefits to performing abstract evaluation over optimized IR rather than untyped IR:

  1. We do not need to perform any method lookups and thus can also avoid inference's relatively complicated tracking of potential recursions. Method lookups were performed during the non-constant inference pass and the :termiantes_globally effect ensures the absence of recursion (at least when proven by the compiler - the property I documented for manual annotation is slightly too weak than what we need, so we may need to split out these effects).

  2. Optimized IR is likely to be smaller (in terms of total number of instructions that need to be visited for a given set of input arguments) because some optimizations/simplification/DCE have been performed.

  3. Optimized IR does not have any slots in it, so we avoid Very WIP: Refactor core inference loops to use less memory #43999-like problems around inference memory usage.

  4. The same optimized IR can be re-used many times for different sets of constants.

Threats to validity

Now, there are some challenges also. For one, it is not guaranteed that this will have the same precision as the inference-based constant propagation. I've done some testing here and precision is decent, but there are some cases where precision is worse than the inference-based constant propagation:

  1. In the current implementation, we never perform any method matching, instead relying on methods annotated in :invoke statements. This mostly works, but there are certain situations (e.g. the cases that optimizer: inline abstract union-split callsite #44512 is supposed to fix), where we currently cannot produce :invoke, even though inference was able to compute a full method match. My preferred solution to this is to extend the semantics of :invoke to always make it possible to generate an :invoke node when the full method match set is known (even if codegen does not make use of it). However, I haven't really seen this be much of a problem in my testing.

  2. There are certain branching patterns that would require the insertion of additional Pi nodes in order to avoid overapproximation of the lattice elements. This is one of the reasons that we currently don't do regular inference on SSA IR (the other being debuggability of lowered code). We've been thinking about some solutions to this, but this particular case is somewhat simpler than inference because 1) the branching patterns that inference can prove :consistent are limited anyway 2) regular inference may have already inserted the requisite PiNodes in which case there isn't a problem. In particular, in my testing I haven't actually seen any case of precision regressions due to this issue.

Benchmark results

The benchmarks for this are looking very attractive. On my ongoing inference torture test (https://gist.github.com/Keno/5587fbfe89bff96c863c8eeb1477defa), this gives an additional 2x improvement in inference time on top of the improvements already merged on master and those pending in #44447 and #44494. I should note that this is total inference time. By the nature of the benchmark, it basically performs inference and constant propagation once for each specialized call site. The 2x improvement here essentially comes down to the constant-propagation portion of that time dropping down to noise level.

The performance is even better on the real world benchmark that motivated https://gist.github.com/Keno/5587fbfe89bff96c863c8eeb1477defa. There constant propagation is performed multiple times with different constants for each non-constant inference, so the performance improvement is proportionally better, to the point where inference time is no longer dominating in that benchmark (down to about 30s from several hours in early January before all the recent compile-time perf improvements).

Current status

This passes tests for me locally, but I'm convinced that issues will show up during PkgEval. The re-use of the abstract interpreter pieces is also quite janky and should be factored better.

@ianatol
Copy link
Member Author

ianatol commented Mar 31, 2022

@nanosoldier runtests(["ADI", "AMLPipelineBase", "ANOVA", "ARules", "Agents", "AlgebraOfGraphics", "Arrow", "AutoMLPipeline", "BGEN", "BHAtp", "BallroomSkatingSystem", "BangBang", "BedgraphFiles", "BenchmarkConfigSweeps", "Binscatters", "BioFetch", "BipolarSphericalHarmonics", "BoltzmannMachinesPlots", "Bootstrap", "CMAEvolutionStrategy", "CSVReader", "Cassette", "ChainLadder", "CoinbasePro", "CombinatorialSpaces", "ConstraintSolver", "CovarianceMatrices", "CropRootBox", "CrystalInfoFramework", "Cthulhu", "DLMReader", "DPClustering", "Dagger", "DarkCurves", "DataFrameMacros", "DataFrameTools", "DataFramesMeta", "DataKnots", "DataSkimmer", "DecisionProgramming", "Diagonalizations", "DimensionalData", "Distances", "Diversity", "DrelTools", "DrillHoles", "EchelleCCFs", "EffectSizes", "Effects", "Equate", "FHIRClient", "FastAI", "Feather", "FeatureTransforms", "FeynmanDiagram", "FileTrees", "FinEtoolsFlexBeams", "FixedEffectModels", "FixedPointAcceleration", "FlowAtlas", "FlowWorkspace", "Folds", "FrameFun", "FunSQL", "Futbolista", "GBIF", "GLM", "GPLinearODEMaker", "GeoClustering", "GeoDatasets", "GeoLearning", "GeoStatsBase", "GlobalSearchRegression", "GlobalSensitivityAnalysis", "Graph500", "GraphDataFrameBridge", "GridapDistributed", "GroupedTemporalTerms", "GslibIO", "HITRAN", "Hadleyverse", "HighFrequencyCovariance", "HurdleDMR", "INMET", "ImageComponentAnalysis", "ImageGeoms", "InMemoryDatasets", "IncrementalPruning", "IndexedTables", "InformationGeometry", "InteractionWeightedDIDs", "InteractiveErrors", "IntervalTrees", "InvariantCausal", "IterTools", "JMcDM", "JSONLines", "JSONTables", "JWAS", "JlrsReflect", "JudiLing", "JuliaCon", "KCenters", "KeyedFrames", "LITS", "Lasso", "LazyGrids", "Legolas", "LegolasFlux", "LifeTable", "Lighthouse", "LinRegOutliers", "LocalAnisotropies", "LockandKeyLookups", "LoopVectorization", "LowLevelParticleFilters", "LsqFit", "MCMCChains", "MIPVerify", "MLJAbstractGPsGlue", "MLJEnsembles", "MLJLinearModels", "MLJModels", "MLJMultivariateStatsInterface", "MLJScientificTypes", "MatrixLMnet", "Meshes", "Metida", "MimiPAGE2020", "MixedModels", "MixedModelsExtras", "MixedModelsMakie", "MixedModelsPermutations", "MixedModelsSim", "ModelParameters", "Modia", "ModiaPlot_CairoMakie", "ModiaPlot_PyPlot", "ModiaResult", "MultiModalMuSig", "MusicManipulations", "MutualInformationImageRegistration", "NCBITaxonomy", "NNlib", "NaiveGAflux", "OMOPCommonDataModel", "ObservationDims", "Onda", "OndaEDF", "Optim", "OptimKit", "OrdinalGWAS", "OutlierDetection", "OutlierDetectionData", "OutlierDetectionNeighbors", "PNGFiles", "POMDPSimulators", "PackageCompiler", "ParameterSpacePartitions", "Persa", "PersistenceDiagramsBase", "Phylo", "PhyloNetworks", "PhyloPlots", "Pitchjx", "PkgUtility", "PlantBiophysics", "PlotMesh", "PlotlyBase", "PopGenCore", "PopGenSims", "PoreMatMod", "PorousMaterials", "PowerModelsAnnex", "PowerPlots", "PowerSimulations", "PowerSystems", "ProbabilisticCircuits", "ProgenyTestingTools", "ProgressiveHedging", "PyRhodium", "QuantumLattices", "QuantumTomography", "QuerySQLite", "Queryverse", "Qwind", "RData", "RDatasets", "RELOG", "ReadWriteDlm2", "Recommenders", "RegressionDiscontinuity", "RegressionTables", "Remark", "ReplicateBE", "ReportMetrics", "RigidBodyTools", "RipQP", "Ripserer", "RobustModels", "Run", "RvSpectMLPlots", "SQLite", "Santiago", "ScenTrees", "ScientificTypes", "ShapML", "Shapley", "SimpleChains", "SlackThreads", "SnoopCompile", "SolverBenchmark", "SortMark", "SpatialDependence", "SphericalHarmonicModes", "SpineBasedRecordLinkage", "SpmSpectroscopy", "StataDTAFiles", "StaticArrays", "StatsModels", "StochasticIntegrals", "Stonks", "Strapping", "StructArrays", "SugarKelp", "SunAsAStar", "SyntheticDatasets", "SystemBenchmark", "TMLE", "TableOperations", "TextAnalysis", "TidyStanza", "TimeSeries", "Tracking", "Transducers", "TypedTables", "UncertaintyQuantification", "UnitfulAssets", "UpROOT", "VectorSphericalHarmonics", "VisualSearchACTR", "WRDSMerger", "WiSER", "Wordlegames", "XLSX", "YAAD"], vs = ":master")

@nanosoldier
Copy link
Collaborator

Something went wrong when running your job:

NanosoldierError: failed to run tests: Build for julia on x86_64-linux-gnu did not complete successfully

Logs and partial data can be found here
cc @maleadt

@aviatesk
Copy link
Sponsor Member

@nanosoldier runtests(["ADI", "AMLPipelineBase", "ANOVA", "ARules", "Agents", "AlgebraOfGraphics", "Arrow", "AutoMLPipeline", "BGEN", "BHAtp", "BallroomSkatingSystem", "BangBang", "BedgraphFiles", "BenchmarkConfigSweeps", "Binscatters", "BioFetch", "BipolarSphericalHarmonics", "BoltzmannMachinesPlots", "Bootstrap", "CMAEvolutionStrategy", "CSVReader", "Cassette", "ChainLadder", "CoinbasePro", "CombinatorialSpaces", "ConstraintSolver", "CovarianceMatrices", "CropRootBox", "CrystalInfoFramework", "Cthulhu", "DLMReader", "DPClustering", "Dagger", "DarkCurves", "DataFrameMacros", "DataFrameTools", "DataFramesMeta", "DataKnots", "DataSkimmer", "DecisionProgramming", "Diagonalizations", "DimensionalData", "Distances", "Diversity", "DrelTools", "DrillHoles", "EchelleCCFs", "EffectSizes", "Effects", "Equate", "FHIRClient", "FastAI", "Feather", "FeatureTransforms", "FeynmanDiagram", "FileTrees", "FinEtoolsFlexBeams", "FixedEffectModels", "FixedPointAcceleration", "FlowAtlas", "FlowWorkspace", "Folds", "FrameFun", "FunSQL", "Futbolista", "GBIF", "GLM", "GPLinearODEMaker", "GeoClustering", "GeoDatasets", "GeoLearning", "GeoStatsBase", "GlobalSearchRegression", "GlobalSensitivityAnalysis", "Graph500", "GraphDataFrameBridge", "GridapDistributed", "GroupedTemporalTerms", "GslibIO", "HITRAN", "Hadleyverse", "HighFrequencyCovariance", "HurdleDMR", "INMET", "ImageComponentAnalysis", "ImageGeoms", "InMemoryDatasets", "IncrementalPruning", "IndexedTables", "InformationGeometry", "InteractionWeightedDIDs", "InteractiveErrors", "IntervalTrees", "InvariantCausal", "IterTools", "JMcDM", "JSONLines", "JSONTables", "JWAS", "JlrsReflect", "JudiLing", "JuliaCon", "KCenters", "KeyedFrames", "LITS", "Lasso", "LazyGrids", "Legolas", "LegolasFlux", "LifeTable", "Lighthouse", "LinRegOutliers", "LocalAnisotropies", "LockandKeyLookups", "LoopVectorization", "LowLevelParticleFilters", "LsqFit", "MCMCChains", "MIPVerify", "MLJAbstractGPsGlue", "MLJEnsembles", "MLJLinearModels", "MLJModels", "MLJMultivariateStatsInterface", "MLJScientificTypes", "MatrixLMnet", "Meshes", "Metida", "MimiPAGE2020", "MixedModels", "MixedModelsExtras", "MixedModelsMakie", "MixedModelsPermutations", "MixedModelsSim", "ModelParameters", "Modia", "ModiaPlot_CairoMakie", "ModiaPlot_PyPlot", "ModiaResult", "MultiModalMuSig", "MusicManipulations", "MutualInformationImageRegistration", "NCBITaxonomy", "NNlib", "NaiveGAflux", "OMOPCommonDataModel", "ObservationDims", "Onda", "OndaEDF", "Optim", "OptimKit", "OrdinalGWAS", "OutlierDetection", "OutlierDetectionData", "OutlierDetectionNeighbors", "PNGFiles", "POMDPSimulators", "PackageCompiler", "ParameterSpacePartitions", "Persa", "PersistenceDiagramsBase", "Phylo", "PhyloNetworks", "PhyloPlots", "Pitchjx", "PkgUtility", "PlantBiophysics", "PlotMesh", "PlotlyBase", "PopGenCore", "PopGenSims", "PoreMatMod", "PorousMaterials", "PowerModelsAnnex", "PowerPlots", "PowerSimulations", "PowerSystems", "ProbabilisticCircuits", "ProgenyTestingTools", "ProgressiveHedging", "PyRhodium", "QuantumLattices", "QuantumTomography", "QuerySQLite", "Queryverse", "Qwind", "RData", "RDatasets", "RELOG", "ReadWriteDlm2", "Recommenders", "RegressionDiscontinuity", "RegressionTables", "Remark", "ReplicateBE", "ReportMetrics", "RigidBodyTools", "RipQP", "Ripserer", "RobustModels", "Run", "RvSpectMLPlots", "SQLite", "Santiago", "ScenTrees", "ScientificTypes", "ShapML", "Shapley", "SimpleChains", "SlackThreads", "SnoopCompile", "SolverBenchmark", "SortMark", "SpatialDependence", "SphericalHarmonicModes", "SpineBasedRecordLinkage", "SpmSpectroscopy", "StataDTAFiles", "StaticArrays", "StatsModels", "StochasticIntegrals", "Stonks", "Strapping", "StructArrays", "SugarKelp", "SunAsAStar", "SyntheticDatasets", "SystemBenchmark", "TMLE", "TableOperations", "TextAnalysis", "TidyStanza", "TimeSeries", "Tracking", "Transducers", "TypedTables", "UncertaintyQuantification", "UnitfulAssets", "UpROOT", "VectorSphericalHarmonics", "VisualSearchACTR", "WRDSMerger", "WiSER", "Wordlegames", "XLSX", "YAAD"], vs = ":master")

@nanosoldier
Copy link
Collaborator

Something went wrong when running your job:

NanosoldierError: failed to run tests: Build for julia on x86_64-linux-gnu did not complete successfully

Logs and partial data can be found here
cc @maleadt

@maleadt
Copy link
Member

maleadt commented Mar 31, 2022

The build failed -- re-requesting PkgEval won't fix that.

unknown function (ip: 0x7ff09679396c)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff09678cea5)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff096789d0d)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff096788b77)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff0967c28ce)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff0967bfc12)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff0967b372e)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff0967a7a8e)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff0967a3a3c)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff0967a259e)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff09679951a)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff096796032)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff09679396c)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff09678cea5)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff096789d0d)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff096788b77)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff09676c07c)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff09675f597)
jl_toplevel_eval_flex at /workspace/srcdir/src/toplevel.c:900
jl_parse_eval_all at /workspace/srcdir/src/toplevel.c:1043
ijl_load_ at /workspace/srcdir/src/toplevel.c:1090
unknown function (ip: 0x7ff09672e61d)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
unknown function (ip: 0x7ff09672e564)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
jl_apply at /workspace/srcdir/src/julia.h:1830 [inlined]
do_call at /workspace/srcdir/src/interpreter.c:126
eval_value at /workspace/srcdir/src/interpreter.c:215
eval_stmt_value at /workspace/srcdir/src/interpreter.c:166 [inlined]
eval_body at /workspace/srcdir/src/interpreter.c:612
jl_interpret_toplevel_thunk at /workspace/srcdir/src/interpreter.c:750
top-level scope at compiler/compiler.jl:161
jl_toplevel_eval_flex at /workspace/srcdir/src/toplevel.c:909
jl_eval_module_expr at /workspace/srcdir/src/toplevel.c:203 [inlined]
jl_toplevel_eval_flex at /workspace/srcdir/src/toplevel.c:712
ijl_toplevel_eval_in at /workspace/srcdir/src/toplevel.c:968
unknown function (ip: 0x7ff09672da0d)
_jl_invoke at /workspace/srcdir/src/gf.c:2367 [inlined]
ijl_apply_generic at /workspace/srcdir/src/gf.c:2549
jl_apply at /workspace/srcdir/src/julia.h:1830 [inlined]
do_call at /workspace/srcdir/src/interpreter.c:126
eval_value at /workspace/srcdir/src/interpreter.c:215
eval_stmt_value at /workspace/srcdir/src/interpreter.c:166 [inlined]
eval_body at /workspace/srcdir/src/interpreter.c:612
jl_interpret_toplevel_thunk at /workspace/srcdir/src/interpreter.c:750
top-level scope at compiler/compiler.jl:3
jl_toplevel_eval_flex at /workspace/srcdir/src/toplevel.c:909
jl_parse_eval_all at /workspace/srcdir/src/toplevel.c:1043
ijl_load_ at /workspace/srcdir/src/toplevel.c:1090
ijl_load at /workspace/srcdir/src/toplevel.c:1103
exec_program at /workspace/srcdir/src/jlapi.c:517
true_main at /workspace/srcdir/src/jlapi.c:570
jl_repl_entrypoint at /workspace/srcdir/src/jlapi.c:702
main at /workspace/srcdir/cli/loader_exe.c:59
__libc_start_main at /workspace/srcdir/glibc-2.29/csu/../csu/libc-start.c:308
unknown function (ip: 0x400808)


make[1]: *** [sysimage.mk:61: /workspace/srcdir/usr/lib/julia/corecompiler.ji] Error 1
make[1]: Leaving directory '/workspace/srcdir'
make: *** [Makefile:82: julia-sysimg-ji] Error 2
Previous command exited with 2

@ianatol
Copy link
Member Author

ianatol commented Mar 31, 2022

Ah yeah, glanced at it late last night and thought it might've been a CI thing so asked Shuhei to re-run. Thanks for the logs

@ianatol ianatol force-pushed the kf/semiconcreteeval branch 2 times, most recently from 9576635 to 96e4731 Compare April 5, 2022 01:57
@aviatesk aviatesk self-requested a review April 5, 2022 02:44
@aviatesk aviatesk force-pushed the kf/semiconcreteeval branch 2 times, most recently from 0f669e2 to 53cc7cd Compare April 6, 2022 07:44
@aviatesk
Copy link
Sponsor Member

aviatesk commented Apr 7, 2022

The failing test case will be fixed by #44896.

@ianatol
Copy link
Member Author

ianatol commented Apr 7, 2022

@nanosoldier runtests(ALL, vs = ":master")

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

@ianatol
Copy link
Member Author

ianatol commented Apr 7, 2022

Let's do a re-run of failed tests to double check for real ones:

@nanosoldier runtests(["BGEN", "BackgroundSubtraction", "BayesianQuadrature", "Cassette", "CombinatorialSpaces", "DeepQLearning", "DelayDiffEq", "DimensionalData", "Distances", "EffectSizes", "ElasticArrays", "Evolutionary", "FluxTraining", "ForestBiometrics", "FunctionWrappers", "GaussianMixtureAlignment", "GigaSOM", "GridapDistributed", "ImageGeoms", "IterTools", "LokiLogger", "LoopVectorization", "LsqFit", "MLJMultivariateStatsInterface", "MatrixLMnet", "MinimallyDisruptiveCurves", "MixedModelsExtras", "Modia", "MutualInformationImageRegistration", "NaiveGAflux", "NiLang", "Optim", "PNGFiles", "QSimulator", "QuadEig", "QuantumLattices", "Quiqbox", "Reactive", "RigidBodyTools", "SimpleChains", "SlackThreads", "SnoopCompile", "SphericalHarmonicModes", "StochasticDelayDiffEq", "Sundials", "TableOperations", "TypedTables", "WavePropBase"], vs = ":master")

@ianatol
Copy link
Member Author

ianatol commented Apr 8, 2022

Not definitive, but just wanted to make this list of test failures that look real at first glance

Inference accuracy regressions:
IterTools
DimensionalData
TypedTables

Allocation regressions:
SimpleChains
MutualInformationImageRegistration

Possibly need upstream changes:
Cassette
SnoopCompile
SlackThreads (This seems to need JET.jl upstream change to account for ret::CallMeta here)

Other:
FunctionWrappers (error message is clearly related to internals)

The unreachable instruction ones are also real as they turned up in the PkgEval on the original PR, but hopefully are all from the same issue...

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

@aviatesk
Copy link
Sponsor Member

@nanosoldier runtests(["BGEN", "BackgroundSubtraction", "BayesianQuadrature", "Cassette", "CombinatorialSpaces", "DeepQLearning", "DelayDiffEq", "DimensionalData", "Distances", "EffectSizes", "ElasticArrays", "Evolutionary", "FluxTraining", "ForestBiometrics", "FunctionWrappers", "GaussianMixtureAlignment", "GigaSOM", "GridapDistributed", "ImageGeoms", "IterTools", "LokiLogger", "LoopVectorization", "LsqFit", "MLJMultivariateStatsInterface", "MatrixLMnet", "MinimallyDisruptiveCurves", "MixedModelsExtras", "Modia", "MutualInformationImageRegistration", "NaiveGAflux", "NiLang", "Optim", "PNGFiles", "QSimulator", "QuadEig", "QuantumLattices", "Quiqbox", "Reactive", "RigidBodyTools", "SimpleChains", "SlackThreads", "SnoopCompile", "SphericalHarmonicModes", "StochasticDelayDiffEq", "Sundials", "TableOperations", "TypedTables", "WavePropBase"], vs = ":master")

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

@ianatol
Copy link
Member Author

ianatol commented Apr 28, 2022

This will fail some abstract unionsplit tests due to 4874755

@ianatol
Copy link
Member Author

ianatol commented Apr 28, 2022

@nanosoldier runtests(["BGEN", "BackgroundSubtraction", "BayesianQuadrature", "Cassette", "CombinatorialSpaces", "DeepQLearning", "DelayDiffEq", "DimensionalData", "Distances", "EffectSizes", "ElasticArrays", "Evolutionary", "FluxTraining", "ForestBiometrics", "FunctionWrappers", "GaussianMixtureAlignment", "GigaSOM", "GridapDistributed", "ImageGeoms", "IterTools", "LokiLogger", "LoopVectorization", "LsqFit", "MLJMultivariateStatsInterface", "MatrixLMnet", "MinimallyDisruptiveCurves", "MixedModelsExtras", "Modia", "MutualInformationImageRegistration", "NaiveGAflux", "NiLang", "Optim", "PNGFiles", "QSimulator", "QuadEig", "QuantumLattices", "Quiqbox", "Reactive", "RigidBodyTools", "SimpleChains", "SlackThreads", "SnoopCompile", "SphericalHarmonicModes", "StochasticDelayDiffEq", "Sundials", "TableOperations", "TypedTables", "WavePropBase"], vs = ":master")

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

@aviatesk aviatesk added the compiler:inference Type inference label Aug 31, 2022
test/compiler/inference.jl Outdated Show resolved Hide resolved
test/compiler/inference.jl Outdated Show resolved Hide resolved
test/compiler/inference.jl Outdated Show resolved Hide resolved
base/essentials.jl Outdated Show resolved Hide resolved
base/compiler/utilities.jl Outdated Show resolved Hide resolved
base/compiler/typeinfer.jl Show resolved Hide resolved
base/compiler/tfuncs.jl Outdated Show resolved Hide resolved
base/compiler/stmtinfo.jl Show resolved Hide resolved
base/compiler/inferencestate.jl Outdated Show resolved Hide resolved
if isa(linfo, InferenceResult)
ecache = get(interp.cache, linfo, nothing)
elseif isa(linfo, SemiConcreteResult)
ecache = get(interp.cache, linfo, nothing)
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

This never returns cache (as interp.cache is IdDict{InferenceResult,EscapeCache} object). We should tweak callsites of get_escape_cache instead.

base/compiler/ssair/inlining.jl Outdated Show resolved Hide resolved
base/compiler/ssair/inlining.jl Outdated Show resolved Hide resolved
base/compiler/ssair/inlining.jl Outdated Show resolved Hide resolved
base/compiler/abstractinterpretation.jl Outdated Show resolved Hide resolved
base/compiler/abstractinterpretation.jl Outdated Show resolved Hide resolved
base/compiler/abstractinterpretation.jl Outdated Show resolved Hide resolved
base/compiler/abstractinterpretation.jl Outdated Show resolved Hide resolved
base/compiler/abstractinterpretation.jl Show resolved Hide resolved
base/compiler/abstractinterpretation.jl Outdated Show resolved Hide resolved
@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

ir = codeinst_to_ir(interp, code)
if isa(ir, IRCode)
T = ir_abstract_constant_propagation(interp, mi_cache, sv, mi, ir, arginfo.argtypes)
if !isa(T, Type) || typeintersect(T, Bool) === Union{}
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Why do we want to have this check?

base/compiler/abstractinterpretation.jl Show resolved Hide resolved
base/compiler/abstractinterpretation.jl Outdated Show resolved Hide resolved
base/compiler/inferenceresult.jl Show resolved Hide resolved
base/compiler/ssair/irinterp.jl Outdated Show resolved Hide resolved
base/compiler/ssair/irinterp.jl Outdated Show resolved Hide resolved
base/compiler/ssair/irinterp.jl Outdated Show resolved Hide resolved
base/compiler/ssair/irinterp.jl Outdated Show resolved Hide resolved
base/compiler/ssair/irinterp.jl Outdated Show resolved Hide resolved
base/compiler/ssair/irinterp.jl Outdated Show resolved Hide resolved
base/compiler/ssair/irinterp.jl Outdated Show resolved Hide resolved
Comment on lines +186 to +189
# All other effects already guaranteed effect free by construction
if is_nothrow(effects)
ir.stmts[idx][:flag] |= IR_FLAG_EFFECT_FREE
end
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Why do we want to handle this here rather than letting the optimizer to annotate this as like the regular absint->optimization chain?

Copy link
Member

Choose a reason for hiding this comment

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

I'd just like to generally move towards inference annotating this information if it has it. We're already doing all the analysis, so doing it over again in the optimizer is wasteful. That said, this branch is dead anyway, since we're currently requiring nothrow, but I'll plan to address that after merge.

@aviatesk
Copy link
Sponsor Member

aviatesk commented Aug 31, 2022

2. There are certain branching patterns that would require the insertion of additional Pi nodes in order to avoid overapproximation of the lattice elements. This is one of the reasons that we currently don't do regular inference on SSA IR (the other being debuggability of lowered code). We've been thinking about some solutions to this, but this particular case is somewhat simpler than inference because 1) the branching patterns that inference can prove :consistent are limited anyway 2) regular inference may have already inserted the requisite PiNodes in which case there isn't a problem. In particular, in my testing I haven't actually seen any case of precision regressions due to this issue.

Is this still a consideration? I'm still not sure why abstract interpretation on IRCode faces this problem -- AFAIU if we obtain a type constraint on a variable (e.g. from isa branch), we may generate PiNode at the start of optimization and replace all the usages of the variable in that branch with that PiNode. Then I think we can successfully reason about that constrained type of the variable if we just look at the type of the PiNode. Am I missing something?

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 31, 2022

if we obtain a type constraint on a variable (e.g. from isa branch), we may generate PiNode at the start of optimization and replace all the usages of the variable in that branch with that PiNode. Then I think we can successfully reason about that constrained type of the variable if we just look at the type of the PiNode.

We would lose the ability to further constrain and refine the value further, since we don't allow SSAValues to be used in in the Conditional type. But as Ian mentioned, it is somewhat unlikely we would consider the program to be consistent if it needed further Conditional type splitting.

@ianatol ianatol force-pushed the kf/semiconcreteeval branch 2 times, most recently from bdd0d25 to 4382c9b Compare August 31, 2022 17:56
@ianatol
Copy link
Member Author

ianatol commented Aug 31, 2022

@nanosoldier runtests(["Accessors", "CSVReader", "CUTEst", "CairoMakie", "ComplexPhasePortrait", "CountdownNumbers", "FlameGraphs", "Folds", "GalaxyBrain", "MeshViz", "MolecularGraph", "MzPlots", "Pidfile", "PlantGeom", "ProfileView", "RetroCap", "SpmGrids", "StrBase", "TopOptMakie"], vs = ":master")

@nanosoldier runbenchmarks(!"scalar", vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

@ianatol
Copy link
Member Author

ianatol commented Sep 1, 2022

@nanosoldier runbenchmarks("broadcast", vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

Copy link
Member

@Keno Keno left a comment

Choose a reason for hiding this comment

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

Alright, let's get this in. There some follow-up cleanup that I have to do, but let's get this in first.

@ianatol ianatol added the merge me PR is reviewed. Merge when all tests are passing label Sep 1, 2022
@Keno Keno merged commit aa20b32 into JuliaLang:master Sep 1, 2022
@ianatol ianatol removed the merge me PR is reviewed. Merge when all tests are passing label Sep 2, 2022
@ianatol ianatol deleted the kf/semiconcreteeval branch September 2, 2022 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants