checktag's permissive fallback silently disables tag checking (e.g. for derivative(f!, y, x, cfg))
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 50/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Área
- tooling
Línea de trabajo
Comienza con los métodos checktag y los sitios de llamada de derivative/derivative!, y luego compara su comportamiento con la ruta InvalidTagException de gradient. Se considera terminado cuando una DerivativeConfig para la función incorrecta se rechaza en las llamadas escalares a derivative, y se tienen en cuenta el comportamiento de nothing documentado y el de las etiquetas personalizadas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
A DerivativeConfig built for one function is silently accepted by another, so derivative(f!, y, x, cfg) gets no perturbation confusion protection at all:
julia> a!(y, x) = (y .= sin(x)); b!(y, x) = (y .= cos(x));
julia> y = Vector{Float64}(undef, 2);
julia> cfg = ForwardDiff.DerivativeConfig(a!, y, 0.0);
julia> ForwardDiff.derivative(b!, y, 0.0, cfg) # cfg belongs to a!, no complaint
2-element Vector{Float64}:
-0.0
-0.0
gradient does raise InvalidTagException in the analogous situation. This reproduces with a real y on master, so it is unrelated to complex support.
The immediate cause is that every non-fallback checktag method requires x::AbstractArray:
checktag(::Type{Tag{FT,VT}}, f::F, x::AbstractArray{V}) where {FT,VT,F,V} = throw(InvalidTagException{...}())
checktag(::Type{Tag{F,V}}, f::F, x::AbstractArray{V}) where {F,V} = true
while derivative/derivative! call checktag(T, f!, x) with a scalar x. Dispatch lands on the catch-all checktag(z, f, x) = true, so the check argument of derivative(f!, y, x, cfg, Val{true}()) has no effect.
Adding scalar counterparts of those two methods fixes this particular case, but the more interesting question is whether the permissive checktag(z, f, x) = true default should stay. As it stands, any signature that does not match a specific method silently opts out of checking, which is how this gap went unnoticed -- the failure mode is "no error", not "no method". Defaulting to rejection and explicitly accepting only validated tags would make such gaps loud instead of silent.
Two things to note for anyone attempting that:
- The return value is currently discarded -- every call site is
CHK && checktag(...), andchecktagworks purely by throwing. So flipping the default tofalseon its own changes nothing; the call sites would have to throw on afalseresult. Nothingneeds to be accepted explicitly, since anothingtag is documented as usable with any target function. Custom tag types currently pass via the same fallback ("custom tag: you're on your own"), so rejecting by default would be breaking for them unless they opt in by definingchecktagfor their tag type -- arguably the point, but worth a deprecation path.
- Lenguaje dominante
- Julia
- Estrellas
- 1k
- Forks
- 162
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de JuliaDiff/ForwardDiff.jl
-
missing floatmin, floatmax, and issubnormal for DualPosiblemente ocupada @devmotion la tomó hace 15 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
JuliaDiff/ForwardDiff.jl#852 · 6 comentarios ·
-
`fma` and `muladd` ignore NaN-safe modePosiblemente ocupada @devmotion la tomó hace 1 día. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
JuliaDiff/ForwardDiff.jl#860 ·
-
Enable NaN-safe mode by defaultPosiblemente ocupada @devmotion la tomó hace 3 días. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
JuliaDiff/ForwardDiff.jl#857 · 1 reacción ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
JuliaDiff/ForwardDiff.jl#854 · 1 comentario ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 75/100
JuliaDiff/ForwardDiff.jl#849 ·
Todos los issues de JuliaDiff/ForwardDiff.jl
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
JuliaGPU/KernelAbstractions.jl#897 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
oscar-system/GAP.jl#1455 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
JuliaAI/MLJTransforms.jl#85 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
SciML/OrdinaryDiffEq.jl#4875 ·
Los mantenedores suelen responder en 4 días