viiccwen commented on PR #805: URL: https://github.com/apache/mahout/pull/805#issuecomment-3742327615
> thanks for the patch @viiccwen ! 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? Agree. I hadn’t considered IEEE 754 propagation behavior. It'll be removed later. And also agree to keep the nan/inf guard, although we've checked nan/inf situation later stages: https://github.com/apache/mahout/blob/bff0b88ef38808263a65a24a8d2ee2352bd0e1b4/qdp/qdp-kernels/src/amplitude.cu#L147-L149 It should help catch invalid values early in the pipeline as well : ) Thanks for the suggestion! -- 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]
