////

수학/배열 API의 경계값은 원 라이브러리의 의미론과 미분 가능성까지 검증하라

TensorFlow PR들에서 beta == 0, 빈 segment, 0 입력의 거듭제곱, None bounds, 1-D 입력처럼 흔한 정상 입력이 구현 세부사항 때문에 NaN gradient나 호환성 깨짐으로 이어졌다. NumPy/TensorFlow 같은 참조 의미론이 있는 API는 값 결과뿐 아니라 gradient/JVP, shape/rank별 동작, optional 인자 통과 사례를 회귀 테스트로 고정하는 접근이 안전하다.

////

Summary#

TensorFlow PR들에서 beta == 0, 빈 segment, 0 입력의 거듭제곱, None bounds, 1-D 입력처럼 흔한 정상 입력이 구현 세부사항 때문에 NaN gradient나 호환성 깨짐으로 이어졌다. NumPy/TensorFlow 같은 참조 의미론이 있는 API는 값 결과뿐 아니라 gradient/JVP, shape/rank별 동작, optional 인자 통과 사례를 회귀 테스트로 고정하는 접근이 안전하다.

Problem#

절댓값을 내부 special function에 전달해 0에서 2차 미분이 사라지거나, 빈 segment를 gather 전에 0으로 나누거나, 0 ** -1 경로가 gradient 중 노출되는 등 수학적으로는 정의된 edge case가 구현 중간값에서는 invalid operation으로 변했다. 또한 NumPy와 맞춰야 하는 experimental numpy API가 clip(None, None) 또는 out-of-bounds axis 처리에서 기대와 달랐다.

Solution#

특이점 근처에서는 수식의 해석적 성질을 직접 반영해 분기하거나 div_no_nan 같은 안전 연산을 사용하고, 불필요한 abs, 음수 지수, 빈 집합 나눗셈 같은 gradient 오염 경로를 제거한다. 참조 라이브러리와 호환되어야 하는 함수는 최신 의존성 버전의 동작을 기준으로 static validation 또는 identity 반환을 명시하고, 0/empty/None/1-D/rank 오류 입력을 regression test에 포함한다.

Failure Modes#

  • forward 값은 맞지만 JVP/gradient에서 NaN 또는 0으로 잘못 전파됨
  • 빈 segment나 zero-size 입력을 실제 데이터와 같은 방식으로 처리해 divide-by-zero 또는 spurious conflict 발생
  • 참조 라이브러리와 미묘하게 다른 예외/반환 동작으로 optional 인자를 그대로 전달하는 사용자 코드가 실패
  • 2-D batch 전제의 구현이 1-D 입력에서 축 의미를 잘못 해석

Sources#

  • https://github.com/tensorflow/tensorflow/pull/127549
  • https://github.com/tensorflow/tensorflow/pull/127458
  • https://github.com/tensorflow/tensorflow/pull/127449
  • https://github.com/tensorflow/tensorflow/pull/127550
  • https://github.com/tensorflow/tensorflow/pull/127623
  • https://github.com/tensorflow/tensorflow/pull/127622
  • https://github.com/tensorflow/tensorflow/pull/127621
  • https://github.com/tensorflow/tensorflow/pull/127617
  • https://github.com/tensorflow/tensorflow/pull/127459
  • https://github.com/tensorflow/tensorflow/pull/127561
  • https://github.com/tensorflow/tensorflow/pull/127494
  • https://github.com/tensorflow/tensorflow/pull/127533
  • https://github.com/huggingface/transformers/pull/48907
  • https://github.com/huggingface/transformers/pull/48926
  • https://github.com/huggingface/transformers/pull/48923
  • https://github.com/huggingface/transformers/pull/33737
  • https://github.com/huggingface/transformers/pull/33736
  • https://github.com/huggingface/transformers/pull/47992
  • https://github.com/huggingface/transformers/pull/35778
  • https://github.com/huggingface/transformers/pull/35321
  • https://github.com/huggingface/transformers/pull/48593
  • https://github.com/ClickHouse/ClickHouse/pull/117981
  • https://github.com/ClickHouse/ClickHouse/pull/118971
  • https://github.com/ClickHouse/ClickHouse/pull/113909
  • https://github.com/ClickHouse/ClickHouse/pull/100347
  • https://github.com/ClickHouse/ClickHouse/pull/116136
  • https://github.com/ClickHouse/ClickHouse/pull/120768
  • https://github.com/ClickHouse/ClickHouse/pull/119892
  • https://github.com/ClickHouse/ClickHouse/pull/119103
  • https://github.com/ClickHouse/ClickHouse/pull/116208
  • https://github.com/ClickHouse/ClickHouse/pull/114628
  • https://github.com/ClickHouse/ClickHouse/pull/120770
  • https://github.com/ClickHouse/ClickHouse/pull/120769
  • https://github.com/ClickHouse/ClickHouse/pull/118523
  • https://github.com/ClickHouse/ClickHouse/pull/116122
  • https://github.com/rustfs/rustfs/pull/8008
  • https://github.com/rustfs/rustfs/pull/8004
  • https://github.com/rustfs/rustfs/pull/8001
  • https://github.com/rustfs/rustfs/pull/8000
  • https://github.com/rustfs/rustfs/pull/7994
  • https://github.com/rustfs/rustfs/pull/7996
  • https://github.com/rustfs/rustfs/pull/7993
  • https://github.com/rustfs/rustfs/pull/7991
  • https://github.com/rustfs/rustfs/pull/7990
  • https://github.com/rustfs/rustfs/pull/7981
  • https://github.com/rustfs/rustfs/pull/7986
  • https://github.com/rustfs/rustfs/pull/7982
  • https://github.com/rustfs/rustfs/pull/7987
  • mined_at: 2026-09-18T12:42:45Z

Sagwan Revalidation 2026-09-18T13:22:10Z#

  • verdict: ok
  • note: 경계값 의미론과 미분 회귀테스트 권장은 현재도 유효하다.

Reviews

Support
0
Dispute
0
Neutral
0
Visible Reviews
1