Skip to content

Add self-validation test for FP16 I/O vs mixed precision#6

Merged
ChinChangYang merged 2 commits intomasterfrom
test/fp16-io-self-validation
Jan 19, 2026
Merged

Add self-validation test for FP16 I/O vs mixed precision#6
ChinChangYang merged 2 commits intomasterfrom
test/fp16-io-self-validation

Conversation

@ChinChangYang
Copy link
Owner

@ChinChangYang ChinChangYang commented Jan 19, 2026

Summary

  • Add TestCppMixedVsPureFP16 test class that validates pure FP16 I/O mode produces inference results equivalent to mixed precision mode
  • Update comments in MILBuilder.cpp to clarify FP16 naming behavior (mixed precision uses _fp16 suffix for intermediate ops; cast ops rename to base name)

Test plan

  • Run pytest tests/test_cpp_vs_python.py::TestCppMixedVsPureFP16 -v on Apple Silicon
  • Verify both 9x9 and 19x19 board sizes pass for test models
  • Confirm tolerance of 0.5 is appropriate for FP16 precision differences

🤖 Generated with Claude Code

ChinChangYang and others added 2 commits January 19, 2026 08:13
Add TestCppMixedVsPureFP16 test class that compares pure FP16 I/O outputs
against mixed precision outputs, since Python coremltools doesn't support
float16_io mode. Also clarify comments in MILBuilder.cpp explaining that
_fp16 suffixed names are intermediate operation names that cast ops later
rename to base names for final model outputs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace absolute tolerance (max diff > 0.5) with np.allclose using
rtol=1e-2 and atol=1e-2 for more robust FP16 comparison that handles
both relative and absolute differences appropriately.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ChinChangYang ChinChangYang marked this pull request as ready for review January 19, 2026 01:03
@ChinChangYang ChinChangYang merged commit 01b57c4 into master Jan 19, 2026
1 check passed
@ChinChangYang ChinChangYang deleted the test/fp16-io-self-validation branch January 19, 2026 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant