Repository navigation
Add global average pooling and multiply to the raster lane, validated live - #48
Merged
Merged
Conversation
…lane Two raster blocks, Fixed — offline only: global_avg_pool2d, the mean of the whole map onto its one-pixel grid through the private helper pool2d's aligned branch now uses (byte-identical), and multiply, a same-grid product or a one-pixel gate pooled from the map. compile_model recognizes AdaptiveAvgPool2d / F.adaptive_avg_pool2d to size 1, mean over (2, 3) with keepdim=True, and *, torch.mul and Tensor.mul in either operand order. The receptive-field analysis lists a global mean in extent_nodes and refuses every halo, so tiled compilation refuses the model. Mirrors, integer-generated fixtures (one on a 128 x 128 map, by a per-fixture request-grid allowance), tests and the catalogue.
tools/live_fixtures.py --offline global_pool_multiply on the previous commit (clean tree): 7 fixtures passed, zero cloud calls; largest mirror-vs-PyTorch error 2.38e-07. The catalogue now resolves the blocks' evidence.
x = a*col + b*row + c, so a pixel spanning the whole map takes b times the height and d times the width. Grid refuses any shear, so both terms are zero and no graph changes.
The global_pool_multiply selection ran live once: 7 fixtures, 13 requests, all passed. Earth Engine equals the NumPy mirror in every value; against float32 PyTorch the largest absolute error is 2.38e-07 (the pooled mean) and 0 for the product. reduceResolution accepted maxPixels 16,900 on the 128 x 128 map. Both statuses name the maps that ran, since the map's size is the input's grid and not a parameter; the validated records hold clip_footprints False. Larger maps and Earth Engine's accumulation order remain unvalidated.
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.
Two new raster blocks, the parts of a squeeze-and-excitation gate the CNN path lacked, with their recognition in
compile_model. Both were validated live in this pull request.global_avg_pool2d(EXTENT,float32_operands): PyTorch'sadaptive_avg_pool2d(x, 1), the mean of an H × W map, as a[N, C, 1, 1]tensor on a one-pixel grid that covers exactly the map (core.grid.one_pixel). It ispool2d's aligned expression with the map's size as the kernel, through one shared private helper (_aligned_reduce).multiply(POINTWISE,float32_operands):x * otherfor an operand onx's grid, or for a one-pixel gate onone_pixel(x.grid), with equal channel counts. Channel broadcasts, scalars, other grids and other channel counts are refused.compile_modelrecognizesnn.AdaptiveAvgPool2d(1),F.adaptive_avg_pool2d(x, 1),torch.mean/Tensor.meanover(2, 3)withkeepdim=True, and*,torch.mul,Tensor.mulin either operand order. 1 × 1 convolutions and pointwise activations run on the one-pixel grid unchanged.analyze_receptive_fieldlists it inextent_nodesand refuses a halo, tiled compilation refuses the model, and the compatibility report adds one restriction when a global mean is present. Equality with PyTorch is per compiled grid.Fixture.raster_sidelets one fixture raise its own request grid to at most 128 × 128; onlyraster/global_avg_pool2d/h128-w128uses it.No existing block, default, cast or status changes.
pool2demits the same graph through the shared helper, which G1 shows.Base revision:
5c170c36(main).Changes by layer
tensor_ee/core/grid.py(one_pixel).blocks/raster/pooling.py(_aligned_reduce,global_avg_pool2d),blocks/raster/merge.py(multiply),blocks/raster/__init__.py.semantics.py,compiler.py,receptive_field.py,compatibility.py.tools/fixtures/core.py,tools/fixtures/raster.py(selectionglobal_pool_multiply, seven fixtures, integer-generated inputs and weights),tools/live_fixtures.py.tests/test_raster_global_pool_multiply.py(new),tests/reference/raster_gate.py(new mirror),tests/reference/activations.py,tests/reference/__init__.py,tests/test_live_fixtures.py,tests/test_raster_blocks.py,tests/test_receptive_field.py,tests/test_x02b_validated_settings.py.README.md(90 blocks),docs/api.md,docs/library-contract.md,docs/live-fixtures.md,docs/building-blocks.md(regenerated),docs/evidence/raster-global-pool-multiply-offline.json,docs/evidence/live-fixtures/20261112T151417Z-global_pool_multiply.json.Checks on the head commit
Run locally on
c000725with a clean tree (Python 3.14, all extras, trained checkpoints present):5c170c36before the first edit.pytest -q: 3778 passed, 20 skipped.--offline global_pool_multiply: 7 fixtures passed, zero cloud calls.--plan global_pool_multiply: 13 requests, largest 49,152 values and 374,955 bytes, 0 assets, 0 tasks, within budget.--plangraphs and totals ofcalibration,p02,hard_activations,batch_norm,bilinear,grouped_convandstandardizeare identical at the base and at4b30c592.Not reproduced locally: the hosted jobs on Python 3.11 and 3.12 without extras.
Largest absolute error per fixture (tolerance 1e-4). The three columns are separate claims:
raster/global_avg_pool2d/h5-w7raster/global_avg_pool2d/h8-w8raster/global_avg_pool2d/h64-w64raster/global_avg_pool2d/h128-w128raster/multiply/same-grid-h5-w7raster/multiply/gate-h5-w7raster/multiply/squeeze-excitation-h12-w20Live run
The selection
global_pool_multiplyran once on the clean revision4b30c592: 7 fixtures, 13 requests (the planned count), 0 assets, 0 tasks, no refused calls, 14.9 s. Every fixture passed. The record is committed unedited. The head commit's 13 planned graph hashes are identical to that revision's, so the record describes the graphs this pull request ships.An earlier attempt of the same selection stopped in initialization on a credentials error before any request was sent. It says nothing about the blocks and its record is not committed.
Both blocks are promoted to Ready at what ran:
global_avg_pool2d: "Ready — maps 5 × 7, 8 × 8, 12 × 20, 64 × 64 and 128 × 128".multiply: "Ready — same grid on a 5 × 7 map; one-pixel gate on 5 × 7 and 12 × 20 maps".The map's size is the input's grid and not a parameter of either block, so the validated records hold only
clip_footprintsFalse and the statuses name the maps.Limitations
reduceResolutionacceptedmaxPixels16,900 on the 128 × 128 map. A larger map needs a largermaxPixelsand has not run.conv2d; its 26 pools and 26 products are no longer what refuses it.