0xMiden / 0xMiden/air-script

Randomize checking of each optimization pass

Abierto
#475 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
96
Forks
39
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

With each optimization pass, we are running the risk that our transformations might have a bug that would lead to an invalid set of constraints.

As an extra precautionary measure, we should try to check that each successive pass ensures the correctness of the transformation. I *think* we could implement this as an internal check in each pass.

The idea is to again use randomized polynomial identity testing. Given a list of expressions $f_1, \ldots, f_n$, which get transformed into $g_1, \ldots, g_n$, we should make sure that $f_i(r) = g_i(r)$ for some randomly sampled $r$ from a large enough field (`QuadFelt` seems the safest, although we can repeat the test with multiple random `Felt`).

This technique is easy when an optimization pass simply maps one constraint to another, but is more complicated if we are reordering or removing redundant constraints. It seems like we would need some extra logic to be able to accurately compare the the set of input and set of output expressions as a whole.

Making our transformations more robust in this way would give us way more confidence in our pipeline. Applying this test to our dummy examples may not catch all mistakes, but for our main use case which is writing the Miden VM constraints, we could be sure that the generated code matches the initial description.

Moreover, this should make it much easier to audit the compiler since we could focus mainly on whether this randomized test is correct, rather than having to check that the individual optimizations are sound.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Observe las pasadas de optimización en la pipeline del compilador, probablemente en un directorio como `src/optimization`. Comprenda cómo cada pasada transforma las restricciones. La prueba implica muestrear elementos de campo aleatorios (QuadFelt, Felt) y evaluar expresiones de entrada y salida. Comience implementando un ayudante para pruebas de identidad polinomial aleatorizadas en una sola pasada. Revise las pruebas existentes para ver ejemplos ficticios y las restricciones de Miden VM para ver el punto de integración.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
rust
Área
compilers
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.