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

Subtype: avoid false alarm caused by eager forall_exists_subtype. #48441

Merged
merged 3 commits into from
Feb 2, 2023

Conversation

N5N3
Copy link
Member

@N5N3 N5N3 commented Jan 28, 2023

Nested forall_exists_subtype always earse the remaining Runion, which should not be ignored if the tailling subtype fails.
This PR tries to keep the Runion if the local subtyping has moderate scale.
close #40865.

Note: this PR is based on #48410. The first commit is a squashed version.

@N5N3 N5N3 added types and dispatch Types, subtyping and method dispatch bugfix This change fixes an existing bug labels Jan 28, 2023
@N5N3

This comment was marked as outdated.

@nanosoldier

This comment was marked as outdated.

@N5N3
Copy link
Member Author

N5N3 commented Jan 30, 2023

@nanosoldier runtests(["GAlgebra", "BenchmarkProfiles", "NonlinearSolve", "TensND", "MathML", "StructuralIdentifiability", "NonconvexIpopt", "DifferentiableTrajectoryOptimization", "SIAN", "MomentClosure", "ModelOrderReduction", "BoundaryValueDiffEq", "CellMLToolkit", "PotentialFlow", "PETLION", "Plots", "DifferentiableStateSpaceModels", "ParameterizedFunctions", "MTH229", "AstroChemistry", "OptimizationMOI", "MPIClusterManagers", "Percival", "HighDimPDE", "JSOSolvers", "ODEProblemLibrary", "Quaternionic", "DataDrivenSparse", "ReversePropagation", "Causal", "QuadraticModels", "BSeries", "JumpProblemLibrary", "EasyModelAnalysis", "BlockSystems", "DelaySSAToolkit", "LSODA", "RigorousInvariantMeasures", "DataDrivenSR", "Silico", "SpinWaveTheory", "LicenseGrabber", "NonconvexPavito", "EquationsSolver", "DickeModel", "PostNewtonian", "AlgebraicPetri", "RootedTrees", "SphericalFunctions", "OptimizationOptimJL", "VoronoiFVM", "DirectTrajectoryOptimization", "SolverBenchmark", "NonconvexJuniper", "UncertaintyQuantification", "Stopping", "Sundials", "NLPModelsIpopt", "SolverTools", "ControlSystemsMTK", "DiffEqProblemLibrary", "DECAES", "GeometricIntegrators", "ClimaAtmos", "DataDrivenDMD", "NablaNet", "GasChem", "LegendrePolynomials", "VoronoiFVMDiffEq", "MathOptSymbolicAD", "ODE", "NestedEnvironments", "PreallocationTools", "DataInterpolations", "ODEConvergenceTester", "DerivableFunctions", "PairPlots", "SparseDiffTools", "GeometricEquations", "DiffEqCallbacks", "DCISolver", "DerivableFunctionsBase", "SolverTest", "SBML", "PartiallySeparableNLPModels", "SDEProblemLibrary", "Evolutionary", "Pluto", "SymPy", "NumericalMethodsforEngineers", "QuantumLattices", "ExpressionTreeForge", "FundamentalsNumericalComputation", "Sophon", "TKTDsimulations", "FractionalCalculus", "SummationByPartsOperators", "DataDrivenDiffEq", "ODEInterfaceDiffEq", "SideKicks", "DelayDiffEq", "StochasticDelayDiffEq", "CaNNOLeS", "ExactODEReduction", "SteadyStateDiffEq", "IRKGaussLegendre", "GeneralizedMonteCarlo", "IterativeLQR", "Collide", "Nonconvex", "Optimization", "FletcherPenaltySolver", "RRTMGP", "SolverCore", "CropRootBox", "JosephsonCircuits", "ExactDiagonalization", "ProbNumDiffEq", "NeuronBuilder", "FiniteStateProjection", "PolynomialGTM", "ReactionNetworkImporters", "ReliabilityOptimization", "DiffEqNoiseProcess", "TableTransforms", "DataDrivenLux", "Mehrotra", "ReachabilityAnalysis"])

@nanosoldier
Copy link
Collaborator

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

@N5N3
Copy link
Member Author

N5N3 commented Jan 30, 2023

PkgEval looks good this time.

src/subtype.c Outdated Show resolved Hide resolved
If `Runion.more != 0` we‘d better not erase the local `Runion` as we need it if the subtyping fails after.

This commit replaces `forall_exists_subtype` with a local version.
It first tries `forall_exists_subtype` and estimates the "problem scale".
If subtyping fails and the scale looks small then it switches to the slow path.

TODO: At present, the "problem scale" only counts the number of checked `Lunion`s.
But perhaps we need a more accurate result (e.g. sum of `Runion.depth`)

Update subtype.c

Update subtype.c
Make sure we don't forget the bound in `env`.
(And we can fuse `local_forall_exists_subtype`)
@N5N3 N5N3 merged commit 96acd4d into JuliaLang:master Feb 2, 2023
@N5N3 N5N3 deleted the forall_tuning branch February 2, 2023 03:41
@staticfloat
Copy link
Member

This appears to have caused a significant loadtime regression in CUDA. X-ref: #48582

@KristofferC KristofferC added the backport 1.9 Change should be backported to release-1.9 label Mar 14, 2023
@N5N3 N5N3 mentioned this pull request Mar 15, 2023
N5N3 added a commit to N5N3/julia that referenced this pull request Mar 17, 2023
…uliaLang#48441)

* Avoid earsing `Runion` within nested `forall_exists_subtype`

If `Runion.more != 0` we‘d better not erase the local `Runion` as we need it if the subtyping fails after.

This commit replaces `forall_exists_subtype` with a local version.
It first tries `forall_exists_subtype` and estimates the "problem scale".
If subtyping fails and the scale looks small then it switches to the slow path.

TODO: At present, the "problem scale" only counts the number of checked `Lunion`s.
But perhaps we need a more accurate result (e.g. sum of `Runion.depth`)

* Change the reversed subtyping into a local check.

Make sure we don't forget the bound in `env`.
(And we can fuse `local_forall_exists_subtype`)

* Optimization for non-union invariant parameter.
@KristofferC KristofferC mentioned this pull request Mar 24, 2023
52 tasks
@KristofferC KristofferC removed the backport 1.9 Change should be backported to release-1.9 label Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

subtype error with KV<:Union{K,Ref{K}} alternate constraint
5 participants