Log functorch_config to Scuba per compile region (#182762) (#182762)
Summary:
Adds `functorch_config` as a JSON blob column in the `dynamo_compile` Scuba table,
completing the visibility into all three stages of the torch.compile() pipeline:
```
Python code
↓
[dynamo_config] ← Graph capture: tracing, guards, cache ✅ already logged
↓ FX Graph
[functorch_config] ← AOT Autograd: partitioning, AutoAC ← THIS DIFF
↓ Forward + Backward graphs
[inductor_config] ← Code generation: triton, fusion, tuning ✅ already logged
↓ Compiled code
```
`functorch_config` captures AOT autograd settings per compile region, including:
- `activation_memory_budget` — AutoAC budget (0.0-1.0), the primary use case
- `activation_memory_budget_solver` — solver for min-cut partitioning (dp, ilp, greedy)
- `activation_memory_budget_runtime_estimator` — how op runtimes are estimated (flops, profile)
- Other functorch settings https://fburl.com/code/0zg42buq
Since `record_compilation_metrics` fires per compile region and `functorch_config_override.as_patch()`
sets per-FQN values, this captures the per-region budget — different modules can have different budgets.
**Use case example:**
- fire-jackienguyen-auto_ac_0504_204046: this job has autoac activation_memory_budget in pt2 config set as 0.1 as it inherits from model config. However, I custom override it via functorch_config to have activation_memory_budget=0.4. This logging will let us able to quickly check what is the correct budget that was set without checking job config/log.
- This enables efficiency automation platform to query `dynamo_compile` to check both "is PT2 on" and "what AutoAC budget is set" in a single query, without grepping job logs, which is expensive at scale.
Follows the same pattern as the existing `dynamo_config` and `inductor_config` JSON blob columns.
**Rollback safety:** Gated behind JK `pytorch/dynamo:log_functorch_config` (defaults to `True`). If
the new field causes issues, flip the JK to `False` to stop populating it without reverting the diff.
Exception handling matches the inductor config pattern (`TypeError, AttributeError, RuntimeError,
AssertionError`) to avoid losing all compilation metrics if `get_config_copy()` raises unexpectedly.
X-link: https://github.com/pytorch/pytorch/pull/182762
Approved by: https://github.com/aorenste
Reviewed By: georgehong
Differential Revision: D104097781
fbshipit-source-id: 0f4aadf176197c45dc115c6894bcbca1d05ee921