Skip to content

weight-sync(jax): fail-loud runtime-derived tile-representability guard - #666

Open
lokic233 wants to merge 1 commit into
google:mainfrom
lokic233:pr-a-tile-representability-guard
Open

weight-sync(jax): fail-loud runtime-derived tile-representability guard#666
lokic233 wants to merge 1 commit into
google:mainfrom
lokic233:pr-a-tile-representability-guard

Conversation

@lokic233

Copy link
Copy Markdown

Problem

A tiled leaf whose on-device representation cannot be faithfully reconstructed at the destination previously published silent zeros (BUG1 class). The D2H stages logical bytes but transfer completion is accounted in tiled (on-device) bytes; when on_device_size > logical_size the receiver waits for bytes that never arrive after detiling, H2D never fires, and the destination silently remains zero-initialized — with success == true.

Fix (fail-loud, runtime-derived, dtype-proof)

Add assert_tile_representable_v2(jax_arrays), invoked from WeightSynchronizer.__init__ and bind_weights. It rejects a leaf iff sum(on_device_size_in_bytes(shards)) > logical_bytes:

  • Runtime-derived, no hardcoded tile constant — correct for f32 (8,128), bf16 (8,128)+(2,1), int8 (8,128)+(4,1), MoE/1-D/narrow, and any future dtype.
  • No false positive when the on-device size is unavailable (-1).
  • Fail-loud pre-publication with an actionable message.

Validation

Deterministic unit checks: rejects tiled>logical (single-array and sharded), allows on_device==logical, allows unknown on-device size (no false reject). Prior silicon matrix (LANDING, 24 cells): 14/14 tiled>logical rejected, 10/10 byte-safe allowed, 0 silent-zero survivors; 296×512 bf16 byte-exact.

Scope / non-goals

This is a fail-closed guard. It does not replace the separate D2H event-completion correctness fix (which addresses the distinct silent rank-1 byte-drop of a present var) or the coverage guard (missing-var class). No subset-sync semantics.


Authored with agentic assistance (Navi); guard logic validated deterministically and consistent with prior silicon runs.

A tiled leaf whose on-device representation cannot be faithfully reconstructed
at the destination (on-device/tiled bytes > logical bytes) previously published
silent zeros: the D2H stages LOGICAL bytes but completion is accounted in TILED
bytes, so the receiver waits for bytes that never arrive after detiling, H2D
never fires, and the destination silently stays zero-initialized (BUG1 class).

Add a runtime-derived guard (assert_tile_representable_v2) invoked from
WeightSynchronizer.__init__ and bind_weights that rejects a leaf iff
sum(on_device_size_in_bytes(shards)) > logical_bytes. It is dtype-proof (reads
the runtime's own device layout, no hardcoded tile constant) and does not false-
positive when the on-device size is unavailable. Fail-loud, pre-publication.

Deterministically validated: rejects tiled>logical (single + sharded), allows
odb==logical, no false reject on unknown odb. This is a fail-closed guard, not a
substitute for the D2H event-completion fix (separate PR) which addresses the
distinct silent rank-1 byte-drop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant