File size: 2,865 Bytes
c556874
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""Prepare a local RGB-only inference adapter; preserve source/patch provenance."""
import ast
import difflib
import hashlib
import json
import subprocess
from pathlib import Path

ROOT=Path(__file__).resolve().parent
SOL=ROOT/'behavior-1k-solution'
ARCHIVE=Path('/home/eai/Documents/Codex/2026-09-18/b1k-chat-part1-b1k-gui-jsonl/work/source')
patches=[]
for name in ['src/b1k/models/pi_behavior.py','src/b1k/models/pi_behavior_config.py']:
    src=(ARCHIVE/name).read_text()
    out=src
    if name.endswith('/pi_behavior.py'):
        out=out.replace('from b1k.models import spatial_da3 as _spatial_da3\n','')
        start=out.index('                spatial_inject=spatial_inject,')
        end=out.index('            )\n', start)
        out=out[:start]+out[end:]
        out=out.replace('        self.config = config\n', '        self.config = config\n        assert config.da3 is None and not config.use_spatial_action_cross_attention and not config.use_skill_conditioning, "RGB-only evaluation adapter"\n',1)
        out=out.replace(', banks=_prefix_banks)', ')')
        out='\n'.join(x for x in out.split('\n') if x.strip() not in {'banks=_prefix_banks,','banks=spatial_banks,'})
        marker='        L = self.action_correlation_cholesky.value\n        Sigma = L @ L.T'
        out=out.replace(marker,"        if hasattr(self, '_eval_correction'):\n            assert O_indices.shape == (128,) and U_indices.shape == (832,)\n            return {'O_indices': O_indices, 'U_indices': U_indices, 'correction_matrix': self._eval_correction.value}\n\n"+marker)
    ast.parse(out)
    (SOL/name).write_text(out)
    patches.extend(difflib.unified_diff(src.splitlines(True),out.splitlines(True),fromfile='archived/'+name,tofile='runtime/'+name))
for name in ['src/b1k/policies/b1k_policy.py','src/b1k/shared/eval_b1k_wrapper.py']:
    p=SOL/name
    src=subprocess.check_output(['git','-C',str(SOL),'show','HEAD:'+name],text=True)
    out=src.replace('from omnigibson.learning.utils.eval_utils import PROPRIOCEPTION_INDICES','from b1k_eval_contract import PROPRIOCEPTION_INDICES')
    p.write_text(out)
    patches.extend(difflib.unified_diff(src.splitlines(True),out.splitlines(True),fromfile='upstream/'+name,tofile='runtime/'+name))
# Copy exact evaluator proprioception constant without importing the simulator in the policy process.
p=Path('/home/eai/code/b1k/OmniGibson/omnigibson/eval/utils/eval_utils.py')
src=p.read_text(); tree=ast.parse(src)
node=next(n for n in tree.body if isinstance(n,ast.Assign) and any(isinstance(t,ast.Name) and t.id=='PROPRIOCEPTION_INDICES' for t in n.targets))
(ROOT/'b1k_eval_contract.py').write_text('from collections import OrderedDict\nimport numpy as np\n'+ast.get_source_segment(src,node)+'\n')
(ROOT/'runtime_adapter.patch').write_text(''.join(patches))
print('Prepared no-DA3 runtime and recorded adapter patch.')