rich7420 commented on PR #805:
URL: https://github.com/apache/mahout/pull/805#issuecomment-3741575096

   Doing validate_input and then calculate_l2_norm in debug mode is basically 
two full O(N) passes. Once you get into ~20+ qubits, that can definitely make 
local runs feel sluggish.
   I think we could do with the IEEE 754 behavior approach: NaNs/Infs will 
naturally "poison" the sum during the norm calculation, so you're already 
getting most of that validation for free:
   
   - Any NaN in the input → sum of squares becomes NaN
   - Any Inf in the input → sum becomes Inf
   
   So yeah, in most cases we can drop the separate check_numerical_safety loop 
and just rely on the end-of-calculate_l2_norm guard (lines 86–96) to catch:
   
   1. Invalid inputs (NaN/Inf)
   2. Overflow during accumulation
   
   That gives you a single O(N) pass, keeps things cleaner, and speeds up debug 
builds without affecting release.
   WDYT?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to