Repository navigation
Run compiled CNNs in stages: saved nodes in compile_model, a run tool, and live runs of an EfficientNet-B3 U-Net - #52
Merged
Conversation
…one export, compare
…lists, offline refusals
…ool; report argmax agreement as a count
…'s input chip in the plan; record the staged live runs in the docstrings
…ns compared with PyTorch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A way to run a CNN that is too complex for one Earth Engine request as a sequence of exports, with the records of three live runs of SMP's EfficientNet-B3 U-Net (8 bands, 3 classes, one 256 × 256 chip): one request, refused as too complex; then the same model in six exports, with deterministic weights and with the released Fields of The World v3.1 weights, each within 1e-4 of float32 PyTorch.
No block, record, status, default, golden file or catalogue row changes, and no reader documentation.
compile_model(..., saved_nodes=None), keyword-only. It maps FX node names to images an earlier export saved for those nodes. A saved node's tensor is still built, for its grid and bands, and then replaced by the saved image, read exactly as the input is. Compiling the whole model with a saved node gives the same graph as compiling the model's tail alone from that image, which the tests assert byte for byte. The default emits today's graph. Refused: a name that is not a tensor operation of the traced graph, a node with no raster tensor, and a one-pixel tensor.tools/compiled_cnn_run.py, for one chip of one model:planis offline and exact: the weight tables, every request with its size, hash and graph counts, every call with its cap, the limits and the outcomes.uploadexports the weights as tables and the input chip as an image, and verifies both.runsubmits the model as one export, or as a staged run from a cut list (--cuts): export k compiles the whole model with every earlier saved node read from its image and exports node k; the last export is the logits. One submission per export, never repeated; resumable; a wall and a queue limit per task; an EECU budget checked before every submission; a required bound on the longest path of any export.comparefetches the saved input and logits once each and compares the logits with float32 PyTorch at 1e-4.reportis offline.tools/fixtures/cnn_reference.py). The other reads the released Fields of The World v3.1 CC BY checkpoint from a resources checkout: the tool never fetches it, refuses a file whose SHA-256 is not the pinned one, and reads it withtorch.load(..., weights_only=True)only.tensor_ee.weight_assets), the export request, the call guard and the asset and operation checks (tensor_ee/converter/), and the limits and helpers oftools/raster_cost_run.py, all unmodified.compile_modelstays the CNN path; the converter's planner is not involved.Base revision:
18e9365(main).Changes by layer
tensor_ee/compiler.py(saved_nodes; the input read and the saved-node read share one helper).tools/compiled_cnn_run.py(new),tools/fixtures/cnn_reference.py(new).tests/test_compile_saved_nodes.py(new),tests/test_compiled_cnn_run.py(new, against a fake client; zero cloud calls).docs/evidence/compiled-cnn-one-graph-live.json,docs/evidence/compiled-cnn-staged-live.json,docs/evidence/compiled-cnn-ftw-v31-staged-live.json(the tool'sreportoutput, unedited).Checks on the head commit
Run locally on
fcc3999with a clean tree (Python 3.14, all extras, trained checkpoints present):6e2d8fc,862c3ae,e2a0af8): 45 of 45 and 19 of 19 each.pytest -q: 4225 passed, 21 skipped. The two new files alone: 52 passed, 1 skipped (the released-checkpoint test, which reads the checkpoint only when a resources checkout is named).compiled_cnn_run.py plan, one request with deterministic weights, and staged for both recipes: every request hash equals the one in the live record of that run (1 + 6 + 6 model requests, and the deterministic-weights input).raster_cost_run.py plan --cases base,screen_size,long: its 16 request hashes equal those ofdocs/evidence/raster-gate-cost-live.json, so the shared input read leaves those compiled graphs as they were.segmentation-models-pytorch(hidden behind an import blocker): the two new files give 49 passed, 4 skipped.live_fixtures.py --offlineand--plan: not run. No fixture or selection is added or changed.Not reproduced locally: the hosted jobs on Python 3.11 and 3.12 without extras.
Live runs
Each on one 256 × 256 chip of 8 bands (the fixtures' evaluation chip with deterministic weights; the same chip plus 0.5 with trained weights),
clip_footprints=True,include_unfused_nodes=False, weights read from tables. The records carry neither the revision that ran nor the staged runs' limits: the one-request run was at6e2d8fc, the staged run with deterministic weights at862c3ae, the staged run with trained weights ate2a0af8, each on a clean tree.One request: refused. 6,587,046 bytes, 7,503 invocations, longest invocation path 4,132.
exportImageraised "Computation is too complex." at submission. It was not submitted again.Six exports (cut list
features: five saved nodes, then the logits; path bound 1,600):Request bytes are those of the deterministic-weights run; the trained run's differ by a few hundred bytes. Limits of both staged runs, as prepared: budget 600 EECU-seconds, 900 s per task, 1,800 s in the queue. Six
exportImagecalls per run, none repeated, no cancel.In both runs the saved input equals the local chip bit for bit.
The trained run was resumed once: after export 4 was submitted a status read failed on the client, and the tool stopped without an outcome. The task itself had succeeded. Run again, the tool read export 4's operation without resubmitting it and went on. The bounded retry of status reads in this pull request was added after that.
What the runs show, and what they do not
Limitations
clip_footprints=Falsehas run in stages live.cancelOperation; a lost submission answer; a staged run without an adopted upload.e2a0af8.tensor_ee/converter/run.pyandtools/raster_cost_run.py; a change there can break it, which its tests would show.Open questions
compile_model's docstring ("Run live in two staged runs of one architecture … No saved stage image was itself compared …") is a proposal.docs/api.mddoes not mentionsaved_nodes. A sentence next toclip_footprintswould be the place.