topoexploit 0.1.0__py3-none-any.whl
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.
- topoexploit-0.1.0.dist-info/METADATA +523 -0
- topoexploit-0.1.0.dist-info/RECORD +23 -0
- topoexploit-0.1.0.dist-info/WHEEL +5 -0
- topoexploit-0.1.0.dist-info/entry_points.txt +6 -0
- topoexploit-0.1.0.dist-info/licenses/LICENSE +661 -0
- topoexploit-0.1.0.dist-info/top_level.txt +1 -0
- topogpt3/__init__.py +125 -0
- topogpt3/__main__.py +49 -0
- topogpt3/api_server.py +1178 -0
- topogpt3/continuation.py +114 -0
- topogpt3/ewc.py +369 -0
- topogpt3/exploitgym_config.py +130 -0
- topogpt3/exploitgym_loader.py +416 -0
- topogpt3/hodge_cm.py +160 -0
- topogpt3/inference.py +731 -0
- topogpt3/inference_hrm.py +1502 -0
- topogpt3/jlens.py +958 -0
- topogpt3/lens_model.py +389 -0
- topogpt3/merged_config.py +187 -0
- topogpt3/model.py +3824 -0
- topogpt3/structured_output.py +251 -0
- topogpt3/train.py +1939 -0
- topogpt3/vanilla_control.py +240 -0
topogpt3/__init__.py
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""TopoGPT3: complex-valued spectral language model for code.
|
|
2
|
+
|
|
3
|
+
This package bundles:
|
|
4
|
+
|
|
5
|
+
- ``topogpt3.model``: the base TopoGPT2 architecture (quaternion spectral
|
|
6
|
+
layers, BPE tokenizer, helpers).
|
|
7
|
+
- ``topogpt3.train``: the curriculum trainer with Grassmannian / Fisher /
|
|
8
|
+
phase diagnostics.
|
|
9
|
+
- ``topogpt3.inference``: a standard autoregressive sampler that loads a
|
|
10
|
+
trained safetensors checkpoint.
|
|
11
|
+
- ``topogpt3.inference_hrm``: a hierarchical recursive reasoning sampler
|
|
12
|
+
that reuses the same checkpoint with no extra trained parameters.
|
|
13
|
+
- ``topogpt3.lens_model``: the Jacobian-lens model adapter (LensModel
|
|
14
|
+
protocol + TopoGPT3LensModel wrapper).
|
|
15
|
+
- ``topogpt3.jlens``: Jacobian lens fitting, application, and the
|
|
16
|
+
ActivationRecorder / JacobianLens infrastructure.
|
|
17
|
+
|
|
18
|
+
Typical usage from a downstream project::
|
|
19
|
+
|
|
20
|
+
from topogpt3 import InferenceSettings, InferencePipeline
|
|
21
|
+
|
|
22
|
+
settings = InferenceSettings(
|
|
23
|
+
checkpoint_dir="checkpoints_topogpt3",
|
|
24
|
+
prompt="def fibonacci(",
|
|
25
|
+
max_new_tokens=200,
|
|
26
|
+
)
|
|
27
|
+
InferencePipeline(settings).execute()
|
|
28
|
+
|
|
29
|
+
Jacobian lens usage::
|
|
30
|
+
|
|
31
|
+
from topogpt3.lens_model import TopoGPT3LensModel
|
|
32
|
+
from topogpt3.jlens import fit, JacobianLens
|
|
33
|
+
|
|
34
|
+
model = TopoGPT3LensModel.from_checkpoint("checkpoints_topogpt3/last")
|
|
35
|
+
lens = fit(model, prompts, source_layers=[0, 1, 2, 3, 4])
|
|
36
|
+
lens_logits, model_logits, input_ids = lens.apply(model, "def hello(")
|
|
37
|
+
"""
|
|
38
|
+
from __future__ import annotations
|
|
39
|
+
|
|
40
|
+
__version__ = "0.1.0"
|
|
41
|
+
|
|
42
|
+
from .model import (
|
|
43
|
+
BPETokenizer,
|
|
44
|
+
QuaternionSpectralLayer,
|
|
45
|
+
SpectralAutoencoder,
|
|
46
|
+
TopoGPT2,
|
|
47
|
+
TopoGPT2Config,
|
|
48
|
+
set_seed,
|
|
49
|
+
setup_logger,
|
|
50
|
+
)
|
|
51
|
+
from .train import (
|
|
52
|
+
CheckpointStore,
|
|
53
|
+
CodeCurriculumLoader,
|
|
54
|
+
GrassmannianTracker,
|
|
55
|
+
TopoGPT3Config,
|
|
56
|
+
TopoGPT3Trainer,
|
|
57
|
+
apply_gauss_patch,
|
|
58
|
+
)
|
|
59
|
+
from .merged_config import TopoMergedConfig
|
|
60
|
+
from .inference import (
|
|
61
|
+
GenerationReport,
|
|
62
|
+
InferencePipeline,
|
|
63
|
+
InferenceSettings,
|
|
64
|
+
SamplingPolicy,
|
|
65
|
+
)
|
|
66
|
+
from .inference_hrm import (
|
|
67
|
+
GenerationReasoningSummary,
|
|
68
|
+
HRMInferencePipeline,
|
|
69
|
+
HRMInferenceSettings,
|
|
70
|
+
HierarchicalRecursiveReasoner,
|
|
71
|
+
RecursiveReasoningConfig,
|
|
72
|
+
)
|
|
73
|
+
from .lens_model import (
|
|
74
|
+
LensModel,
|
|
75
|
+
TinyDecoder,
|
|
76
|
+
TopoGPT3LensConfig,
|
|
77
|
+
TopoGPT3LensModel,
|
|
78
|
+
)
|
|
79
|
+
from .jlens import (
|
|
80
|
+
ActivationRecorder,
|
|
81
|
+
JacobianLens,
|
|
82
|
+
TopoGPT3JLensAppConfig,
|
|
83
|
+
TopoGPT3JLensFitConfig,
|
|
84
|
+
fit,
|
|
85
|
+
jacobian_for_prompt,
|
|
86
|
+
valid_position_mask,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
__all__ = [
|
|
90
|
+
"__version__",
|
|
91
|
+
"ActivationRecorder",
|
|
92
|
+
"BPETokenizer",
|
|
93
|
+
"CheckpointStore",
|
|
94
|
+
"CodeCurriculumLoader",
|
|
95
|
+
"fit",
|
|
96
|
+
"GenerationReasoningSummary",
|
|
97
|
+
"GenerationReport",
|
|
98
|
+
"GrassmannianTracker",
|
|
99
|
+
"HierarchicalRecursiveReasoner",
|
|
100
|
+
"HRMInferencePipeline",
|
|
101
|
+
"HRMInferenceSettings",
|
|
102
|
+
"InferencePipeline",
|
|
103
|
+
"InferenceSettings",
|
|
104
|
+
"jacobian_for_prompt",
|
|
105
|
+
"JacobianLens",
|
|
106
|
+
"LensModel",
|
|
107
|
+
"QuaternionSpectralLayer",
|
|
108
|
+
"RecursiveReasoningConfig",
|
|
109
|
+
"SamplingPolicy",
|
|
110
|
+
"set_seed",
|
|
111
|
+
"setup_logger",
|
|
112
|
+
"SpectralAutoencoder",
|
|
113
|
+
"TinyDecoder",
|
|
114
|
+
"TopoGPT2",
|
|
115
|
+
"TopoGPT2Config",
|
|
116
|
+
"TopoGPT3Config",
|
|
117
|
+
"TopoGPT3JLensAppConfig",
|
|
118
|
+
"TopoGPT3JLensFitConfig",
|
|
119
|
+
"TopoGPT3LensConfig",
|
|
120
|
+
"TopoGPT3LensModel",
|
|
121
|
+
"TopoGPT3Trainer",
|
|
122
|
+
"TopoMergedConfig",
|
|
123
|
+
"apply_gauss_patch",
|
|
124
|
+
"valid_position_mask",
|
|
125
|
+
]
|
topogpt3/__main__.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def main() -> None:
|
|
7
|
+
"""TopoGPT3 entry point. Delegates to subcommands."""
|
|
8
|
+
if len(sys.argv) < 2:
|
|
9
|
+
print(
|
|
10
|
+
"TopoGPT3: complex-valued spectral language model\n"
|
|
11
|
+
"\n"
|
|
12
|
+
"Usage:\n"
|
|
13
|
+
" python3 -m topogpt3 this help\n"
|
|
14
|
+
" python3 -m topogpt3 infer standard autoregressive inference\n"
|
|
15
|
+
" python3 -m topogpt3 infer-hrm HRM recursive reasoning inference\n"
|
|
16
|
+
" python3 -m topogpt3 train curriculum training\n"
|
|
17
|
+
" python3 -m topogpt3 api start API server\n"
|
|
18
|
+
" python3 -m topogpt3 lens test model loading\n"
|
|
19
|
+
" python3 -m topogpt3 jlens Jacobian lens demo\n"
|
|
20
|
+
" python3 -m topogpt3 check quick checkpoint validation\n"
|
|
21
|
+
)
|
|
22
|
+
return
|
|
23
|
+
subcommand = sys.argv[1]
|
|
24
|
+
sys.argv = sys.argv[1:]
|
|
25
|
+
if subcommand in ("jlens", "lens"):
|
|
26
|
+
from .jlens import _demo_jlens
|
|
27
|
+
_demo_jlens()
|
|
28
|
+
elif subcommand == "check":
|
|
29
|
+
from .lens_model import TopoGPT3LensModel
|
|
30
|
+
m = TopoGPT3LensModel.from_checkpoint("checkpoints_topogpt3/last")
|
|
31
|
+
print(f"OK: n_layers={m.n_layers}, d_model={m.d_model}")
|
|
32
|
+
elif subcommand in ("api", "api_server"):
|
|
33
|
+
from .api_server import main as api_main
|
|
34
|
+
api_main()
|
|
35
|
+
elif subcommand in ("infer", "inference"):
|
|
36
|
+
from .inference import main as infer_main
|
|
37
|
+
infer_main()
|
|
38
|
+
elif subcommand in ("infer-hrm", "inference-hrm"):
|
|
39
|
+
from .inference_hrm import main as hrm_main
|
|
40
|
+
hrm_main()
|
|
41
|
+
elif subcommand == "train":
|
|
42
|
+
from .train import main as train_main
|
|
43
|
+
train_main()
|
|
44
|
+
else:
|
|
45
|
+
print(f"Unknown subcommand: {subcommand}")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if __name__ == "__main__":
|
|
49
|
+
main()
|