Skip to content

Simplify TensorStats Inheritance#540

Open
kylebd99 wants to merge 12 commits into
mainfrom
kbd-refactor-tensor-stats
Open

Simplify TensorStats Inheritance#540
kylebd99 wants to merge 12 commits into
mainfrom
kbd-refactor-tensor-stats

Conversation

@kylebd99

Copy link
Copy Markdown
Contributor

This PR is a small cleanup within the TensorStats folder. The goal is to remove TensorDef and instead use inheritance to manage the shared functionality.

@codspeed-hq

codspeed-hq Bot commented Jun 30, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 11.38%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 4 regressed benchmarks
✅ 28 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime test_ops_binary[interpret_galley-add] 787 ms 899 ms -12.47%
WallTime test_ops_binary[interpret_galley-multiply] 786.2 ms 888 ms -11.47%
WallTime test_ops_reduction[interpret_galley-sum] 419.5 ms 471.4 ms -11%
WallTime test_f1_jit[interpret_galley] 11.2 s 12.6 s -10.56%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing kbd-refactor-tensor-stats (c322bda) with main (64775fa)

Open in CodSpeed

@kylebd99 kylebd99 linked an issue Jun 30, 2026 that may be closed by this pull request

@willow-ahrens willow-ahrens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these methods seem like they should be calling super(), but instead they're passing around the parent where the def used to be, which is a little bit of a mismatch in the programming pattern


def _mapjoin_union(
self, new_def: TensorDef, op: FinchOperator, union_args: list[DummyStats]
self, new_def: BaseTensorStats, op: FinchOperator, union_args: list[DummyStats]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part seems a little strange? I think we should just call super().mapjoin_union?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit tricky because the class is a factory not a statistic, so calling super().mapjoin creates a BaseTensorStats object. We essentially do this within the BaseTensorStatsFactory.mapjoin implementation, then pass it to the _mapjoin_union/_mapjoin_join functions in the child classes. We can instead do that call within every _mapjoin_union/_mapjoin_join implementation though (and I think that may be cleaner).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just made that change

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.

Refactor TensorStats Inheritance hierarchy

2 participants