Skip to content

Commit bc82405

Browse files
committed
feat(bench): leave the geometry open unless the
configuration asks for it `tools/bench/build.py` passed a lane geometry on every build: the one the configuration asked for, or, where it asked for none, the generator's own deduction. The two are not the same statement. A geometry the tuner is given is one it holds fixed, so handing it the deduction took the lane count out of the space for every build this harness makes -- the tuner could turn rolling and merging and nothing else, which is most of what the measurements were meant to test. Only what was asked for is passed now; where nothing was, the generator deduces as it always did, and the tuner may turn it. A lane ceiling in the configuration still counts as asked. Which leaves the harness reporting a geometry it no longer knows, so the generator reports the one it settled on (`Generator.lanes`), beside the figures it already reports, and the record takes it from there. With nothing asked for that is the deduction's answer, or the tuner's. AI-generated. Model: Opus 5
1 parent 862a681 commit bc82405

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎src/tensorforge/generators/generator.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@ def __init__(self,
382382
#: settled before they were built: tuning them again would open a walk
383383
#: inside every probe, and a probe inside every build of every walk.
384384
self._may_tune: bool = True
385+
#: The geometry this build settled on, which with none asked for is what
386+
#: the deduction, or the tuner, arrived at. Beside the other figures a
387+
#: caller reads back, because a harness that reports the geometry it
388+
#: passed in reports the question and not the answer.
389+
self.lanes: Optional[LaneConfig] = None
385390

386391
self._section: Section = Section()
387392
self._sections: List[Section] = []
@@ -1234,6 +1239,8 @@ def _generate_kernel(self):
12341239
self.memory_bytes = self._context.memory_bytes
12351240
self._warn_icache()
12361241
self.resident_blocks = self._resident_blocks()
1242+
self.lanes = LaneConfig(self._num_threads, self._num_active_threads,
1243+
self._lead_width)
12371244

12381245
def _warn_icache(self) -> None:
12391246
"""Say so when the kernel's code is larger than the instruction cache.

‎tools/bench/build.py‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,15 @@ def generate(workload: Workload, unit: BuildUnit) -> Tuple[Optional[str],
209209
# `lanes` over the option (`Generator` builds with `self._lanes or
210210
# lanes.requested(...)`), so passing only the deduction here built
211211
# every lane-count configuration at the deduced count.
212-
config = (lanes.requested(descrs, ctx)
213-
or lanes.deduce(descrs, ctx, ceiling=unit.config.lane_ceiling))
214-
gen = Generator(descrs, ctx, attrs=workload.attrs, lanes=config)
212+
#
213+
# And only what the configuration asked for is passed: a geometry
214+
# given here is one the tuner holds fixed, so handing it the deduction
215+
# -- which is the generator's own answer, not the caller's -- takes
216+
# the lane count out of the space for every build this harness does.
217+
asked = (lanes.requested(descrs, ctx)
218+
or (lanes.deduce(descrs, ctx, ceiling=unit.config.lane_ceiling)
219+
if unit.config.lane_ceiling else None))
220+
gen = Generator(descrs, ctx, attrs=workload.attrs, lanes=asked)
215221
with contextlib.redirect_stdout(io.StringIO()):
216222
gen.generate()
217223
headers = list(ctx.get_vm().get_headers()) + list(
@@ -224,7 +230,9 @@ def generate(workload: Workload, unit: BuildUnit) -> Tuple[Optional[str],
224230
return None, record
225231

226232
record.symbol = f'kernel_{gen.get_base_name()}'
227-
record.lanes = config.num_threads
233+
# What it was built at, which with nothing asked for is what the generator
234+
# deduced or the tuner picked.
235+
record.lanes = gen.lanes.num_threads
228236
record.cost = list_cost(workload.descrs(), batch=1,
229237
datatype=unit.datatype)
230238
return src, record

0 commit comments

Comments
 (0)