Skip to content

feat(thermal,r-iif): add generic thermal power models, profile overlays, and directional handoff - #49

Merged
saariuslystoned merged 1 commit into
mainfrom
feat/thermal-power-and-directional-riif
Nov 30, 2026
Merged

saariuslystoned merged 1 commit into
mainfrom
feat/thermal-power-and-directional-riif

Conversation

@saariuslystoned

Copy link
Copy Markdown
Contributor

Summary

Adds generic, SoC-agnostic temperature-compensated power modeling, runtime JSON profile overlay loading, and asymmetric directional cross-accelerator handoff costing across both the C11/C++17 freesched runtime (libfreesched.a) and Python freesilicon-twin:

  1. Generic Thermal Power Models (include/freesched.h, src/fs_{internal.h,topology.cpp,router.cpp,executor.cpp} & python/freesilicon_twin/roofline.py):

    • Adds fs_thermal_model_kind_t (FS_THERMAL_NONE, FS_THERMAL_LINEAR, FS_THERMAL_EXP), fs_thermal_power_model_t (p_dyn_w, p_leak0_w, coeff, ref_temp_c, tj_ceiling_c), and fs_eval_device_watts(dev, junction_temp_c) with zero-init backward compatibility to typical_watts, 0/NaN fallback to ref_temp_c, optional tj_ceiling_c clamping, and non-negative output guards.
    • Wires fs_resolve_device_watts_internal() into fs_router.cpp energy estimation and fs_executor.cpp telemetry (est_watts, total_energy_mj), alongside Python eval_thermal_rail_watts() and eval_profile_thermal_watts() (preserving non-double-counted VSYS_ALL vs additive sub-rails) and optional est_watts / rail_watts schema support.
  2. External Profile Overlay Loader (python/freesilicon_twin/{profiles.py,cli.py}):

    • Adds --profile-overlay <path> and FREESILICON_TWIN_OVERLAY runtime overlay loading (load_profile_overlay, apply_profile_overlay) with deep-copy isolation of bundled profiles and fail-closed schema validation (schema_target, thermal_power_model, directional_handoff_us, iif_kthread_quirk).
    • Adds global --temp-c / --temps-json CLI overrides while keeping bundled default profiles untouched and free of private calibration payloads.
  3. Directional R-IIF Handoff Costing & iif_kthread_quirk Guard (fs_topology.cpp, fs_router.cpp, roofline.py):

    • Adds fs_handoff_policy_t (directional_us[FS_DEV_COUNT][FS_DEV_COUNT], iif_kthread_quirk, iif_kthread_penalty_us, FS_DEFAULT_IIF_KTHREAD_PENALTY_US), fs_topology_handoff_us(), and matching Python eval_directional_handoff_us().
    • Supports asymmetric TPU -> GPU vs GPU -> TPU sync-file bridge latency and selectively applies iif_kthread_penalty_us to non-TPU -> FS_DEV_TPU transitions when iif_kthread_quirk is active.

Verification

  • make verify-headers (-std=c11 & -std=c++17 -Wall -Wextra -Werror): PASS
  • FREESCHED_MOCK=1 ./build/test_c11_abi (-std=c11 -Wall -Wextra -Werror -pedantic): PASS
  • FREESCHED_MOCK=1 ./build/test_freesched (11 suites incl. synthetic thermal_power_model_and_telemetry & directional_handoff_and_iif_kthread_quirk): All 11 PASS
  • FREESCHED_MOCK=1 ./build/bench_heterogeneous & ./build/freesched_dmabuf_smoke --profile malibu --mock --json: PASS (zero_copy_handoffs=3, fallback_copies=0)
  • python3 -m unittest -v tests/test_twin.py tests/test_sdk.py tests/test_evolve_runner.py tests/test_map_elites.py tests/test_twin_qcs9075.py: Ran 41 tests - OK
  • ./twin/freesilicon-twin self-test: PASS (schema_errors=0, native_bench_verified=2)
  • ./scripts/clean-room-audit.sh: Clean-room audit PASSED across 122 files (0 errors)

@saariuslystoned
saariuslystoned merged commit af49b56 into main Nov 30, 2026
5 checks passed
@saariuslystoned
saariuslystoned deleted the feat/thermal-power-and-directional-riif branch November 30, 2026 13:30
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.

1 participant