omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
| 1 | # M21 OMEGA_AUTODIFF (docs/autodiff/M21_OMEGA_AUTODIFF.md): reverse-mode tape |
| 2 | # over the M20 tensor CPU tier. Files under src/autodiff/ and |
| 3 | # tests/test_omega_autodiff.c. Picked up by `-include mk/*.mk`. Not part of |
| 4 | # `all` or `test`. CPU only: opens no device, never touches the GB10. |
| 5 | # |
| 6 | # test-autodiff CPU tests plain and with ASan/UBSan |
| 7 | # test-autodiff-mutations applies each MUT: source mutation of src/autodiff |
| 8 | # in a scratch copy and proves the test then fails |
| 9 | # autodiff-mutants alias of test-autodiff-mutations |
| 10 | # test-autodiff-fixture FIXTURE=<path>: replays a native .om tape fixture |
| 11 | # (native/autodiff664) on this C tape, CPU table; |
| 12 | # the --mutant-sign negative control must FAIL. |
| 13 | # The GB10 arm is tests/run_ad_chip.sh, not here. |
| 14 | # |
| 15 | # Own source lists (mk/tensor.mk is read after this file, so its variables |
| 16 | # are not set yet when these rules are parsed). |
| 17 | ifndef AUTODIFF_MK |
| 18 | AUTODIFF_MK := 1 |
| 19 | .PHONY: test-autodiff test-autodiff-mutations autodiff-mutants test-autodiff-fixture |
| 20 | AUTODIFF_CFLAGS = -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -ffp-contract=off -Isrc -Isrc/tensor \ |
| 21 | -Isrc/autodiff -DOMEGA_NUMERIC_CPU_ONLY |
| 22 | AUTODIFF_SRCS = src/autodiff/omega_autodiff.c |
| 23 | AUTODIFF_TENSOR_SRCS = src/tensor/omega_tensor.c src/tensor/omega_tensor_cpu.c \ |
| 24 | src/tensor/omega_tensor_reduce_seam.c src/omega_numeric_reduce.c src/omega_numeric_transc.c |
| 25 | AUTODIFF_DEPS = src/omega_numeric.c src/omega_numeric_provenance.c src/omega_blackwell_encoder.c \ |
| 26 | src/omega_blackwell_codegen.c src/omega_blackwell_matmul.c src/omega_blackwell_qmd.c src/omega_om_units.c |
| 27 | AUTODIFF_HDRS = src/autodiff/omega_autodiff.h src/tensor/omega_tensor.h src/tensor/omega_tensor_reduce_seam.h \ |
| 28 | src/omega_numeric_reduce.h src/omega_numeric.h src/sha256.h src/omega_numeric_transc.h |
| 29 | |
| 30 | AUTODIFF_OMC ?= seed/out/omc |
| 31 | AUTODIFF_OM_SRCS = src/tensor/tensor_shape.om src/tensor/tensor_ops.om src/train/tg_sha256.om \ |
| 32 | src/tensor/omega_tensor_cpu.om src/tensor/omega_tensor.om \ |
| 33 | src/autodiff/gradient_shape.om src/autodiff/omega_autodiff.om |
| 34 | |
| 35 | $(OUT_DIR)/test_omega_autodiff: src/autodiff/test_autodiff.om $(AUTODIFF_OM_SRCS) $(AUTODIFF_OMC) |
| 36 | @mkdir -p $(OUT_DIR) |
| 37 | (printf 'om2\n'; sed -e '/^om2$$/d' -e 's/^export fn /fn /' $(AUTODIFF_OM_SRCS) src/autodiff/test_autodiff.om) | $(AUTODIFF_OMC) > $@ && chmod +x $@ |
| 38 | |
| 39 | test-autodiff: $(OUT_DIR)/test_omega_autodiff |
| 40 | ./$(OUT_DIR)/test_omega_autodiff |
| 41 | |
| 42 | $(OUT_DIR)/test_omega_ad_fixture: tests/test_omega_ad_fixture.c $(AUTODIFF_SRCS) $(AUTODIFF_TENSOR_SRCS) \ |
| 43 | $(AUTODIFF_DEPS) $(AUTODIFF_HDRS) |
| 44 | @mkdir -p $(OUT_DIR) |
| 45 | gcc $(AUTODIFF_CFLAGS) -O2 -o $@ tests/test_omega_ad_fixture.c $(AUTODIFF_SRCS) $(AUTODIFF_TENSOR_SRCS) \ |
| 46 | $(AUTODIFF_DEPS) |
| 47 | |
| 48 | test-autodiff-fixture: $(OUT_DIR)/test_omega_ad_fixture |
| 49 | @test -n "$(FIXTURE)" || { echo "test-autodiff-fixture needs FIXTURE=<path>"; exit 2; } |
| 50 | ./$(OUT_DIR)/test_omega_ad_fixture --host $(FIXTURE) |
| 51 | @./$(OUT_DIR)/test_omega_ad_fixture --host --mutant-sign $(FIXTURE); rc=$$?; \ |
| 52 | if [ $$rc -ne 1 ]; then echo "mutant-sign control did not FAIL (rc=$$rc)"; exit 1; fi; \ |
| 53 | echo "AD_FIXTURE_HOST mutant-sign control: FAIL as required" |
| 54 | |
| 55 | test-autodiff-mutations: |
| 56 | sh tools/autodiff_mutations.sh |
| 57 | |
| 58 | autodiff-mutants: test-autodiff-mutations |
| 59 | endif |