|
| 1 | +# GATL AD Lab |
| 2 | + |
| 3 | +GATL AD Lab is an external numeric check harness for `gatl-core` risk-model |
| 4 | +artifacts. It consumes `gatl risk-models` JSON, evaluates the typed scalar RPN |
| 5 | +expression, executes the exported reverse derivative instruction skeleton, and |
| 6 | +compares it with a local finite-difference estimate. |
| 7 | + |
| 8 | +This repo is intentionally outside `gatl-core`. It does not change GATL |
| 9 | +language semantics and does not add an AD runtime to the language core. |
| 10 | + |
| 11 | +## Scope |
| 12 | + |
| 13 | +v0.1 supports: |
| 14 | + |
| 15 | +- `gatl-core/v0.1-risk-model-analysis`; |
| 16 | +- `typedExpression.format = rpn/scalar-v0.1`; |
| 17 | +- scalar primitives `const`, `add`, `sub`, `mul`, `div`, `exp`, `log`, |
| 18 | + `sigmoid`, `dot`, and `matmul`; |
| 19 | +- reverse pullbacks from `derivativeProgram.instructions`; |
| 20 | +- finite-difference gradient comparison. |
| 21 | + |
| 22 | +`const` has no literal in current `gatl-core`, so this lab treats it as an |
| 23 | +external numeric assumption. The CLI default is `--const 1.0`, and reports |
| 24 | +record that value. |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +Generate risk-model artifacts: |
| 29 | + |
| 30 | +```bash |
| 31 | +cd /home/jisheng-yang/projects/gatl-core |
| 32 | +./gatl risk-models examples/valid-fill-kinds.gir --out target/gatl/risk-models.json |
| 33 | +``` |
| 34 | + |
| 35 | +Run AD checks externally: |
| 36 | + |
| 37 | +```bash |
| 38 | +cd /home/jisheng-yang/projects/gatl-ad-lab |
| 39 | +cargo run -- validate /home/jisheng-yang/projects/gatl-core/target/gatl/risk-models.json |
| 40 | +cargo run -- eval /home/jisheng-yang/projects/gatl-core/target/gatl/risk-models.json \ |
| 41 | + --input action_features=2.0 \ |
| 42 | + --input user_features=3.0 \ |
| 43 | + --const 1.0 \ |
| 44 | + --out target/gatl-ad-lab/evaluation.json |
| 45 | +cargo run -- check-gradient /home/jisheng-yang/projects/gatl-core/target/gatl/risk-models.json \ |
| 46 | + --input action_features=2.0 \ |
| 47 | + --input user_features=3.0 \ |
| 48 | + --const 1.0 \ |
| 49 | + --epsilon 0.000001 \ |
| 50 | + --tolerance 0.00001 \ |
| 51 | + --out target/gatl-ad-lab/ad-check.json |
| 52 | +``` |
| 53 | + |
| 54 | +Local example: |
| 55 | + |
| 56 | +```bash |
| 57 | +make check |
| 58 | +``` |
| 59 | + |
| 60 | +## Boundary |
| 61 | + |
| 62 | +This is a local numeric lab, not a production AD engine: |
| 63 | + |
| 64 | +- no TensorFlow, PyTorch, JAX, ONNX, or autograd framework; |
| 65 | +- no external proof checker; |
| 66 | +- no network; |
| 67 | +- no secrets; |
| 68 | +- no runtime worker; |
| 69 | +- no modification of `gatl-core`. |
| 70 | + |
| 71 | +Future proof-oriented work should consume the generated AD check report or add |
| 72 | +a separate proof fixture format, not move numeric execution into `gatl-core`. |
0 commit comments