finir 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- finir-0.1.0/.gitignore +48 -0
- finir-0.1.0/CHANGELOG.md +55 -0
- finir-0.1.0/CITATION.cff +23 -0
- finir-0.1.0/LICENSE +201 -0
- finir-0.1.0/NOTICE +15 -0
- finir-0.1.0/PKG-INFO +258 -0
- finir-0.1.0/README.md +214 -0
- finir-0.1.0/benchmarks/README.md +27 -0
- finir-0.1.0/benchmarks/results/benchmark_results.json +73 -0
- finir-0.1.0/benchmarks/run_benchmarks.py +71 -0
- finir-0.1.0/docs/README.md +34 -0
- finir-0.1.0/docs/agent-integration.md +62 -0
- finir-0.1.0/docs/architecture.md +50 -0
- finir-0.1.0/docs/backends.md +49 -0
- finir-0.1.0/docs/caching.md +46 -0
- finir-0.1.0/docs/compiler.md +47 -0
- finir-0.1.0/docs/extending.md +64 -0
- finir-0.1.0/docs/financial-semantics.md +55 -0
- finir-0.1.0/docs/huggingface-intent-handoff.md +161 -0
- finir-0.1.0/docs/intent-contract.md +176 -0
- finir-0.1.0/docs/ir.md +62 -0
- finir-0.1.0/docs/kernels.md +53 -0
- finir-0.1.0/docs/performance.md +60 -0
- finir-0.1.0/docs/pypi-release.md +105 -0
- finir-0.1.0/docs/release-checklist.md +42 -0
- finir-0.1.0/docs/release-notes-0.1.0.md +53 -0
- finir-0.1.0/docs/runtime.md +53 -0
- finir-0.1.0/docs/scenarios.md +61 -0
- finir-0.1.0/docs/type-system.md +52 -0
- finir-0.1.0/examples/README.md +19 -0
- finir-0.1.0/examples/agent_financial_reasoning/run.py +53 -0
- finir-0.1.0/examples/company_model/model.finir +19 -0
- finir-0.1.0/examples/company_model/run.py +77 -0
- finir-0.1.0/pyproject.toml +151 -0
- finir-0.1.0/research/experiment_001_incremental_financial_reasoning.md +99 -0
- finir-0.1.0/research/experiment_002_backend_dispatch.md +65 -0
- finir-0.1.0/research/prior_art.md +162 -0
- finir-0.1.0/research/reproduce_experiment_001.py +144 -0
- finir-0.1.0/research/reproduce_experiment_002.py +84 -0
- finir-0.1.0/research/results_001.json +82 -0
- finir-0.1.0/research/results_002.json +45 -0
- finir-0.1.0/schemas/finir-intent-v1.schema.json +160 -0
- finir-0.1.0/src/finir/__init__.py +64 -0
- finir-0.1.0/src/finir/backends/__init__.py +19 -0
- finir-0.1.0/src/finir/backends/base.py +67 -0
- finir-0.1.0/src/finir/backends/dispatch.py +64 -0
- finir-0.1.0/src/finir/backends/gpu.py +63 -0
- finir-0.1.0/src/finir/backends/numpy_backend.py +39 -0
- finir-0.1.0/src/finir/benchmark/__init__.py +14 -0
- finir-0.1.0/src/finir/benchmark/incremental.py +68 -0
- finir-0.1.0/src/finir/benchmark/scenario_bench.py +51 -0
- finir-0.1.0/src/finir/benchmark/synthetic.py +43 -0
- finir-0.1.0/src/finir/cli/__init__.py +13 -0
- finir-0.1.0/src/finir/cli/main.py +229 -0
- finir-0.1.0/src/finir/compiler/__init__.py +17 -0
- finir-0.1.0/src/finir/compiler/passes.py +329 -0
- finir-0.1.0/src/finir/exceptions.py +68 -0
- finir-0.1.0/src/finir/graphviz.py +72 -0
- finir-0.1.0/src/finir/intent/__init__.py +48 -0
- finir-0.1.0/src/finir/intent/compiler.py +142 -0
- finir-0.1.0/src/finir/intent/execute.py +117 -0
- finir-0.1.0/src/finir/intent/finir-intent-v1.schema.json +160 -0
- finir-0.1.0/src/finir/intent/schema.py +277 -0
- finir-0.1.0/src/finir/ir/__init__.py +33 -0
- finir-0.1.0/src/finir/ir/expr.py +98 -0
- finir-0.1.0/src/finir/ir/module.py +176 -0
- finir-0.1.0/src/finir/ir/parser.py +199 -0
- finir-0.1.0/src/finir/ir/serialize.py +102 -0
- finir-0.1.0/src/finir/ir/textual.py +24 -0
- finir-0.1.0/src/finir/ir/typeinfer.py +61 -0
- finir-0.1.0/src/finir/ir/validate.py +27 -0
- finir-0.1.0/src/finir/kernels/__init__.py +23 -0
- finir-0.1.0/src/finir/kernels/arithmetic.py +53 -0
- finir-0.1.0/src/finir/kernels/corporate.py +67 -0
- finir-0.1.0/src/finir/kernels/registry.py +141 -0
- finir-0.1.0/src/finir/kernels/risk.py +62 -0
- finir-0.1.0/src/finir/kernels/tvm.py +122 -0
- finir-0.1.0/src/finir/kernels/working_capital.py +60 -0
- finir-0.1.0/src/finir/model.py +290 -0
- finir-0.1.0/src/finir/numerics.py +75 -0
- finir-0.1.0/src/finir/runtime/__init__.py +18 -0
- finir-0.1.0/src/finir/runtime/cache.py +70 -0
- finir-0.1.0/src/finir/runtime/engine.py +304 -0
- finir-0.1.0/src/finir/runtime/scenario.py +52 -0
- finir-0.1.0/src/finir/runtime/state.py +55 -0
- finir-0.1.0/src/finir/stdlib/__init__.py +20 -0
- finir-0.1.0/src/finir/stdlib/accounting.py +17 -0
- finir-0.1.0/src/finir/stdlib/corporate.py +17 -0
- finir-0.1.0/src/finir/stdlib/risk.py +12 -0
- finir-0.1.0/src/finir/stdlib/unit_economics.py +19 -0
- finir-0.1.0/src/finir/stdlib/valuation.py +16 -0
- finir-0.1.0/src/finir/stdlib/working_capital.py +15 -0
- finir-0.1.0/src/finir/types.py +252 -0
- finir-0.1.0/src/finir/version.py +8 -0
- finir-0.1.0/tests/fixtures/intents/ambiguous_missing_value.json +6 -0
- finir-0.1.0/tests/fixtures/intents/invalid_currency.json +7 -0
- finir-0.1.0/tests/fixtures/intents/invalid_type.json +7 -0
- finir-0.1.0/tests/fixtures/intents/unsupported_operation.json +6 -0
- finir-0.1.0/tests/fixtures/intents/valid_absolute_change.json +7 -0
- finir-0.1.0/tests/fixtures/intents/valid_multi_operation.json +9 -0
- finir-0.1.0/tests/fixtures/intents/valid_relative_change.json +7 -0
- finir-0.1.0/tests/fixtures/intents/valid_scenario.json +12 -0
- finir-0.1.0/tests/fixtures/intents/valid_set_days.json +7 -0
- finir-0.1.0/tests/test_cli.py +74 -0
- finir-0.1.0/tests/test_compiler.py +56 -0
- finir-0.1.0/tests/test_intent_contract.py +188 -0
- finir-0.1.0/tests/test_ir.py +88 -0
- finir-0.1.0/tests/test_kernels.py +59 -0
- finir-0.1.0/tests/test_model_and_misc.py +100 -0
- finir-0.1.0/tests/test_runtime.py +97 -0
- finir-0.1.0/tests/test_types.py +65 -0
finir-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
*.egg
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
.eggs/
|
|
9
|
+
.installed.cfg
|
|
10
|
+
pip-wheel-metadata/
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
ENV/
|
|
17
|
+
|
|
18
|
+
# Testing / coverage
|
|
19
|
+
.pytest_cache/
|
|
20
|
+
.mypy_cache/
|
|
21
|
+
.ruff_cache/
|
|
22
|
+
.coverage
|
|
23
|
+
.coverage.*
|
|
24
|
+
coverage.xml
|
|
25
|
+
htmlcov/
|
|
26
|
+
|
|
27
|
+
# Local databases / runtime artifacts
|
|
28
|
+
*.db
|
|
29
|
+
*.sqlite
|
|
30
|
+
*.sqlite3
|
|
31
|
+
eif.db
|
|
32
|
+
data/
|
|
33
|
+
.eif/
|
|
34
|
+
|
|
35
|
+
# Secrets & environment
|
|
36
|
+
.env
|
|
37
|
+
.env.*
|
|
38
|
+
!.env.example
|
|
39
|
+
|
|
40
|
+
# Editors / OS
|
|
41
|
+
.idea/
|
|
42
|
+
.vscode/
|
|
43
|
+
*.swp
|
|
44
|
+
.DS_Store
|
|
45
|
+
Thumbs.db
|
|
46
|
+
|
|
47
|
+
# Docs build
|
|
48
|
+
site/
|
finir-0.1.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to FinIR are documented here. Format based on
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versioning follows
|
|
5
|
+
[SemVer](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-08-31
|
|
8
|
+
|
|
9
|
+
First release of **FinIR** — a financial intermediate representation and incremental
|
|
10
|
+
execution runtime for AI systems.
|
|
11
|
+
|
|
12
|
+
> This repository previously hosted a different project (an economic-event
|
|
13
|
+
> framework). That direction has been **retired**; FinIR is a new project with a new
|
|
14
|
+
> purpose. No results from the previous project are carried over or presented as
|
|
15
|
+
> FinIR results.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **Financial IR** (`finir.ir`): typed computation modules with an expression AST, a
|
|
20
|
+
`.finir` textual format, a parser, a lossless JSON interchange format, and a
|
|
21
|
+
validator.
|
|
22
|
+
- **Finance-aware type system** (`finir.types`): `money[CCY]`, `percentage`, `ratio`,
|
|
23
|
+
`days`, `quantity`, `rate`, `series`, `scenario`, `scalar`, `bool`, with a compile-
|
|
24
|
+
time algebra (e.g. `money/money → ratio`; `money + days` and `USD + ZAR` are errors).
|
|
25
|
+
- **Compiler passes** (`finir.compiler`): validation, type checking, constant
|
|
26
|
+
folding, common-subexpression elimination, dead-node elimination, dependency
|
|
27
|
+
pruning, scenario-vectorization analysis, fusion analysis, cache planning.
|
|
28
|
+
- **Incremental runtime** (`finir.runtime`): dependency-aware engine that recomputes
|
|
29
|
+
only a changed input's downstream cone and reuses the rest in O(1); computation
|
|
30
|
+
cache with hit/reuse metrics; versioned `ModelState` snapshots.
|
|
31
|
+
- **Scenario engine**: `what_if`, named `scenarios`, and vectorized `run_scenarios`
|
|
32
|
+
over million-row batches.
|
|
33
|
+
- **Backends** (`finir.backends`): reference/vectorized CPU (NumPy) and an optional
|
|
34
|
+
GPU backend (CuPy), with a workload-aware dispatch planner.
|
|
35
|
+
- **Kernel library** (`finir.kernels`): arithmetic, corporate finance, working
|
|
36
|
+
capital, time-value-of-money, and basic risk — plus a `@finir.kernel` extension
|
|
37
|
+
point.
|
|
38
|
+
- **Standard library** (`finir.stdlib`): income-statement, working-capital,
|
|
39
|
+
operating-model, DCF, risk, and SaaS unit-economics templates.
|
|
40
|
+
- **Agent integration**: structured-intent `apply_intent` and an optional
|
|
41
|
+
`IntentCompiler` interface with a dependency-free `MockIntentCompiler`.
|
|
42
|
+
- **CLI** (`finir`): `run`, `compile`, `inspect`, `graph`, `benchmark`, `doctor`,
|
|
43
|
+
`version`.
|
|
44
|
+
- **Graph export**: Graphviz DOT and JSON.
|
|
45
|
+
- **Safe numerics**: configurable division-by-zero / non-finite handling; Decimal
|
|
46
|
+
path for money-sensitive scalar math.
|
|
47
|
+
- **Benchmarks** (`benchmarks/`, `finir.benchmark`): incremental-vs-recompute and
|
|
48
|
+
scenario-batch suites that write real results with hardware metadata.
|
|
49
|
+
- **Research**: Experiment 001 (incremental financial reasoning), Experiment 002
|
|
50
|
+
(backend dispatch), and a critical prior-art analysis.
|
|
51
|
+
- **Docs** (`docs/`): architecture, IR, type system, compiler, runtime, caching,
|
|
52
|
+
scenarios, kernels, financial semantics, backends, agent integration, performance,
|
|
53
|
+
extending.
|
|
54
|
+
|
|
55
|
+
[0.1.0]: https://github.com/Olyxee/finir/releases/tag/v0.1.0
|
finir-0.1.0/CITATION.cff
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use FinIR in your research, please cite it as below."
|
|
3
|
+
title: "FinIR: a financial intermediate representation and incremental execution runtime"
|
|
4
|
+
abstract: >-
|
|
5
|
+
FinIR is a compiler target and runtime for financial computation generated or
|
|
6
|
+
consumed by AI systems: a typed financial intermediate representation with
|
|
7
|
+
dependency-aware incremental execution, a finance-native cache, a scenario engine,
|
|
8
|
+
and workload-aware CPU/GPU dispatch.
|
|
9
|
+
type: software
|
|
10
|
+
authors:
|
|
11
|
+
- name: "FinIR Contributors"
|
|
12
|
+
version: 0.1.0
|
|
13
|
+
date-released: 2026-08-31
|
|
14
|
+
license: Apache-2.0
|
|
15
|
+
repository-code: "https://github.com/Olyxee/finir"
|
|
16
|
+
url: "https://github.com/Olyxee/finir"
|
|
17
|
+
keywords:
|
|
18
|
+
- financial computation
|
|
19
|
+
- intermediate representation
|
|
20
|
+
- compiler
|
|
21
|
+
- incremental computation
|
|
22
|
+
- scenario analysis
|
|
23
|
+
- ai infrastructure
|
finir-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 EIF Contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
finir-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
FinIR
|
|
2
|
+
Copyright 2026 FinIR Contributors
|
|
3
|
+
|
|
4
|
+
This product includes software developed as an open financial intermediate
|
|
5
|
+
representation and incremental execution runtime for AI systems.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
|
8
|
+
software except in compliance with the License. You may obtain a copy of the License
|
|
9
|
+
at http://www.apache.org/licenses/LICENSE-2.0.
|
|
10
|
+
|
|
11
|
+
Early research exploration was inspired by omni-modal scientific-reasoning systems
|
|
12
|
+
(including work such as OmniScientist). FinIR is an independent project and contains
|
|
13
|
+
no OmniScientist code, nor does it depend on OmniScientist at runtime.
|
|
14
|
+
|
|
15
|
+
All example and benchmark data in this repository is synthetic.
|
finir-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: finir
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A financial intermediate representation and incremental execution runtime for AI systems.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Olyxee/finir
|
|
6
|
+
Project-URL: Repository, https://github.com/Olyxee/finir
|
|
7
|
+
Project-URL: Documentation, https://github.com/Olyxee/finir/tree/main/docs
|
|
8
|
+
Project-URL: Changelog, https://github.com/Olyxee/finir/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Issues, https://github.com/Olyxee/finir/issues
|
|
10
|
+
Author: FinIR Contributors
|
|
11
|
+
Maintainer: Olyxee
|
|
12
|
+
License: Apache-2.0
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
License-File: NOTICE
|
|
15
|
+
Keywords: ai-infrastructure,compiler,financial-computation,incremental-computation,intermediate-representation,scenario-analysis
|
|
16
|
+
Classifier: Development Status :: 3 - Alpha
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
19
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
24
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.11
|
|
27
|
+
Requires-Dist: numpy>=1.26
|
|
28
|
+
Requires-Dist: rich>=13.7
|
|
29
|
+
Requires-Dist: typer>=0.12
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
32
|
+
Requires-Dist: jsonschema>=4.21; extra == 'dev'
|
|
33
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
34
|
+
Requires-Dist: pre-commit>=3.7; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest>=8.1; extra == 'dev'
|
|
37
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
38
|
+
Requires-Dist: twine>=5.0; extra == 'dev'
|
|
39
|
+
Provides-Extra: gpu
|
|
40
|
+
Requires-Dist: cupy-cuda12x>=13.0; extra == 'gpu'
|
|
41
|
+
Provides-Extra: viz
|
|
42
|
+
Requires-Dist: graphviz>=0.20; extra == 'viz'
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# FinIR
|
|
46
|
+
|
|
47
|
+
**A financial intermediate representation and incremental execution runtime for AI systems.**
|
|
48
|
+
|
|
49
|
+
AI systems increasingly reason about finance, but their numerical execution still
|
|
50
|
+
falls back to generated Python, spreadsheets, SQL, or generic tensor frameworks.
|
|
51
|
+
FinIR gives financial reasoning a dedicated compiler target.
|
|
52
|
+
|
|
53
|
+
<img width="1774" height="887" alt="image" src="https://github.com/user-attachments/assets/20298bac-2d01-4b65-8b83-01643e500851" />
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
[](https://github.com/Olyxee/finir/actions/workflows/ci.yml)
|
|
57
|
+
License: Apache-2.0 · Python 3.11+ · CPU-first, optional GPU
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
Financial Intent
|
|
61
|
+
↓
|
|
62
|
+
FinIR
|
|
63
|
+
↓
|
|
64
|
+
Dependency Analysis
|
|
65
|
+
↓
|
|
66
|
+
Incremental Execution
|
|
67
|
+
↓
|
|
68
|
+
CPU / SIMD / GPU
|
|
69
|
+
↓
|
|
70
|
+
Financial Result
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Install
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install finir
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
python -c "import finir; print(finir.__version__)"
|
|
81
|
+
finir --help
|
|
82
|
+
finir doctor
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
CPU-first: `pip install finir` needs no GPU. Optional extras: `pip install "finir[gpu]"`
|
|
86
|
+
(CuPy GPU backend), `pip install "finir[viz]"` (Graphviz SVG rendering). Develop from
|
|
87
|
+
source with `git clone https://github.com/Olyxee/finir && cd finir && pip install -e ".[dev]"`.
|
|
88
|
+
|
|
89
|
+
## Quick start
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from finir import FinancialModel
|
|
93
|
+
|
|
94
|
+
model = FinancialModel()
|
|
95
|
+
|
|
96
|
+
model.input("revenue", 500_000_000, currency="ZAR")
|
|
97
|
+
model.input("cogs", 300_000_000, currency="ZAR")
|
|
98
|
+
model.input("opex", 120_000_000, currency="ZAR")
|
|
99
|
+
|
|
100
|
+
model.define("gross_profit", "revenue - cogs")
|
|
101
|
+
model.define("ebitda", "gross_profit - opex")
|
|
102
|
+
|
|
103
|
+
model.evaluate()
|
|
104
|
+
|
|
105
|
+
scenario = model.what_if(cogs="+4%")
|
|
106
|
+
|
|
107
|
+
print(scenario["ebitda"])
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Change one assumption and FinIR recomputes **only the affected part of the graph**:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
Input changed:
|
|
114
|
+
COGS
|
|
115
|
+
|
|
116
|
+
Recomputed:
|
|
117
|
+
COGS → Gross Profit → EBITDA → Gross Margin → Cash Flow
|
|
118
|
+
|
|
119
|
+
Reused (from cache):
|
|
120
|
+
Revenue, Payroll, Debt, Receivables, ...
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Why FinIR
|
|
124
|
+
|
|
125
|
+
When an AI needs to compute *"increase supplier costs 7% and extend payment terms
|
|
126
|
+
30→60 days,"* it usually translates that into arbitrary generated code — inefficient,
|
|
127
|
+
non-deterministic, unaudited, and recomputed from scratch every turn. FinIR replaces
|
|
128
|
+
that with a standard boundary:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
financial intent → FinIR → deterministic, incremental financial execution
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
It understands financial semantics (revenue, COGS, gross margin, EBITDA, working
|
|
135
|
+
capital, receivables/payables, free cash flow, NPV, unit economics, payment terms,
|
|
136
|
+
…) and their computational dependencies — so it can recompute only what changed and
|
|
137
|
+
reuse the rest.
|
|
138
|
+
|
|
139
|
+
## What is a Financial IR?
|
|
140
|
+
|
|
141
|
+
A typed computation graph with a finance-native type system:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
revenue = input money[ZAR]
|
|
145
|
+
cogs = input money[ZAR]
|
|
146
|
+
gross_profit = revenue - cogs : money[ZAR]
|
|
147
|
+
gross_margin = gross_profit / revenue : ratio
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
`money - money → money` (same currency, else an error); `money / money → ratio`;
|
|
151
|
+
`money + days` is a type error. See [docs/ir.md](https://github.com/Olyxee/finir/blob/main/docs/ir.md) and
|
|
152
|
+
[docs/type-system.md](https://github.com/Olyxee/finir/blob/main/docs/type-system.md).
|
|
153
|
+
|
|
154
|
+
## Architecture
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
Agent / Developer API → FinIR Builder → Financial IR → Compiler Passes
|
|
158
|
+
→ Execution Plan → Incremental Runtime → Kernel Backend → CPU / SIMD / GPU
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Each layer is cleanly separated. See [docs/architecture.md](https://github.com/Olyxee/finir/blob/main/docs/architecture.md).
|
|
162
|
+
|
|
163
|
+
## Incremental execution
|
|
164
|
+
|
|
165
|
+
Changing one input invalidates only its downstream cone; the next evaluation
|
|
166
|
+
recomputes exactly those nodes and reuses everything else in O(1). This is FinIR's
|
|
167
|
+
reason to exist — see [docs/runtime.md](https://github.com/Olyxee/finir/blob/main/docs/runtime.md) and
|
|
168
|
+
[docs/caching.md](https://github.com/Olyxee/finir/blob/main/docs/caching.md).
|
|
169
|
+
|
|
170
|
+
## Scenario engine
|
|
171
|
+
|
|
172
|
+
`what_if`, named `scenarios`, and vectorized `run_scenarios` over million-row
|
|
173
|
+
batches. See [docs/scenarios.md](https://github.com/Olyxee/finir/blob/main/docs/scenarios.md).
|
|
174
|
+
|
|
175
|
+
## Financial types
|
|
176
|
+
|
|
177
|
+
`money[CCY]`, `percentage`, `ratio`, `days`, `quantity`, `rate`, `series`,
|
|
178
|
+
`scenario`, `scalar`, `bool` — enforced at compile time. See
|
|
179
|
+
[docs/type-system.md](https://github.com/Olyxee/finir/blob/main/docs/type-system.md).
|
|
180
|
+
|
|
181
|
+
## Kernels
|
|
182
|
+
|
|
183
|
+
Arithmetic, corporate finance, working capital, time-value-of-money, and basic risk
|
|
184
|
+
— plus a `@finir.kernel` extension point. Deliberately small (not a quant library).
|
|
185
|
+
See [docs/kernels.md](https://github.com/Olyxee/finir/blob/main/docs/kernels.md).
|
|
186
|
+
|
|
187
|
+
## Compiler passes
|
|
188
|
+
|
|
189
|
+
Validation, type checking, constant folding, CSE, dead-node elimination, dependency
|
|
190
|
+
pruning, scenario vectorization, fusion analysis, cache planning. Inspect with
|
|
191
|
+
`finir compile model.finir --show-passes`. See [docs/compiler.md](https://github.com/Olyxee/finir/blob/main/docs/compiler.md).
|
|
192
|
+
|
|
193
|
+
## Agent integration
|
|
194
|
+
|
|
195
|
+
Core FinIR consumes **structured** intent (`apply_intent`); natural-language
|
|
196
|
+
interpretation is an optional `IntentCompiler` layer (a dependency-free
|
|
197
|
+
`MockIntentCompiler` ships for offline use). The model interprets; the runtime
|
|
198
|
+
computes. See [docs/agent-integration.md](https://github.com/Olyxee/finir/blob/main/docs/agent-integration.md).
|
|
199
|
+
|
|
200
|
+
## CPU / GPU dispatch
|
|
201
|
+
|
|
202
|
+
CPU-first and fully usable with no optional dependencies. A workload-aware planner
|
|
203
|
+
sends very large scenario batches to an optional CuPy GPU backend when present. See
|
|
204
|
+
[docs/backends.md](https://github.com/Olyxee/finir/blob/main/docs/backends.md).
|
|
205
|
+
|
|
206
|
+
## Benchmarks
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
finir benchmark --full
|
|
210
|
+
python benchmarks/run_benchmarks.py # writes benchmarks/results/
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
On the reference machine: **1.7×–2.2× faster** iterative reasoning vs. full
|
|
214
|
+
recompute (up to 99.6% cache hits), and ~1,000,000 scenarios in ~46 ms on CPU. All
|
|
215
|
+
numbers are measured, never hard-coded. See [docs/performance.md](https://github.com/Olyxee/finir/blob/main/docs/performance.md).
|
|
216
|
+
|
|
217
|
+
## Research
|
|
218
|
+
|
|
219
|
+
- [research/experiment_001_incremental_financial_reasoning.md](https://github.com/Olyxee/finir/blob/main/research/experiment_001_incremental_financial_reasoning.md) — incremental vs. full recompute
|
|
220
|
+
- [research/experiment_002_backend_dispatch.md](https://github.com/Olyxee/finir/blob/main/research/experiment_002_backend_dispatch.md) — CPU/GPU crossover (GPU unverified locally)
|
|
221
|
+
- [research/prior_art.md](https://github.com/Olyxee/finir/blob/main/research/prior_art.md) — critical positioning vs. spreadsheets, incremental-computation systems, JAX/XLA/MLIR, QuantLib, planning engines, and more
|
|
222
|
+
|
|
223
|
+
We do **not** claim FinIR is a first or a breakthrough. The working hypothesis —
|
|
224
|
+
that there is no widely-adopted open finance-specific IR designed as the execution
|
|
225
|
+
boundary between AI financial intent and incremental computation — remains a
|
|
226
|
+
hypothesis pending a formal prior-art review.
|
|
227
|
+
|
|
228
|
+
## Extending FinIR
|
|
229
|
+
|
|
230
|
+
Custom kernels, backends, and templates; a stable JSON IR for other-language
|
|
231
|
+
bindings. See [docs/extending.md](https://github.com/Olyxee/finir/blob/main/docs/extending.md).
|
|
232
|
+
|
|
233
|
+
## Roadmap
|
|
234
|
+
|
|
235
|
+
- Larger real-model benchmarks and agent-trace evaluation.
|
|
236
|
+
- Measured GPU dispatch thresholds on CUDA hardware.
|
|
237
|
+
- Optional lowering onto a tensor compiler (XLA/MLIR) for very large graphs.
|
|
238
|
+
- Language bindings (TypeScript/Rust) over the JSON IR.
|
|
239
|
+
- Autodiff / sensitivities as an optional layer.
|
|
240
|
+
|
|
241
|
+
## Contributing
|
|
242
|
+
|
|
243
|
+
See [CONTRIBUTING.md](https://github.com/Olyxee/finir/blob/main/CONTRIBUTING.md). Quality gates: `ruff check .`,
|
|
244
|
+
`ruff format --check .`, `mypy src`, `pytest`. CPU-only; no network for core tests.
|
|
245
|
+
|
|
246
|
+
## Citation
|
|
247
|
+
|
|
248
|
+
See [CITATION.cff](https://github.com/Olyxee/finir/blob/main/CITATION.cff).
|
|
249
|
+
|
|
250
|
+
## Acknowledgements
|
|
251
|
+
|
|
252
|
+
Early research exploration was inspired by omni-modal scientific-reasoning systems
|
|
253
|
+
(including work such as OmniScientist). FinIR is **independent**: no OmniScientist
|
|
254
|
+
code and no runtime dependency on it.
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
Apache-2.0 — see [LICENSE](https://github.com/Olyxee/finir/blob/main/LICENSE).
|