pullback drops cotangents when f repeats a variable or contains wrt, breaking pushforward
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
The bug is in pullback in pytensor/gradient.py, which keeps one cotangent per repeated variable and lets output cotangents override gradients from other outputs; pushforward in the same module depends on it. Start by running the reproduction snippets in the issue and checking which inputs explicit_graph_inputs returns. Done means all three pushforward cases return both tangents and the pullback cases return every cotangent, without breaking existing gradient tests.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
pytensor.gradient.pushforward drops tangents through Add and Sub, so the directional derivative of a + b depends on only one of the two tangents. The cause is pullback, which keeps only one cotangent per variable when f repeats a variable. It also lets the cotangent of a variable in f override the gradient reaching it through the other outputs. The default pushforward pulls back through a first pullback whose outputs for Add are the output cotangent itself, so it hits both cases.
import pytensor.tensor as pt
from pytensor.gradient import pullback, pushforward
from pytensor.graph.traversal import explicit_graph_inputs
x = pt.dscalar("x")
y_bar_1 = pt.dscalar("y_bar_1")
y_bar_2 = pt.dscalar("y_bar_2")
y = x**2
list(explicit_graph_inputs(pullback([y, y], x, [y_bar_1, y_bar_2]))) # [x, y_bar_2], expected [x, y_bar_1, y_bar_2]
list(explicit_graph_inputs(pullback([x, 2 * x], x, [y_bar_1, y_bar_2]))) # [y_bar_1], expected [y_bar_1, y_bar_2]
a = pt.dscalar("a")
b = pt.dscalar("b")
a_dot = pt.dscalar("a_dot")
b_dot = pt.dscalar("b_dot")
list(explicit_graph_inputs(pushforward(a + b, [a, b], [a_dot, b_dot]))) # [b_dot], expected [a_dot, b_dot]
list(explicit_graph_inputs(pushforward(a - b, [a, b], [a_dot, b_dot]))) # [a_dot], expected [a_dot, b_dot]
list(explicit_graph_inputs(pushforward(a + 2 * b, [a, b], [a_dot, b_dot]))) # [a_dot], expected [a_dot, b_dot]
This came up while computing sparse Jacobians from colored pushforwards for #2578.
- Lenguaje dominante
- Python
- Estrellas
- 654
- Forks
- 258
- Merge medio
- 3 d 41 min
- PR fusionados (30 d)
- 42
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
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 pymc-devs/pytensor
-
Docs of mode still mentions C/CVM as the default with FAST_RUNPosiblemente ocupada @ADITYASINGH1206 la tomó hace 8 días. Abiertodocs
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
pymc-devs/pytensor#2641 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Update conditions page in docsAbiertodocs
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
BUG: geomspace returns wrong sign for the endpoints when start and stop are negativePosiblemente ocupada @mayuriphad la tomó hace 27 días. Abierto
Dificultad 2/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Reciprocal.impl computes np.float32(1.0) / x: float32 precision for float64 scalars under NEP 50 (Python linker)Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
pymc-devs/pytensor#2430 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pymc-devs/pytensor#2428 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de pymc-devs/pytensor
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
dgunning/edgartools#2019 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
topoteretes/cognee#6818 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
source_verification_agent: no outcome when the publisher confirms a work but its DOI resolves to a different recordPosiblemente ocupada @pinjun99 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Imbad0202/academic-research-skills#1159 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Bug]: DoubleMLData.from_arrays checks the treatment d with force_all_x_finite instead of force_all_d_finitePosiblemente ocupada @leninworld la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
DoubleML/doubleml-for-py#471 ·
Los mantenedores suelen responder en 1 día