Repository navigation
Validate FP8 E4M3FN conversion correctness and add MPS vs CPU comparison - #8
Merged
Merged
Conversation
- Tests all 256 FP8 values for roundtrip consistency - Validates special values and edge cases - Tests monotonicity (order preservation) - Checks quantization error bounds - Confirms reference implementation matches IEEE FP8 E4M3FN spec Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
- Add comprehensive correctness test suite (test_fp8_correctness.py) - Add cross-validation test for Metal vs C++ (test_cross_validation.py) - Create detailed analysis report (ANALYSIS_REPORT.md) - Verify all implementations match IEEE FP8 E4M3FN spec - Confirm scaling bug fix is properly implemented - Identify that conversion math is correct; precision limits are inherent to FP8 Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
- Create test_mps_vs_cpu.py: comprehensive validation comparing Metal GPU vs CPU fallback - Tests encoding, decoding, roundtrip, dtype conversion, and matmul - Includes performance benchmarking - Address code review comments in test_fp8_correctness.py: - Add comments explaining NaN handling - Document special case roundtrip behavior - Add calculation comments for test cases - Extract magic numbers to named constants - Update README with new testing workflow Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
- Create FIX_SUMMARY.md documenting complete investigation - Explains what was found, what was fixed, and what tests were added - Provides clear guidance for users experiencing video corruption - Documents that conversion math is correct per IEEE spec - Issue is precision limitations, not bugs - All security checks pass Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix wrong Float8_e4m3fn conversion math
Validate FP8 E4M3FN conversion correctness and add MPS vs CPU comparison
Feb 17, 2026
lmangani
marked this pull request as ready for review
February 17, 2026 22:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue claims FP8 conversions corrupt video generation. Investigation shows conversion math is correct per IEEE spec. Root cause: inherent FP8 precision limits (~6-12% quantization error), not implementation bugs.
Validation Tests Added
test_fp8_correctness.py
test_mps_vs_cpu.py
test_cross_validation.py
Documentation
ANALYSIS_REPORT.md - Root cause analysis, recommendations
FIX_SUMMARY.md - Complete investigation summary
Findings
Conversion implementation is correct. Video corruption likely from:
Recommend: mixed precision (FP16 for critical layers), tighter test tolerances.
Usage
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.