[fastcache] Fix parameter pruning for dead-static-branch and swapped-slot forwarding#809
Conversation
…-slot forwarding (#808) Adds failing repros for the two fastcache parameter-pruning bugs from #808: - dead-static-branch field forwarded through a caller path walked before the live instantiation populates the shared used-set (flat and 3-level nested) - same-flat-name forwarding into swapped callee slots, cross-caller and same-caller Also adds a reversed walk-order variant of the flat dead-static-branch case, which passes on main and guards against an order-dependent fix.
…rding (#808) Record per-call-site call-graph edges during the discovery pass and propagate used-sets to a worklist fixpoint afterwards, instead of a single-shot copy keyed by callee. - Dead-static-branch (bug A): a callee's used-set (shared across template instantiations via its func id) can grow after an earlier caller copied it, so the enforcing pass pruned a parameter the callee still needed. The fixpoint makes propagation order-independent. - Swapped-slot forwarding (bug B): the caller-arg -> callee-param map was keyed by callee func id alone, so call sites forwarding the same flat name into different callee slots collided. Edges are now keyed per call site (source position). filter_call_args now takes the caller func id and looks up the per-call-site edge; kernel.materialize runs propagate_fixpoint() between discovery and the prefix-collapse. The fastcache-load path is unaffected (it skips discovery and only re-parses the kernel function def).
…runing test (#808) Forwards the dataclass by keyword (md=md) at every call site, exercising the kwarg pruning path (_expand_Call_dataclass_kwargs gated on the callee used-set) rather than the positional filter_call_args, confirming the used-set fixpoint also closes over keyword-forwarded edges. use_deep stays positional to avoid passing the template value by keyword (an unrelated concern).
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4725667cfa
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| # We can get the child's name directly from our own keyword node. | ||
| edge.pairs.append((caller_arg_name, callee_param_name)) | ||
| if caller_arg_name.startswith("__qd_"): | ||
| edge.positional_map[caller_arg_name] = callee_param_name |
There was a problem hiding this comment.
Key forwarded positional args by slot
When a caller passes the same dataclass field into multiple positional parameters, e.g. inner(md, md), the expanded call contains the same flat name in two different slots. This dict is keyed only by that caller flat name, so the later slot overwrites the earlier one; if the callee uses the first parameter but not the second, the enforcing pass consults the overwritten mapping, treats both occurrences as the unused parameter, and prunes the required argument, causing a missing-argument failure or wrong call wiring. Store the positional mapping by argument index, or otherwise keep per-slot entries, rather than by caller name alone.
Useful? React with 👍 / 👎.
…callee slots (#808) Key CallEdge.positional_map by caller arg name with an ordered list of callee params (one per occurrence) instead of a single value, and consume them in left-to-right order during the enforcing pass. A single name->name map let a later slot (e.g. the second md in inner(md, md)) overwrite an earlier one, so the enforcing pass could prune a positional arg the callee still needs, raising 'Missing argument'. Keying by name (not slot index) keeps the mapping robust to the positional shift that occurs when an upstream caller prunes fields out of a forwarded dataclass.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
Probably should create a pre-release, and check compilation time, on genesis benchmarks (or read from above benchmark csv reulst perhaps) |
|
compile time up a bunch apparently 🤔
Let's try running this also on @duburcqa 's branch, in case his does not increase compile time. |
|
ok to merge |
WoW. 40% is hardcore. Hopefully it is "noise". |
|
I might make AI write me a script to outputthes tables, so I dont have to rely on AI doing the right thing. |
|
AI investigated compile time. Seems not an issue: Compile-time investigationTL;DR: the reported "+11.5% compile time" for this branch is almost entirely a measurement artifact of comparing a locally source-built branch against the WandB CI Evidence 1 - the WandB baseline is not a valid zeroBenchmarking source-built So a local source build on the cluster node compiles ~6% slower (single-shot) than the WandB baseline for identical code. The three "vs WandB-main" runs line up as:
The per-benchmark regression pattern (worst on Evidence 2 - same-node A/B (removes the artifact)Built both
Harness verdict: "NO significant before/after difference." Conclusion
Caveat: |






Issue: #
Brief Summary
copilot:summary
Walkthrough
copilot:walkthrough