Skip to content

Add rewrite validator #47

Open
Open
@Keno

Description

@Keno

The following invariant must hold:

isapprox(f_original(f_reconstruct(u_compressed))), `f_expand_resid(f_compressed(u_compressed)))` 

where f_compressed is the optimized DAE/ODE function we have right now, f_reconstruct is as in DAECompiler v1 and takes a state vector and expands it into a variable vector, f_expand_resid maps from state numbers to original equation numbers and makes all other entries zero, and f_original is the original function without any optimization (but with variable numbers the same as after structural analysis, so there's a little bit of work to do to hook that up right).

Validating this invariant would be a powerful check on our code generation. We need to write code generators for:

  • f_reconstruct
  • f_expand_resid
  • f_original

However, all of these should be relatively straightforward. f_reconstruct codegen can largely be copied from v1. f_expand_resid, is just a bunch of setindex and f_original is largely unmodified IR, with the exception of encoding the variable numbers.

Bonus points for a version of this that can do this on a partition-by-partition basis to narrow down which function is being miscompiled, but that can be follow on PR.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions