Summary#
컴파일러나 텐서 그래프 최적화에서 연산의 shape, rank, slice alignment 등을 바꾸면 기존 sharding, padding, dimension 매핑 같은 부가 메타데이터가 즉시 무효가 될 수 있다. 변환 로직은 데이터 경로뿐 아니라 verifier가 보는 모든 주석과 경계 조건을 함께 재계산하거나 안전하게 제거하는 방식으로 작성하는 것이 좋다.
Problem#
TensorFlow/XLA PR들에서 bitcast hoist 후 fusion output shape가 바뀌었지만 sharding annotation이 그대로 남아 HloVerifier가 실패했고, reshape operand의 leading unit dimension을 잘못 대응시켜 slice-of-reshape 최적화가 잘못 bail out되었다. MatrixDiag 계열 gradient도 op의 실제 padding/align 규칙과 gradient 구현의 기본값이 달라 padded entry로 gradient가 흐르는 문제가 있었다.
Solution#
IR 변환 후에는 shape/rank에 종속된 sharding·layout·slice index·padding 정책을 재검증하고, 새 shape에 맞게 재작성할 수 없으면 annotation을 clear한다. leading size-1 dimension, ignored padding, default alignment처럼 의미상 사라지거나 암묵적인 차원은 별도 케이스로 테스트하고, gradient나 inverse transform도 forward op의 정확한 semantics를 공유하게 만든다.
Failure Modes#
- shape만 변경하고 sharding/layout annotation을 유지해 verifier 또는 런타임에서 실패
- unit dimension을 실제 sliced dimension으로 잘못 매핑해 합법적인 최적화를 막거나 잘못 적용
- forward op에는 없는 기본 align/padding 정책을 gradient에서 사용해 silent numerical error 발생
- rank 변경 케이스, padding 무시 케이스, finite-difference gradient 검증이 테스트에 없음
Sources#
- https://github.com/tensorflow/tensorflow/pull/127491
- https://github.com/tensorflow/tensorflow/pull/127433
- https://github.com/tensorflow/tensorflow/pull/127282
- https://github.com/tensorflow/tensorflow/pull/127343
- https://github.com/tensorflow/tensorflow/pull/127333
- https://github.com/tensorflow/tensorflow/pull/127418
- https://github.com/tensorflow/tensorflow/pull/127286
- https://github.com/tensorflow/tensorflow/pull/126192
- https://github.com/tensorflow/tensorflow/pull/127358
- https://github.com/tensorflow/tensorflow/pull/127283
- https://github.com/tensorflow/tensorflow/pull/127419
- https://github.com/tensorflow/tensorflow/pull/127408
- https://github.com/huggingface/transformers/pull/48760
- https://github.com/huggingface/transformers/pull/48853
- https://github.com/huggingface/transformers/pull/48846
- https://github.com/huggingface/transformers/pull/48809
- https://github.com/huggingface/transformers/pull/48798
- https://github.com/huggingface/transformers/pull/48660
- https://github.com/huggingface/transformers/pull/48852
- https://github.com/huggingface/transformers/pull/48652
- https://github.com/tinode/chat/pull/1014
- https://github.com/tinode/chat/pull/1009
- https://github.com/tinode/chat/pull/1007
- https://github.com/tinode/chat/pull/1006
- https://github.com/tinode/chat/pull/1003
- https://github.com/tinode/chat/pull/1004
- https://github.com/tinode/chat/pull/1001
- https://github.com/tinode/chat/pull/1005
- https://github.com/tinode/chat/pull/1002
- https://github.com/tinode/chat/pull/998
- https://github.com/tinode/chat/pull/997
- https://github.com/heroiclabs/nakama/pull/2554
- https://github.com/heroiclabs/nakama/pull/2551
- https://github.com/heroiclabs/nakama/pull/2532
- https://github.com/heroiclabs/nakama/pull/2533
- https://github.com/heroiclabs/nakama/pull/2536
- https://github.com/heroiclabs/nakama/pull/2539
- https://github.com/heroiclabs/nakama/pull/2541
- https://github.com/heroiclabs/nakama/pull/2538
- https://github.com/heroiclabs/nakama/pull/2540
- https://github.com/heroiclabs/nakama/pull/2542
- mined_at: 2026-09-16T11:38:53Z
Sagwan Revalidation 2026-09-16T12:18:35Z#
- verdict:
ok - note: 일반 원칙과 TensorFlow/XLA 사례 모두 현재 관행과 충돌하지 않는다.
Sagwan Revalidation 2026-09-19T07:06:25Z#
- verdict:
ok - note: 일반 원칙이며 최근 검증 이후 반박이나 관행 변화가 보이지 않는다.
Sagwan Revalidation 2026-09-27T20:24:25Z#
- verdict:
ok - note: 핵심 불변식과 권장안은 여전히 유효하며, 수정이 필요한 모순은 보이지 않는다.
Sagwan Revalidation 2026-10-02T01:07:11Z#
- verdict:
ok - note: 핵심 불변식과 검증 권장안은 여전히 유효하며, 재사용을 막는 모순은 보이지 않는다.
Sagwan Revalidation 2026-10-04T21:38:33Z#
- verdict:
ok - note: shape 변경 시 관련 메타데이터와 경계 조건을 재검증하라는 권고는 여전히 유효하다.
Sagwan Revalidation 2026-10-07T23:06:43Z#
- verdict:
ok - note: shape 변경 시 관련 메타데이터를 재검증하라는 권고는 여전히 유효하며, 재사용을 막는 모순이 없다.
Sagwan Revalidation 2026-10-10T20:28:58Z#
- verdict:
ok - note: shape 변경 시 관련 메타데이터를 재검증하라는 권고는 여전히 유효하며, 재사용을 막는 모순이 없다.
Sagwan Revalidation 2026-10-13T12:05:44Z#
- verdict:
ok - note: shape 변경 시 관련 메타데이터를 재검증하라는 원칙은 여전히 유효하며, 재사용을 막는 모순이 없다.
Sagwan Revalidation 2026-10-16T09:39:25Z#
- verdict:
ok - note: shape 변경 시 관련 메타데이터를 재검증하라는 원칙은 여전히 유효하며, 재사용을 막는 모순이 없다.
Sagwan Revalidation 2026-10-19T05:14:40Z#
- verdict:
ok - note: shape 변경 시 관련 메타데이터를 재검증하라는 원칙은 유효하며, 재사용을 막는 모순이 없다.