Download code/tt_centerpoint/knobs.py from changh95/centerpoint-p150: direct link, hf CLI and curl.
- Browser
- Download file 10.9 kB
-
https://huggingface.co/changh95/centerpoint-p150/resolve/main/code/tt_centerpoint/knobs.py
- Command line
-
hf download hf://changh95/centerpoint-p150/code/tt_centerpoint/knobs.py
-
curl -L -o knobs.py https://huggingface.co/changh95/centerpoint-p150/resolve/main/code/tt_centerpoint/knobs.py
10.9 kB
| # SPDX-License-Identifier: Apache-2.0 | |
| """The optimization knobs of centerpoint-p150 (``ttaw.knobs``): each an A/B switch read once at model build from | |
| ``CENTERPOINT_<NAME>``; the default is the measured best (OPT_REPORT.md), pinned in ``tt-model.yaml serve.env``. | |
| Every host knob selects between bit-identical implementations (the numpy one is the oracle).""" | |
| from __future__ import annotations | |
| from .ttaw.knobs import Knob, Knobs | |
| __all__ = ["KNOBS"] | |
| KNOBS = Knobs("CENTERPOINT", [ | |
| Knob("HOST_VOXELIZER", "numba2", "voxelizer: numba counting sort (H2; 'numba2' = R10 H8: counting pass in input " | |
| "order, int32 work arrays) or the numpy argsort oracle", choices=("numba2", "numba", "numpy")), | |
| Knob("HOST_DENSIFY", "numba", "single-sweep / pre-densified cloud: column select + nonzero_rows + copy in one " | |
| "numba pass (R10 H7) or numpy", choices=("numba", "numpy")), | |
| Knob("HOST_STAGING", "sparse", "staging rows with HOST_DECORATE=numba: 'sparse' = per-pillar occupancy of each " | |
| "persistent buffer, only the rows that held data are rewritten / zeroed (R10 H9), 'full' = every slot row " | |
| "of the kept pillars written + rows of the previous frame's extra pillars zeroed", choices=("sparse", "full")), | |
| Knob("HOST_DECORATE", "numba", "pillar decoration: numba straight into the bf16 staging rows (H1) or the numpy " | |
| "(40000, 32, 9) float32 array + torch bf16 conversion", choices=("numba", "numpy")), | |
| Knob("HOST_DECODE", "rows", "decode: on the read-back head rows, candidate cells only (H3), or unpack the six " | |
| "full head maps first", choices=("rows", "maps")), | |
| Knob("HOST_NMS", "numba", "IoU-BEV NMS: numba twin (same keep decisions, H5) or the numpy / Python oracle", | |
| choices=("numba", "numpy")), | |
| Knob("HOST_PREFILTER", "u64", "the 5-class tiled head-row prefilter with unsigned offsets (R10 H10: no " | |
| "negative-index wraparound per load) or the round-1 signed form", choices=("u64", "i64")), | |
| Knob("HOST_READBACK", "tiled", "head read-back with HOST_DECODE=rows: 'tiled' = the TILE bytes of the host " | |
| "buffer, read by the decoder directly (no host untilize), 'numpy' = ttnn.to_torch untilize", | |
| choices=("tiled", "numpy")), | |
| Knob("PFN_LAYOUT", "pair", "PFN input layout: 'pair' = two pillars per 32x32 tile, uploaded already tiled " | |
| "(no device reshape / tilize; block-diagonal weights), 'slot' = one pillar per tile row block from 1 KB " | |
| "ROW_MAJOR rows (reshape copy + tilize on the device)", choices=("pair", "slot")), | |
| Knob("CONV_L1", "auto", "3x3 convs run on ttnn's L1 path (Conv2dL1FullSliceConfig: input moved to L1 height / " | |
| "block shards inside the op) instead of the DRAM-sliced path, whose [1,1,H*W,C] <-> [1,H,W,C] TILE reshapes " | |
| "are copies when W is not a multiple of 32 (OPT_PLAN D2): 'none', 'all', 'auto' (every conv whose input " | |
| "width is not a multiple of 32), or a comma list of groups block0, block1, block2, shared"), | |
| Knob("DEBLOCK2", "k2r", "linear + depth-to-space deblocks (k = s >= 3, OPT_PLAN D3): 'stock' = the ttaw layer " | |
| "(unfused ReLU, untilize / reshape / permute / reshape / tilize), 'fused' = ReLU fused into the linear " | |
| "(core_grid) + the stock layout ops, 'k2' = fused linear + the K2 face-copy kernel (tt/d2s.py, bit-exact), " | |
| "'k2w' = K2 with 1 KB face-pair reads / writes (K2_WIDE, R5), 'k2f' = k2w with the 32-byte row shuffle's " | |
| "loads issued before its stores (K2_FAST, R8), 'k2r' = K2R: a ROW_MAJOR output into head.shared's part conv " | |
| "L1 shards (pack_untilize + 1 KB chunk writes, R8; k2f where the output goes to DRAM)", | |
| choices=("stock", "fused", "k2", "k2w", "k2f", "k2r")), | |
| Knob("DEBLOCK1", "k2r", "k = s = 2 ConvTranspose deblocks (deblock1, OPT_PLAN D7''', R8): 'ct' = " | |
| "ttnn.conv_transpose2d (DRAM-sliced at base, ROW_MAJOR input per DEBLOCK1_RM), 'k2r' = the linear_d2s form: " | |
| "ttnn.linear (Cin -> 4*Cout, ReLU fused, core_grid) + K2R writing head.shared's part-conv L1 shards " | |
| "(tt/d2s.py; k2f where the output goes to DRAM)", choices=("ct", "k2r")), | |
| Knob("DEBLOCK1_MM", "2d", "the linear of DEBLOCK1=k2r (R8): 'stock' = ttnn.linear with core_grid, '2d' = an " | |
| "explicit 2D multicast program config (bit-identical, tt/d2s.py program_config_2d)", choices=("stock", "2d")), | |
| Knob("FIDELITY", "HiFi3", "math fidelity of every backbone / neck / head module (convs, linears, K6; the PFN " | |
| "stays HiFi4, CENTERPOINT_PRECISION rules still win): 'HiFi3' (R9: a device fp32-weight matmul keeps about " | |
| "9.5 mantissa bits, which HiFi3 covers, PROBES.md P12; all 33 gates green) or 'HiFi4' (rounds 0-8)", | |
| choices=("HiFi3", "HiFi4")), | |
| Knob("DEBLOCK_K2M", "none", "K2M (OPT_PLAN K2M, R9): the k = s deblocks running linear + K2R into head.shared's " | |
| "part-conv L1 shards as ONE generic_op program (tt/d2s.py LinearD2SK2M: fp32 weights in L1, bias + ReLU, " | |
| "pack_untilize from dest, 1 KB chunk writes; no linear output in DRAM): 'none', 'all' or a comma list of " | |
| "deblock1, deblock2"), | |
| Knob("PFN_LY_ROWS", True, "PFN second layer on packed rows: the slot-max output [1, P, 1, C] reshaped to " | |
| "[1, 1, P, C] before ly (OPT_PLAN D1s)"), | |
| Knob("CONV_RM", "auto", "ROW_MAJOR outputs for the convs whose output width is not a multiple of 32 and whose " | |
| "successor runs the DRAM-sliced path, so ttnn.conv2d's TILE reshape copies become views (OPT_PLAN D2b; " | |
| "decided after the first eager call): 'auto' or 'none'", choices=("auto", "none")), | |
| Knob("HEADS", "k5", "merged heads: 'stock' = two ttnn.linear (hidden written to DRAM), 'k5' = one generic_op " | |
| "program with the hidden row block in L1 (tt/heads.py, OPT_PLAN D4)", choices=("stock", "k5")), | |
| Knob("CONV_L1_ABH", "block0:128,shared:32,block1:96", "with CONV_L1=auto, act_block_h_override = N rows for " | |
| "the L1-path 3x3 convs of the listed groups ('group:N,...', groups block0 block1 block2 shared; '' or 'none' " | |
| "= off): at widths that ARE a multiple of 32 (base block0 / head.shared, left on DRAM slicing by 'auto') the " | |
| "convs also try the L1 path with N-row activation blocks (OPT_PLAN D2c); at other widths (block1) N is the " | |
| "second try when ttnn's own blocks do not fit L1 (OPT_PLAN D2e); a layer that still does not fit falls back " | |
| "to DRAM slicing without the override"), | |
| Knob("CONV_CHAIN", "auto", "consecutive L1-path convs of a backbone block keep the producer's sharded L1 output " | |
| "as the consumer's input (no ShardedToInterleaved + InterleavedToSharded pair per conv, OPT_PLAN D2d; " | |
| "decided after the first eager call, a link whose consumer does not fit L1 next to it is dropped): 'auto' " | |
| "or 'none'", choices=("auto", "none")), | |
| Knob("DEBLOCK1_RM", "auto", "k2s2 conv_transpose2d deblocks whose input width is not a multiple of 32 get a " | |
| "ROW_MAJOR input (one untilize), so ttnn's [1,1,H*W,C] <-> [1,H,W,C] TILE reshape copies become views " | |
| "(OPT_PLAN D7'): 'auto' or 'none'", choices=("auto", "none")), | |
| Knob("HEAD_SUM", "k6", "shared conv's K-split sum with HEADS=k5: 'stock' = two ttnn.add (ReLU fused) writing the " | |
| "shared map to DRAM, 'k6' = the three partials go straight into the heads kernel, which forms relu((p0 + p1) " | |
| "+ p2) per row tile in L1 (tt/heads.py run_sum, OPT_PLAN D6a)", choices=("stock", "k6")), | |
| Knob("HEAD_PARTS_L1", "last", "with HEAD_SUM=k6, the head.shared K-split partials that keep the conv's L1 " | |
| "height-sharded output and go to K6 without a ShardedToInterleaved (OPT_PLAN D6b): 'none', 'last' (the " | |
| "third partial) or 'all' (tiny only: at base the second part conv runs out of L1 next to the resident " | |
| "partial, an allocator error this knob does not recover from)", | |
| choices=("none", "last", "all")), | |
| Knob("PFN_PACK", "k97", "pair-layout PFN layout copies as data-movement kernels (tt/pfn_pack.py, OPT_PLAN D1t): " | |
| "'k8' = the slot-max pack before ly (in place of a TILE reshape copy), 'k7' = the scatter table written " | |
| "from ly's TILE output (in place of untilize + reshape + pad), 'k78' = both, 'none' = round 4; 'k97' = K9 " | |
| "(tt/pfn_max.py, OPT_PLAN D1u, R6: the slot max reduced and packed in one program, no padded max tensor in " | |
| "DRAM) + K7", choices=("none", "k8", "k7", "k78", "k97")), | |
| Knob("CONV_TSHARDS", "block2", "Conv2dConfig.transpose_shards for the convs of the listed groups (comma list of " | |
| "block0 block1 block2 shared; '' or 'none' = off; OPT_PLAN D2f): a block-sharded conv puts its 8 channel " | |
| "tiles on the grid's 10 rows and the map rows on its 12 columns (96 cores) instead of 8 x 10 (80 cores); " | |
| "bit-identical (R6 probe 11)"), | |
| Knob("NECK_L1", "auto", "with HEAD_SUM=k6, each deblock runs right before its head.shared part conv and writes " | |
| "that conv's height-sharded L1 input directly (OPT_PLAN D6c): the 1x1 deblock as a 1D-multicast matmul " | |
| "with a sharded output, the K2 deblock through its output accessor, an L1-path conv_transpose2d deblock " | |
| "when its own shards match; no InterleavedToSharded / DRAM round trip of those 59 MB maps: 'auto' or " | |
| "'none' (round 5: all deblocks to DRAM, then the three part convs)", choices=("auto", "none")), | |
| Knob("PFN_MK", "m1", "M1, the PFN + scatter module megakernel (tt/pfn_mk.py, OPT_PLAN 3.5, the D19 attempt, " | |
| "R11): 'm1' = ONE generic_op program per bucket (pair PFN with h / z in L1, ly, the K7 table, a unicast " | |
| "grid barrier, then the canvas gather in place of ttnn.embedding), 'm1a' = the PFN part only (table) + " | |
| "ttnn.embedding, 'none' = l0 / lz / K9 / ly / K7 + embedding (round 10); m1 is bit-identical and the default since R11.1", choices=("none", "m1a", "m1")), | |
| Knob("PFN_MK_GATHER", 4, "M1 phase B (the canvas gather): canvas tiles whose 64-byte row reads share one read " | |
| "barrier (R11.2: default 4, bit-identical to 1 = R11.1's one round trip per occupied tile; validated on the " | |
| "device by the gates and VERIFICATION_OPT_2026-10-11.md)", choices=(1, 2, 4, 8, 16)), | |
| Knob("PFN_BUCKETS", "10000,16000,22000,28000,34000", "pillar-capacity buckets of the pair-layout PFN " | |
| "(OPT_PLAN D1b, R7): one persistent features input and one trace variant per capacity (comma list, each a " | |
| "multiple of 16 below max_voxel_size; the full max_voxel_size trace 'default' always exists); a frame runs " | |
| "the smallest bucket that holds its pillars, so the PFN, the scatter table and the features upload scale " | |
| "with the frame instead of the 40,000-pillar capacity; '' or 'none' = round 6 (one trace)"), | |
| ]) | |