Merged
fix(wtsarq): default floating-point comparisons to cross_check #14960
zsq_888Add on 3 days ago
fix(wtsarq): default floating-point comparisons to cross_check #14960
Merged
Total: 1 files changed+8-16
| @@ -14,7 +14,7 @@ | |||
| 14 | Framework choice (TTK three-leg golden spec): the operator ships a TensorFlow | 14 | Framework choice (TTK three-leg golden spec): the operator ships a TensorFlow |
| 15 | frontend plugin (framework/wts_arq_tf_plugin.cpp maps OriginOpType "WtsARQ"), | 15 | frontend plugin (framework/wts_arq_tf_plugin.cpp maps OriginOpType "WtsARQ"), |
| 16 | so the CPU golden is implemented with TensorFlow; numpy is used only for I/O | 16 | so the CPU golden is implemented with TensorFlow; numpy is used only for I/O |
| 17 | -conversion and the torch third_party stays the independent GPU-leg reference. | 17 | +conversion and the torch third_party supplies the independent reference. |
| 18 | 18 | ||
| 19 | Delivery note: the operator is GE IR graph mode only. TensorFlow does NOT | 19 | Delivery note: the operator is GE IR graph mode only. TensorFlow does NOT |
| 20 | register a callable `tf.compat.v1.WtsARQ` interface, so no TF e2e route is | 20 | register a callable `tf.compat.v1.WtsARQ` interface, so no TF e2e route is |
| @@ -33,14 +33,10 @@ Semantics (README.md formula, kernel.h and DESIGN.md §3.5/§3.6): | |||
| 33 | dequant: y = q * scale | 33 | dequant: y = q * scale |
| 34 | 34 | ||
| 35 | Cast rule (float only, no integer outputs in @wts_arq_def.cpp): | 35 | Cast rule (float only, no integer outputs in @wts_arq_def.cpp): |
| 36 | - - tolerance standard is mix_tolerance, i.e. two-leg comparison; TTK does | 36 | + - float16 and float32 use cross_check by default. In Promote mode, the |
| 37 | - not Promote, so the golden reproduces the NPU kernel width itself: | 37 | + golden computes and returns its result in the dtype supplied by TTK. |
| 38 | - LoadWiden fp16 -> fp32 for the whole computation, CAST_RINT (half to | 38 | + - Outside Promote mode, the golden widens float16 inputs to float32 |
| 39 | - even) narrow back to the dispatched input dtype at the exit. | 39 | + for computation and casts the result back to the input dtype. |
| 40 | - - if a caller switches the judge to cross_check, TTK runs Promote and the | ||
| 41 | - golden receives lifted arrays/output_dtypes; golden_mode==Promote is | ||
| 42 | - therefore detected and the golden then does zero cast (no entry or exit | ||
| 43 | - narrowing), letting TTK own the promotion. | ||
| 44 | """ | 40 | """ |
| 45 | 41 | ||
| 46 | import numpy as np | 42 | import numpy as np |
| @@ -57,14 +53,10 @@ __spec__ = { | |||
| 57 | 53 | ||
| 58 | SCALE_EPS = 1.1920929e-07 | 54 | SCALE_EPS = 1.1920929e-07 |
| 59 | 55 | ||
| 60 | -# Precision standard: explicit ecosystem default. torch third_party below is the | 56 | +# The Torch third_party registered below supplies the reference for cross_check. |
| 61 | -# independent reference for `--compare cross_check` (cross_check needs an | ||
| 62 | -# XPU/torch provider; without one the run reports GOLDEN_FAILURE, so cross_check | ||
| 63 | -# is not set as the default judge here). Keys must cover every dtype registered | ||
| 64 | -# in op_host/wts_arq_def.cpp: DT_FLOAT16, DT_FLOAT. | ||
| 65 | _TOL_KERNEL = { | 57 | _TOL_KERNEL = { |
| 66 | - "float32": {"standard": "mix_tolerance"}, | 58 | + "float32": {"standard": "cross_check", "level": "L1"}, |
| 67 | - "float16": {"standard": "mix_tolerance"}, | 59 | + "float16": {"standard": "cross_check", "level": "L1"}, |
| 68 | } | 60 | } |
| 69 | 61 | ||
| 70 | 62 | ||