Relicense to Apache-2.0 (dual-license; external-contributor files remain MIT) - #408
Merged
Merged
Conversation
Contributor
|
Important Review skippedToo many files! This PR contains 621 files, which is 321 over the limit of 300. To get a review, narrow the scope: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: ⛔ Files ignored due to path filters (6)
📒 Files selected for processing (621)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
18 tasks
Anerudhan
force-pushed
the
relicense-apache-2.0
branch
from
July 23, 2026 19:18
158ed02 to
9f5a3cb
Compare
Anerudhan
force-pushed
the
relicense-apache-2.0
branch
3 times, most recently
from
July 30, 2026 06:08
c85e9df to
1fdbcc4
Compare
…MIT) Rebased onto current develop (b950af1). Relicenses NVIDIA-authored code from MIT to Apache-2.0 using the exact NVIDIA OSS SPDX header, keeping under MIT only files that still carry contributions from external contributors whose permission has not been established. License assignment (per-file SPDX tag on every source file): - Apache-2.0: 541 files - MIT (50): surviving lines from external contributors, consent pending - MIT (29): FlashAttention/QuACK-derived files carrying external authors' copyright Cleared, freeing 16 files to Apache-2.0: - Written consent on issue NVIDIA#431 (10): take-cheeze, fallintoplace, zianglih, JackRao123, zkyue, Hyaloid, haowen-han, junaire, szluyu99, dimitar-asenov. - NVIDIA employment (2), commits under personal email addresses: HollowMan6, and hxbai (Hongxiao Bai, PR NVIDIA#410) -- frees .../indexer_top_k/indexer_top_k_varlen_util.py and test/python/fe_api/dsa/test_DSA_indexer_top_k.py. Files touched by both a cleared and a still-pending contributor remain MIT. PR NVIDIA#427 (CSA fused Compressor kernels ported from Megatron-LM, author @zkyue who consented): its 13 files had no license header at all; they now carry the NVIDIA Apache-2.0 SPDX header. Megatron-LM added to THIRD_PARTY_LICENSES.txt as an NVIDIA Apache-2.0 provenance note. Still pending (7): ConnorBaker, DrDirk, EmilienM, jyknight, sbcd90, valgur, and co-author Benjamin Leff. Every change is comment/header-only; all Python compiles. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Anerudhan
force-pushed
the
relicense-apache-2.0
branch
from
July 30, 2026 06:13
1fdbcc4 to
0c08141
Compare
zkyue
approved these changes
Jul 30, 2026
Anerudhan
marked this pull request as ready for review
July 30, 2026 17:42
This was referenced Jul 31, 2026
Merged
YangXu1990uiuc
added a commit
to YangXu1990uiuc/cudnn-frontend
that referenced
this pull request
Aug 9, 2026
sdpa/fwd/heuristics.py was created by copying the header from config_sm120.py, which is MIT -- so the new file inherited a tag that does not apply to it. Per LICENSING.md, the repo relicensed MIT -> Apache-2.0 in NVIDIA#408 and a file is kept under MIT for exactly two reasons: surviving lines from an external contributor who has not consented to relicensing, or derivation from third-party source. A file written from scratch at NVIDIA has neither, so Apache-2.0 is the correct tag -- as it already is on every other file this change adds content to (engines/heuristics.py, engines/manifest.py, sdpa/fwd/engine.py, and the tests). The MIT neighbours in sdpa/fwd are pre-existing files this PR only edits, and editing does not move a file between licenses. Also switches to the SPDX-FileCopyrightText form the Apache-2.0 files use.
Anerudhan
pushed a commit
that referenced
this pull request
Aug 9, 2026
…_sort (#528) * Take the backend's plans one heuristic mode at a time Ranking the two sides against each other needs to know which backend entries are mode-A recommendations and which are fallbacks -- "the backend's A ahead of ours, its fallbacks behind" cannot be said about one opaque list. Until now the whole thing arrived from a single create_execution_plans([A, FALLBACK]). No C++ change is needed. C++ appends each query to the same plan list, and get_execution_plan_count() already exists, so asking one mode at a time and reading the count after each gives the boundaries. Measured on a 512^3 bf16 matmul (sm90, cuDNN 9.25): A -> plans[0:15], all knob-bearing; FALLBACK -> plans[15:17], bare eng0/eng7 with no knobs; the two segments do not overlap. A mode with no configs raises, which is not a decline while another mode still has entries -- an OPENSOURCE-only query legitimately leaves the cuDNN modes empty. Only every mode failing means the backend has nothing, and then the last error is re-raised so the caller still reports why. * Move plan ranking out of the engines and into one heuristics function An engine cannot rank. It sees neither its siblings nor the backend's entries, so propose_plans could only ever order its own knobs -- and then something downstream had to merge the two sides anyway, which heuristics_sort did by concatenating and calling it ranking. All four in-tree propose_plans were the base class's default copied verbatim: the hook has never decided anything. create_execution_plans() now gathers the inputs (parsed facts, the family's offered ids, the backend's entries tagged by mode) and hands all of it to the graph's family in ONE call. What comes back IS graph.plans, position for position. An engine answers two questions: can I serve this graph (check_support), and compile me this config (build_plan). sdpa/fwd/heuristics.py is the first such hook, and it is deliberately a frame with no tuning in it: one entry per eligible cell at the config its capability row declares. Mode A and FALLBACK differ only in which backend entries they carry; OPENSOURCE is mode A without the backend's recommendation, since these cells ARE the open-source implementation. Real per-cell rules land on top. Deleted, all superseded or never used: BaseEngine.propose_plans + its 4 implementations BaseEngine.default_knobs only fed propose_plans heuristics_sort merging is part of ranking, not a step after engines/router.py entirely Router / default_router / set_router / pygraph(router=) -- policy has one home now, and decline_types moved to base.py where the engine contract already lives engines.probe() (fwd + bwd) superseded by check_support graph.engine pure alias of selected_engine, zero callers graph.from_serialized zero callers; serialize/deserialize are the pybind-era API and stay knobs=None no longer means "engine, pick for me" -- the heuristics name a concrete config. A None field survives only on an axis whose capability row declares no domain. That reading is what let one choice be made twice, once when ranking and once inside the adapter. * Update the dispatch tests to the ranking contract, and delete what it retired Ranking has one home, so a test that wants a specific order replaces heuristics.rank instead of subclassing Router. The _ranking() helper does that; it is the same monkeypatch idiom the rest of the suite already uses. Deleted rather than translated: test_set_router_frozen_after_planning the API it tested is gone test_a_claiming_engine_is_tried_before_the_backend asserted that python plans always outrank the backend, which is a per-cell measurement, not a rule. FROST coverage rides on heur_mode.OPENSOURCE instead: ask for it and any graph still landing on a backend plan is one FROST cannot serve Renamed for what they now test: test_mixed_ranking_dispatch, test_empty_ranking_output_rejected, test_mixed_ranking_backend_slot_executes, test_constructor_backends_validated_and_ranking_ids_checked. One assertion changed meaning: the backend is queried once PER MODE now, so _create_backend_plans records two create_execution_plans calls for [A, FALLBACK]. test_sdpa_graph_analyzer called engines.probe() twice; those two call analyze_for directly, so no production API exists only for tests. Six sdpa test files each carried a verbatim copy of _select_engine matching a bare engine name. Plans now read <engine>[<knobs>] because the heuristics name a concrete config for every entry, so they share frost_test_utils.select_engine, which matches on the engine. 208 passed. test_a_replayed_plan_reports_its_own_notes still fails and also fails on develop without this change -- C++ on 9.25 no longer raises for an index one past the plan count. * Update the design doc, and align the remaining sdpa test helpers The doc still described a Router with three pluggability levels, engines that propose their own plans, and heuristics_sort as the seam a cost model replaces. Rewritten to what dispatch now does: one call per graph into the family's heuristics hook, the backend's entries tagged by the mode that produced them, and heur_mode.OPENSOURCE as the way FROST coverage is measured rather than assumed. Also states plainly what register_backend is and is not. It installs an engine instance on one graph -- the hatch tests use to inject a fake. It does not make an engine rankable: an out-of-tree engine declares no Capabilities, so nothing can enumerate its configs or place it against the backend. The follow-up list now names removing that concept, since an engine id is decodable from the manifest alone. Six sdpa test files each carried a verbatim copy of _select_engine matching a bare engine name; the shared frost_test_utils.select_engine matches on the engine, which is what plan names now carry a config suffix for. 208 passed locally. The one failure is test_a_replayed_plan_reports_its_own_notes, which fails on develop without this change too. * Decode an engine id from the manifest, with nothing registered first An engine id is fully decodable from the manifest: the family owning the id block, then the slot within it. _owners_for_id only ever looked inside the graph's candidate set, so an id could be resolved only if something had already put that engine there -- which made register_backend look like a prerequisite for create_execution_plan() when it is really just one way to supply an instance. engine_for_id() closes that. _owners_for_id falls back to it, so replaying a recorded (engine_id, knobs) works on a fresh graph, including for an engine that is not a candidate for THAT graph -- there the replay is a deliberate pin, not a routing decision. A gated-off slot still resolves to None rather than being built. Groundwork for removing the out-of-tree engine concept entirely. * Remove the out-of-tree engine concept: the manifest is the only way in Every python engine now exists exactly one way. register_backend, pygraph(backends=), graph.backends and OUT_OF_TREE_ID_BASE are gone, and _candidate_engines() is the graph's family and nothing else. An out-of-tree engine could never be RANKED anyway: it declares no Capabilities, so nothing could enumerate its configs or place it against the backend. It was an entry point into the plan list, not into the decision. And being a candidate had nothing to do with fitness -- an engine was in the list because someone had registered it, so an engine that could not serve the graph was still tried, and failed at build instead of at classification. The linear_attention suites used register_backend to PIN an implementation -- cuTile rather than FROST. That is not what registration is for, and those engines are in the manifest already, so the pin is now by name and applied after planning through select_plan(): engine_utils.pin_engines() / apply_pin(). apply_pin raises when the pinned engine produced no plan, so a pin that stops working fails the first op call. The cutile conftest used to check the pin by inspecting the CANDIDATE list, which passes whether or not the pin took effect -- which is how it ran for months against whichever engine the ranking picked while the seam it pinned through was dead. That check is deleted; the pin enforces itself. heuristics: no engine sits outside a family now, so the "family-less engines go last" branch is gone and _without_a_family is _unranked -- the case it covers is a family that declares no heuristics hook, not an engine with no family. test_engine_router.py -> test_dispatch.py. It never tested a Router; it tested dispatch -- one plan list, the at-index APIs, select_plan's strict pin, one-shot planning, how a decline advances the walk, note filters reaching python plans, manifest classification, facts attachment. _offer(monkeypatch, *engines) replaces register_backend by putting the fakes in a manifest family, so the tests reach engines through the same path production does. Six tests deleted with the concept they tested -- all checked registration-time id validation, which has no subject now that engines never declare their own ids: test_register_backend_validation, test_engine_id_in_the_in_tree_region_is_rejected, test_a_registered_in_tree_engine_is_not_offered_twice, test_overlapping_declared_id_blocks_are_rejected, test_a_lying_owns_id_cannot_capture_another_engines_plans, test_constructor_backends_validated_and_ranking_ids_checked. What they protected is covered by test_family_id_blocks_are_disjoint and test_every_engine_spec_has_a_manifest_slot. BaseEngine.owns_id goes with them: zero callers, and its docstring already called it a convenience. Three tests needed real thought rather than a mechanical edit: - The "no family, no facts payload" test built a bare relu graph. relu names no family, so there is no python candidate, and the backend declines a 2-D pass-by-value tensor -- planning raised before the assertion. The claim under test is about the payload, not about the graph being servable. - The mutable-after-validate window was `not self._backends`: validate() lowers and freezes any graph the backend CAN lower, and registering an engine was the only way to skip that. With registration gone the window is exactly the ops with no backend lowering, which is what the property was always about. - test_api_signature_parity asserted {"backends", "router"} were keyword-only. Both are gone, so the assertion had no subject; what it protected is that nothing pygraph-only is POSITIONAL, which is now asserted directly. TorchMatmulEngine goes too. It reimplemented matmul, bias and relu in torch inside a dispatch test: the numeric assertions proved torch, not dispatch, and "torch_matmul" in plan names reads like something cuDNN ships. StubEngine replaces it -- same claim on the graph, no arithmetic, and it RECORDS what dispatch handed it, so the fusion test now asserts what was only implied before: every node arrives in build order, each input port resolved to the caller's storage, and the virtual intermediate carrying none. * Give the SM120 SDPA-forward cell a real tile rule, as the worked example The framework had no rule in it: every cell went to `_sole()` on each knob axis, which answers None the moment a row declares more than one value. The SM120 prefill row declares tile_ms={64,128}, tile_ns={64,128}, so its choice fell through to api_dsl's `_SM120_Q_TILES[0]` default -- the choice being made in the adapter is exactly what moving ranking out of the engines was meant to stop, and it left the frame with nothing showing how a rule is added. _sm120_tiles(facts) is that rule, and it is measured rather than invented: regret 1.009 geomean / 1.054 worst against the best of the enumerated domain. tile_n=128 always; tile_m=64 when the grid cannot fill the machine AND each CTA has enough KV tiles to amortize the extra Q-tile loop, with a causal mask counted as a halved effective grid because it halves the work per CTA. It reads facts and nothing else -- device_sm_count is already on the record. Shape a colleague can copy: write the function, list the cell in _TILE_RULE_CELLS, put the measurement in the commit. A cell absent from that set keeps the old behaviour (its row's sole point per axis), which is the honest answer when nobody has timed it. Mode A now emits the guess FIRST and the rest of the domain behind it, so a caller who autotunes has the runners-up and a caller who does not gets the best guess at index 0. FALLBACK takes the smallest tile the row admits -- the config that asks least of the device; picking real fallback configs per cell is a TODO left in the file. * Ask one function whether an SM120 tile fits, not two Naming tile_n=128 unconditionally broke D=208/224/240/256: the adapter's own `if self.tile_n is None` branch was quietly shrinking the KV tile to whatever fit SMEM, so leaving the knob None had been answering a CAPABILITY question, not a tuning one. Requesting a value skips that branch, and the request then fails the very check the branch existed to satisfy -- 106512 bytes wanted against the part's 101376. The fit arithmetic moves to config_sm120.smem_bytes(), beside the template it describes, and both callers use it: the adapter's check and the ranking's choice. The rule now reads "tile_n = the largest that fits, tile_m by occupancy", and the runners-up it offers are filtered the same way -- a config the kernel cannot fit is not a runner-up, it is an entry that sits in the list to decline at build. test_api_signature_parity asserted {"backends", "router"} were keyword-only. Both are gone, so the assertion had no subject; what it protected is that nothing pygraph-only is POSITIONAL, which is now asserted directly. * Query the backend for the modes the ranking will actually place The default mode list was written out twice -- once in _create_backend_plans, once in heuristics.default_modes. They agree today; a change to one alone would have the backend enumerate plans for a mode no family places, which reads as the family losing entries rather than as the query asking for the wrong thing. * Restore the #512 SDPA tests this branch had silently reverted Four test files were carrying their PRE-#512 content while the production code they exercise is post-#512. The branch is cherry-picked onto the github develop, and the commit that consolidated the sdpa test helpers was authored against a tree from before #512 landed -- so the cherry-pick took the whole file, not the helper edit, and reverted #512's test additions with it. api_dsl.py and engines.py were untouched by that, which is why nothing looked wrong until an SM100 box ran the suite: 16 failures, all of them tests asserting the old contract against the new kernels (a stats-less SM100 graph now carves a dummy LSE, so get_workspace_size() is b*h*s*4, not 0). Restored all four from gh/develop and re-applied only what this branch meant to change: - test_sdpa_fwd_dsl_sm100 / _sm120: the local verbatim copy of _select_engine -> frost_test_utils.select_engine. - test_sdpa_frontend_integration: plan-name lookups made suffix-aware. The heuristics now name a concrete config for every entry, so a plan reads "<engine>[<knobs>]" and names.index(_FROST) raises ValueError. - test_sdpa_graph_analyzer: engines.probe() is deleted, so _eligible asks analyze_for(...)[1] is None. The ragged-Stats coverage #512 added (token-major and head-major layouts, zero-length sequences, the analyzer acceptance test, the strict LSE presence contract in both directions) is back verbatim. * Bring the design doc to the architecture as it now stands The dispatch tree, written out: what create_execution_plans does in order, where the backend's per-mode entries come from, and where a family's rules sit. That tree was the first thing anyone asked for and the doc did not have it. Corrects three things the doc stated as settled that this PR changed: the delegating entry leads the BACKEND's block and not the family's (it falls through to native configs when the C++ OSS engine declines, so ahead of an OPENSOURCE block it answers a coverage question with a native kernel); a plan's identity is (engine_id, knobs) and never its cpp_index; whether a heuristic mode succeeded is tracked per call, not inferred from plan spans. Adds what each machine covers. The suites SKIP on the wrong arch rather than fail, so a green sweep on one box says nothing about the others -- defaulting to CUDA device 0 is how a whole SM100 run silently skips. Follow-ups now name what is actually left: one tuning rule exists, FALLBACK is a placeholder, _MEASURED_BEHIND is empty by design. * Answer the backend's plan query once per distinct config Two findings from the second review pass, both about APIs whose callers moved under the branch. Graph::create_execution_plans checks override_heuristics_query() FIRST and returns before it reads the mode at all -- deterministic SDPA backward and FP8 backward both override. Asking one mode at a time therefore appends the SAME engine-17 config once per mode, and backend_plan_entries() handed all of them back. SDPA forward's recommend() would have deduped them; SDPA BACKWARD declares no heuristics hook, so _unranked passed the duplicates straight into graph.plans and build_plans(ALL) or an autotuner would compile and time one config twice. Deduped at collection instead of in each family: a repeated (engine, knobs) in the backend's own list is never two different things, and the first index is the one whose mode span is real. test_dsl_sm100_band_right_uncovered_tail_rejected called fwd_engines.probe(). That test arrived with #485, which this branch rebased onto after probe() was already deleted here -- so it is a caller that did not exist when the deletion was written, and it would have taken out the whole Blackwell L0 suite with an AttributeError before reaching its assertion. * Address the CodeRabbit pass: an id names one engine, and two tests could not fail engine_for_id() matched an id exactly while _owners_for_id() matched a RANGE, so a replay could resolve one way for a candidate engine and another way on a fresh graph. Collapsed the other way from what was suggested: BaseEngine.id_end and owned_id_range are deleted and _owners_for_id is an equality test. The range existed so a REGISTERED engine could claim a block and registration could prove two blocks disjoint; nothing registers now, no shipped engine ever set id_end, and every range was [engine_id, engine_id + 1). Keeping it would have spread dead machinery to fix an asymmetry that only that machinery created. EngineFamily.id_end -- the family's block -- is a different thing and stays. test_ranking_and_engine_read_the_same_record declared a probe_family by hand and then called _offer(), whose own monkeypatch of MANIFEST won; the surviving family had no analyzer. It passed anyway because both sides call _facts_for(_probe_analyzer) directly, so the documented claim -- that the ranking resolves the analyzer from EngineFamily.analyzer -- went unexercised. Now declared through _offer, and it asserts the analyzer already ran BEFORE ranking, which is the part only planning can do. Verified by mutation: drop the analyzer declaration and the test fails. select_engine(tiles=) matched the rendered plan name by substring, so a request for tile_n=128 could select a tile_n=1280 plan and the test would pass having run something else. Matches PlanConfig.knobs structurally now. No caller on this branch -- the fp8 SM120 tile tests in #509 are the first, and they would have been the ones to hit it. Plus a cross-reference to a test renamed in this PR. 204 passed on the CPU suites; the one failure is the pre-existing test_a_replayed_plan_reports_its_own_notes. * License the one file this PR adds as Apache-2.0, not MIT sdpa/fwd/heuristics.py was created by copying the header from config_sm120.py, which is MIT -- so the new file inherited a tag that does not apply to it. Per LICENSING.md, the repo relicensed MIT -> Apache-2.0 in #408 and a file is kept under MIT for exactly two reasons: surviving lines from an external contributor who has not consented to relicensing, or derivation from third-party source. A file written from scratch at NVIDIA has neither, so Apache-2.0 is the correct tag -- as it already is on every other file this change adds content to (engines/heuristics.py, engines/manifest.py, sdpa/fwd/engine.py, and the tests). The MIT neighbours in sdpa/fwd are pre-existing files this PR only edits, and editing does not move a file between licenses. Also switches to the SPDX-FileCopyrightText form the Apache-2.0 files use. * Compress the comments this PR adds Six blocks broke the house rule that a call site explains only the non-obvious load-bearing fact and rationale/measurements go in the MR description -- which is where all of this already was, so it was duplicated, not lost. Cut: measurement detail from _sm120_tiles (1.5x at 64 CTAs, 240-vs-320 CTAs, 2-4%, 106 KB vs 99) down to a pointer at PR #528, keeping the two thresholds a reader needs and the warning that the rule is kernel-specific. _MEASURED_BEHIND lost two antitheses ("deliberate but NOT a measurement", "an experiment, not an edit") and a cross-reference the module docstring already makes. _owners_for_id, _create_backend_plans and the backend-dedup comment lost restated clauses. BaseEngine's note on the deleted id range stopped narrating the deletion -- that belongs to the commit that made it, where it is verbatim. 31 fewer added lines, 8 fewer comment lines; no claim, number or caveat dropped, only relocated to where it was already written. 199 passed; the one failure is the pre-existing test_a_replayed_plan_reports_its_own_notes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Relicenses NVIDIA-authored code in cudnn-frontend from MIT to the Apache License 2.0, using the exact NVIDIA OSS SPDX header. Files that still carry contributions from external contributors whose permission has not been established remain under MIT. Rebased onto current
develop(b950af1).License assignment
Every source file carries an SPDX
SPDX-License-Identifier:tag.Per-file mapping — including the commit that introduced each surviving external line — is in LICENSING.md.
How the split is computed
Blame-based, not touch-based. A file stays MIT only if a not-yet-cleared external contributor's lines survive in current
develop. Files whose external lines were fully overwritten by NVIDIA, or whose contributors are cleared, go to Apache-2.0.Licensing files
license = "Apache-2.0 AND MIT"), README.mdVerification
py_compile);git diff -U0confirms every source change is comment/header-only — compile-neutral by construction🤖 Generated with Claude Code