File size: 28,635 Bytes
a45d99d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80a8599
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a45d99d
 
 
 
 
 
 
 
 
 
 
 
 
80a8599
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a45d99d
80a8599
 
 
 
 
 
 
 
 
 
 
 
 
a45d99d
80a8599
 
 
 
 
 
 
 
a45d99d
80a8599
 
 
 
 
 
 
 
 
 
 
a45d99d
80a8599
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a45d99d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80a8599
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a45d99d
 
80a8599
 
 
 
a45d99d
80a8599
 
 
 
 
 
 
 
a45d99d
 
 
80a8599
a45d99d
 
80a8599
 
 
 
 
a45d99d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80a8599
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a45d99d
 
 
 
 
 
 
 
 
 
 
80a8599
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a45d99d
 
 
 
 
80a8599
 
 
 
 
 
 
 
 
 
a45d99d
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
--- original/compare_parity.py
+++ packaged/compare_parity.py
@@ -4,7 +4,14 @@
 import h5py
 import numpy as np
 
-E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108')
+ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103'
+ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT)  # [packaged] relocatable root, default = original
+E = Path(ROOT)/'evaluation-ck30000-20261108'
+
+
+def L(p):  # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT
+    p = str(p)
+    return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p)
 OLD = E/'cotrain-ck3000-20261114'; P = E/'cotrain-delay-n10-20261115'/'parity'/'parity-d0'
 
 
--- original/evaluate_delayed.py
+++ packaged/evaluate_delayed.py
@@ -12,7 +12,14 @@
 import time
 from pathlib import Path
 
-E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108')
+ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103'
+ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT)  # [packaged] relocatable root, default = original
+E = Path(ROOT)/'evaluation-ck30000-20261108'
+
+
+def L(p):  # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT
+    p = str(p)
+    return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p)
 R = E.parent
 OLD = E/'cotrain-ck3000-20261114'
 N = E/'cotrain-delay-n10-20261115'
@@ -32,6 +39,28 @@
 
 TASKS = {'cup': 'OpenCabinetAndReturnCup', 'spice': 'UncoverAndRetrieveSpice'}
 KEYS = ['observation.images.'+c for c in CAMERAS]
+WRIST = 'robot0_eye_in_hand'
+WRIST_NEAR_DIVISOR = 10  # wrist near plane 0.001*extent (29 mm in these kitchens) -> 2.9 mm
+
+
+# [packaged] same wrist near-plane fix as evaluate_delayed_v2.py (default ON; --no-wrist-near-fix = original rendering)
+def render_frames(env, io, wrist_near_fix):
+    """camera_frames(), except (optionally) the wrist camera is rendered with a 10x closer near plane.
+
+    MuJoCo's near plane is vis.map.znear * stat.extent; the ~29 m kitchen extent puts it at 2.9 cm, so geometry within
+    2.9 cm of the wrist camera is clipped (see-through). The agent-view cameras (the left one is the policy history) are
+    rendered with the unchanged global setting, so they stay bit-identical to camera_frames()."""
+    if not wrist_near_fix:
+        return camera_frames(env, io, KEYS)
+    m = env.sim.model._model; z0 = m.vis.map.znear; frames = {}
+    for key in KEYS:
+        cam = key.split('.')[-1]
+        try:
+            if cam == WRIST: m.vis.map.znear = z0/WRIST_NEAR_DIVISOR
+            frames[key] = np.ascontiguousarray(env.sim.render(width=io['render_width'], height=io['render_height'], camera_name=cam)[::-1])
+        finally:
+            m.vis.map.znear = z0
+    return frames
 
 
 def delayed_recall_success(env, task, chores_done):
@@ -73,7 +102,12 @@
 
 def main():
     p = argparse.ArgumentParser(); p.add_argument('--stage', required=True); p.add_argument('--trial', required=True)
-    p.add_argument('--gpu', type=int, choices=[0, 1], required=True); a = p.parse_args()
+    p.add_argument('--gpu', type=int, choices=[0, 1], required=True)
+    p.add_argument('--wrist-near-fix', dest='wrist_near_fix', action='store_true', default=True,  # [packaged] default ON
+                   help='(default) render the wrist camera with a 2.9 mm near plane (no see-through); agent views unchanged')
+    p.add_argument('--no-wrist-near-fix', dest='wrist_near_fix', action='store_false',  # [packaged]
+                   help='original 2.9 cm wrist near plane: exact reproduction of the original 1/5/15-min and immediate runs and of the training-data rendering')
+    a = p.parse_args()
     stage = N/a.stage; pauses = [N/'USER_PAUSED.json', N/'STOP', HERE/'STOP', stage/'STOP', stage/'USER_PAUSED.json']
     plan = read(stage/'plan.json'); case = next(x for x in plan['cases'] if x['trial_id'] == a.trial)
     out = stage/'episodes'/a.trial; out.mkdir(parents=True, exist_ok=False)
@@ -88,16 +122,18 @@
     def progress(status, **kw): write(out/'status.json', dict(status=status, updated_unix=time.time(), trial=a.trial, policy_steps=steps, **kw))
     try:
         check_pause(pauses)
-        src = Path(case['source_dir']); g = read(src/'result.json'); tsrc = Path(case['training_source_dir'])
+        src = L(case['source_dir']); g = read(src/'result.json'); tsrc = L(case['training_source_dir'])
         assert g['status'] == 'verified' and g['trajectory_sha256'] == case['source_trajectory_sha256']
         progress('checking_source_hashes')
         assert digest(src/'trajectory.hdf5') == case['source_trajectory_sha256']
-        assert digest(tsrc/'training.hdf5') == case['training_hdf5_sha256']
+        assert not (tsrc/'training.hdf5').exists() or digest(tsrc/'training.hdf5') == case['training_hdf5_sha256']  # [packaged] RGB reference optional
         b = case['storage_steps']; h = case['handoff_step']
         spec = importlib.util.spec_from_file_location('frozen_data_env', E/case['generator_version']/'data_env.py')
         module = importlib.util.module_from_spec(spec); spec.loader.exec_module(module)
         io = read(OLD/'io.json'); env = module.make(g['scenario'], out/'assets'); obs = env.reset()
-        assert read(OLD/'download-status.json')['status'] == 'verified'
+        zn = float(env.sim.model._model.vis.map.znear*env.sim.model._model.stat.extent)  # [packaged]
+        result.update(wrist_near_fix=dict(enabled=a.wrist_near_fix, wrist_near_plane_m=zn/(WRIST_NEAR_DIVISOR if a.wrist_near_fix else 1), agent_view_near_plane_m=zn))  # [packaged]
+        assert not (OLD/'download-status.json').exists() or read(OLD/'download-status.json')['status'] == 'verified'  # [packaged] optional record
         penv = dict(os.environ, CUDA_VISIBLE_DEVICES=str(a.gpu), PYTHONPATH=str(OLD/'code')+':'+str(OLD/'author-code'), SM_L2NORM_ROW_PAD='65536')
         command = [str(E/'policy-venv/bin/python'), str(OLD/'policy_entry.py'), '--checkpoint', str(OLD/'checkpoint/model'),
             '--io-config', str(OLD/'io.json'), '--repo', str(E/'SimpleMemVLA'), '--max-subtask-tokens', '256',
@@ -114,26 +150,26 @@
         video = EvaluationVideo(out)
         maxerr = 0.; rgb_storage = {c: 0 for c in CAMERAS}; checkpoint_rgb = {}; hidden = []
         progress('replaying_source', boundary=b, handoff=h)
-        with h5py.File(src/'trajectory.hdf5') as trajectory, h5py.File(tsrc/'training.hdf5') as training:
+        with h5py.File(src/'trajectory.hdf5') as trajectory, (h5py.File(tsrc/'training.hdf5') if (tsrc/'training.hdf5').exists() else __import__('contextlib').nullcontext()) as training:  # [packaged]
             assert trajectory['actions'].dtype == np.float64 and len(trajectory['actions']) == h
             for i in range(h+1):
                 check_pause(pauses)
                 error = float(np.max(np.abs(env.sim.get_state().flatten()-trajectory['states'][i])))
                 assert np.isfinite(error) and error <= 1e-8, ('state_replay', i, error); maxerr = max(maxerr, error)
                 assert np.array_equal(encode_state(obs, io), trajectory['observation.state'][i]), ('proprio_replay', i)
-                images = camera_frames(env, io, KEYS)
+                images = render_frames(env, io, a.wrist_near_fix)  # [packaged]
                 assert all(v.shape == (256, 256, 3) and v.std() > 5 for v in images.values()), ('invalid_rgb', i)
-                if i <= b:
+                if training is not None and i <= b:  # [packaged]
                     for c in CAMERAS:
                         d = int(np.abs(images['observation.images.'+c].astype(np.int16)-training['rgb/'+c][i].astype(np.int16)).max())
-                        rgb_storage[c] = max(rgb_storage[c], d); assert d == 0, ('storage_rgb', i, c, d)
+                        rgb_storage[c] = max(rgb_storage[c], d); assert d == 0 or (a.wrist_near_fix and c == WRIST), ('storage_rgb', i, c, d)  # [packaged] wrist recorded, not asserted, with the fix
                 for label, step in (('initial', 0), ('immediate-handoff', b), ('delayed-handoff', h)):
                     if i == step:
                         for c in CAMERAS: Image.fromarray(images['observation.images.'+c]).save(out/f'{label}-{c}.png')
                         if label != 'initial':
                             checkpoint_rgb[label] = {c: int(np.abs(np.asarray(Image.open(src/f'{label}-{c}.png')).astype(np.int16)
                                 - images['observation.images.'+c].astype(np.int16)).max()) for c in CAMERAS}
-                            assert all(v == 0 for v in checkpoint_rgb[label].values()), (label, checkpoint_rgb[label])
+                            assert all(v == 0 for c, v in checkpoint_rgb[label].items() if not (a.wrist_near_fix and c == WRIST)), (label, checkpoint_rgb[label])  # [packaged]
                 if i > b: hidden.append(concealed(env, family))
                 if i < h:
                     policy.observe(images); video.append_reference(images, i)
@@ -178,7 +214,7 @@
                 states.append(env.sim.get_state().flatten().copy()); observations.append(encode_state(obs, io)); actions.append(action)
                 video.append_action(images, step, case['instruction'])
                 obs = env.step(action)[0]; steps = step+1
-                images = camera_frames(env, io, KEYS)
+                images = render_frames(env, io, a.wrist_near_fix)  # [packaged]
                 assert all(v.shape == (256, 256, 3) and v.dtype == np.uint8 and v.std() > 5 for v in images.values())
                 policy.observe(images)
                 current = flags(env, family, origin, chores_done)
--- original/evaluate_delayed_v2.py
+++ packaged/evaluate_delayed_v2.py
@@ -17,7 +17,14 @@
 import time
 from pathlib import Path
 
-E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108')
+ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103'
+ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT)  # [packaged] relocatable root, default = original
+E = Path(ROOT)/'evaluation-ck30000-20261108'
+
+
+def L(p):  # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT
+    p = str(p)
+    return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p)
 R = E.parent
 OLD = E/'cotrain-ck3000-20261114'
 N = E/'cotrain-delay-n10-20261115'
@@ -101,7 +108,10 @@
     p = argparse.ArgumentParser(); p.add_argument('--stage', required=True); p.add_argument('--trial', required=True)
     p.add_argument('--gpu', type=int, choices=[0, 1], required=True)
     p.add_argument('--bounded-history', action='store_true', help='disk-backed policy history buffers (I/O only; inputs bit-identical)')
-    p.add_argument('--wrist-near-fix', action='store_true', help='render the wrist camera with a 2.9 mm near plane (no see-through); agent views unchanged')
+    p.add_argument('--wrist-near-fix', dest='wrist_near_fix', action='store_true', default=True,  # [packaged] default ON
+                   help='(default) render the wrist camera with a 2.9 mm near plane (no see-through); agent views unchanged')
+    p.add_argument('--no-wrist-near-fix', dest='wrist_near_fix', action='store_false',  # [packaged]
+                   help='original 2.9 cm wrist near plane: exact reproduction of the original 1/5/15-min and immediate runs and of the training-data rendering')
     a = p.parse_args()
     stage = N/a.stage; pauses = [N/'USER_PAUSED.json', N/'STOP', HERE/'STOP', stage/'STOP', stage/'USER_PAUSED.json']
     plan = read(stage/'plan.json'); case = next(x for x in plan['cases'] if x['trial_id'] == a.trial)
@@ -117,13 +127,13 @@
     def progress(status, **kw): write(out/'status.json', dict(status=status, updated_unix=time.time(), trial=a.trial, policy_steps=steps, **kw))
     try:
         check_pause(pauses)
-        src = Path(case['source_dir']); g = read(src/'result.json'); kind = case['source_kind']
+        src = L(case['source_dir']); g = read(src/'result.json'); kind = case['source_kind']
         assert g['status'] == 'verified' and g['trajectory_sha256'] == case['source_trajectory_sha256']
         progress('checking_source_hashes')
         assert digest(src/'trajectory.hdf5') == case['source_trajectory_sha256']
         b = case['storage_steps']; h = case['handoff_step']
         if kind == 'short':
-            tsrc = Path(case['training_source_dir']); assert digest(tsrc/'training.hdf5') == case['training_hdf5_sha256']
+            tsrc = L(case['training_source_dir']); assert not (tsrc/'training.hdf5').exists() or digest(tsrc/'training.hdf5') == case['training_hdf5_sha256']  # [packaged] RGB reference optional
             spec = importlib.util.spec_from_file_location('frozen_data_env', E/case['generator_version']/'data_env.py')
             module = importlib.util.module_from_spec(spec); spec.loader.exec_module(module)
             if family == 'cup' and case['chores'] != ['pack_drink']:
@@ -146,10 +156,10 @@
         else:
             from experiments.robocasa_memory.evaluation.driver import make_environment
             with h5py.File(src/'trajectory.hdf5') as f: meta = json.loads(f.attrs['ep_meta'])
-            env = make_environment(dict(metadata=meta, minutes=case['env_minutes']), meta['memory_task'].get('asset_dir') or out/'assets')
-            cache = h5py.File(case['frame_cache'], 'r'); assert int(cache.attrs['handoff_step']) == h
+            env = make_environment(dict(metadata=meta, minutes=case['env_minutes']), (L(meta['memory_task']['asset_dir']) if meta['memory_task'].get('asset_dir') else out/'assets'))
+            cache = h5py.File(L(case['frame_cache']), 'r') if L(case['frame_cache']).exists() else None; assert cache is None or int(cache.attrs['handoff_step']) == h  # [packaged] frame cache optional
         io = read(OLD/'io.json'); obs = env.reset()
-        assert read(OLD/'download-status.json')['status'] == 'verified'
+        assert not (OLD/'download-status.json').exists() or read(OLD/'download-status.json')['status'] == 'verified'  # [packaged] optional record
         penv = dict(os.environ, CUDA_VISIBLE_DEVICES=str(a.gpu), PYTHONPATH=str(OLD/'code')+':'+str(OLD/'author-code'), SM_L2NORM_ROW_PAD='65536')
         history_dir = Path('/tmp/sm-history')/(a.stage.replace('/', '_')+'__'+a.trial)
         if a.bounded_history: penv['SM_HISTORY_DIR'] = str(history_dir)
@@ -177,7 +187,7 @@
         video = EvaluationVideo(out)
         maxerr = 0.; rgb_ref = {c: 0 for c in CAMERAS}; checkpoint_rgb = {}; hidden = []; observed_hashes = []
         progress('replaying_source', boundary=b, handoff=h)
-        training = h5py.File(tsrc/'training.hdf5', 'r') if kind == 'short' else None
+        training = h5py.File(tsrc/'training.hdf5', 'r') if kind == 'short' and (tsrc/'training.hdf5').exists() else None  # [packaged]
         with h5py.File(src/'trajectory.hdf5') as trajectory:
             assert len(trajectory['actions']) == h
             assert trajectory['actions'].dtype == (np.float64 if kind == 'short' else np.float32)
@@ -189,9 +199,9 @@
                 images = render_frames(env, io, a.wrist_near_fix)
                 assert all(v.shape == (256, 256, 3) and v.std() > 5 for v in images.values()), ('invalid_rgb', i)
                 # EGL reference: training frames through storage (short), or the EGL-rendered left-agentview cache (long).
-                if kind == 'short' and i <= b:
+                if kind == 'short' and training is not None and i <= b:  # [packaged]
                     refs = {c: training['rgb/'+c][i] for c in CAMERAS}
-                elif kind == 'long':
+                elif kind == 'long' and cache is not None:  # [packaged]
                     refs = {'robot0_agentview_left': cache['robot0_agentview_left'][i]}
                     if i == h: refs.update({c: cache[c+'_at_handoff'][()] for c in CAMERAS})
                 else: refs = {}
@@ -216,7 +226,7 @@
                     obs = env.step(trajectory['actions'][i])[0]
                 if i % 200 == 0: progress('replaying_source', native_step=i, boundary=b, handoff=h)
         if training: training.close()
-        if kind == 'long': cache.close()
+        if kind == 'long' and cache is not None: cache.close()  # [packaged]
         first_hidden = next((j for j, x in enumerate(hidden) if x), None)
         assert first_hidden is not None and all(hidden[first_hidden:]), 'target became visible before handoff'
         if kind == 'short': assert first_hidden == 0, 'short sources must be concealed from the storage boundary on'
--- original/evaluate_parity.py
+++ packaged/evaluate_parity.py
@@ -15,7 +15,14 @@
 import time
 from pathlib import Path
 
-E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108')
+ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103'
+ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT)  # [packaged] relocatable root, default = original
+E = Path(ROOT)/'evaluation-ck30000-20261108'
+
+
+def L(p):  # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT
+    p = str(p)
+    return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p)
 R = E.parent
 OLD = E/'cotrain-ck3000-20261114'
 N = E/'cotrain-delay-n10-20261115'
@@ -36,6 +43,28 @@
 
 TASKS = {'cup': 'OpenCabinetAndReturnCup', 'spice': 'UncoverAndRetrieveSpice'}
 KEYS = ['observation.images.'+c for c in CAMERAS]
+WRIST = 'robot0_eye_in_hand'
+WRIST_NEAR_DIVISOR = 10  # wrist near plane 0.001*extent (29 mm in these kitchens) -> 2.9 mm
+
+
+# [packaged] same wrist near-plane fix as evaluate_delayed_v2.py (default ON; --no-wrist-near-fix = original rendering)
+def render_frames(env, io, wrist_near_fix):
+    """camera_frames(), except (optionally) the wrist camera is rendered with a 10x closer near plane.
+
+    MuJoCo's near plane is vis.map.znear * stat.extent; the ~29 m kitchen extent puts it at 2.9 cm, so geometry within
+    2.9 cm of the wrist camera is clipped (see-through). The agent-view cameras (the left one is the policy history) are
+    rendered with the unchanged global setting, so they stay bit-identical to camera_frames()."""
+    if not wrist_near_fix:
+        return camera_frames(env, io, KEYS)
+    m = env.sim.model._model; z0 = m.vis.map.znear; frames = {}
+    for key in KEYS:
+        cam = key.split('.')[-1]
+        try:
+            if cam == WRIST: m.vis.map.znear = z0/WRIST_NEAR_DIVISOR
+            frames[key] = np.ascontiguousarray(env.sim.render(width=io['render_width'], height=io['render_height'], camera_name=cam)[::-1])
+        finally:
+            m.vis.map.znear = z0
+    return frames
 
 
 def delayed_recall_success(env, task, chores_done):
@@ -77,7 +106,12 @@
 
 def main():
     p = argparse.ArgumentParser(); p.add_argument('--stage', required=True); p.add_argument('--trial', required=True)
-    p.add_argument('--gpu', type=int, choices=[0, 1], required=True); a = p.parse_args()
+    p.add_argument('--gpu', type=int, choices=[0, 1], required=True)
+    p.add_argument('--wrist-near-fix', dest='wrist_near_fix', action='store_true', default=True,  # [packaged] default ON
+                   help='(default) render the wrist camera with a 2.9 mm near plane (no see-through); agent views unchanged')
+    p.add_argument('--no-wrist-near-fix', dest='wrist_near_fix', action='store_false',  # [packaged]
+                   help='original 2.9 cm wrist near plane: exact reproduction of the original 1/5/15-min and immediate runs and of the training-data rendering')
+    a = p.parse_args()
     stage = N/'parity'/a.stage; pauses = [N/'USER_PAUSED.json', N/'STOP', HERE/'STOP', stage/'STOP', stage/'USER_PAUSED.json']
     plan = read(stage/'plan.json'); case = next(x for x in plan['cases'] if x['trial_id'] == a.trial)
     out = stage/'episodes'/a.trial; out.mkdir(parents=True, exist_ok=False)
@@ -92,16 +126,18 @@
     def progress(status, **kw): write(out/'status.json', dict(status=status, updated_unix=time.time(), trial=a.trial, policy_steps=steps, **kw))
     try:
         check_pause(pauses)
-        src = Path(case['source_dir']); g = read(src/'result.json'); tsrc = Path(case['training_source_dir']); assert src == tsrc
+        src = L(case['source_dir']); g = read(src/'result.json'); tsrc = L(case['training_source_dir']); assert src == tsrc
         assert g['status'] == 'verified' and g['trajectory_sha256'] == case['source_trajectory_sha256'] and g['storage_steps'] == case['handoff_step']
         progress('checking_source_hashes')
         assert digest(src/'trajectory.hdf5') == case['source_trajectory_sha256']
-        assert digest(tsrc/'training.hdf5') == case['training_hdf5_sha256']
+        assert not (tsrc/'training.hdf5').exists() or digest(tsrc/'training.hdf5') == case['training_hdf5_sha256']  # [packaged] RGB reference optional
         b = case['storage_steps']; h = case['handoff_step']
         spec = importlib.util.spec_from_file_location('frozen_data_env', E/case['generator_version']/'data_env.py')
         module = importlib.util.module_from_spec(spec); spec.loader.exec_module(module)
         io = read(OLD/'io.json'); env = module.make(g['scenario'], out/'assets'); obs = env.reset()
-        assert read(OLD/'download-status.json')['status'] == 'verified'
+        zn = float(env.sim.model._model.vis.map.znear*env.sim.model._model.stat.extent)  # [packaged]
+        result.update(wrist_near_fix=dict(enabled=a.wrist_near_fix, wrist_near_plane_m=zn/(WRIST_NEAR_DIVISOR if a.wrist_near_fix else 1), agent_view_near_plane_m=zn))  # [packaged]
+        assert not (OLD/'download-status.json').exists() or read(OLD/'download-status.json')['status'] == 'verified'  # [packaged] optional record
         penv = dict(os.environ, CUDA_VISIBLE_DEVICES=str(a.gpu), PYTHONPATH=str(OLD/'code')+':'+str(OLD/'author-code'), SM_L2NORM_ROW_PAD='65536')
         command = [str(E/'policy-venv/bin/python'), str(OLD/'policy_entry.py'), '--checkpoint', str(OLD/'checkpoint/model'),
             '--io-config', str(OLD/'io.json'), '--repo', str(E/'SimpleMemVLA'), '--max-subtask-tokens', '256',
@@ -118,7 +154,7 @@
         video = EvaluationVideo(out)
         maxerr = 0.; rgb_storage = {c: 0 for c in CAMERAS}; checkpoint_rgb = {}; hidden = []
         progress('replaying_source', boundary=b, handoff=h)
-        with h5py.File(src/'trajectory.hdf5') as trajectory, h5py.File(tsrc/'training.hdf5') as training:
+        with h5py.File(src/'trajectory.hdf5') as trajectory, (h5py.File(tsrc/'training.hdf5') if (tsrc/'training.hdf5').exists() else __import__('contextlib').nullcontext()) as training:  # [packaged]
             assert trajectory['actions'].dtype == np.float64 and len(trajectory['actions']) > h
             for i in range(h+1):
                 check_pause(pauses)
@@ -126,19 +162,19 @@
                 error = float(np.max(np.abs(env.sim.get_state().flatten()-trajectory['states'][i])))
                 assert np.isfinite(error) and error <= 1e-8, ('state_replay', i, error); maxerr = max(maxerr, error)
                 assert np.array_equal(encode_state(obs, io), trajectory['observation.state'][i]), ('proprio_replay', i)
-                images = camera_frames(env, io, KEYS)
+                images = render_frames(env, io, a.wrist_near_fix)  # [packaged]
                 assert all(v.shape == (256, 256, 3) and v.std() > 5 for v in images.values()), ('invalid_rgb', i)
-                if i <= b:
+                if training is not None and i <= b:  # [packaged]
                     for c in CAMERAS:
                         d = int(np.abs(images['observation.images.'+c].astype(np.int16)-training['rgb/'+c][i].astype(np.int16)).max())
-                        rgb_storage[c] = max(rgb_storage[c], d); assert d == 0, ('storage_rgb', i, c, d)
+                        rgb_storage[c] = max(rgb_storage[c], d); assert d == 0 or (a.wrist_near_fix and c == WRIST), ('storage_rgb', i, c, d)  # [packaged] wrist recorded, not asserted, with the fix
                 for label, step in (('initial', 0), ('immediate-handoff', b)):
                     if i == step:
                         for c in CAMERAS: Image.fromarray(images['observation.images.'+c]).save(out/f'{label}-{c}.png')
                         if label != 'initial':
                             checkpoint_rgb[label] = {c: int(np.abs(np.asarray(Image.open(src/f'handoff-{c}.png')).astype(np.int16)
                                 - images['observation.images.'+c].astype(np.int16)).max()) for c in CAMERAS}
-                            assert all(v == 0 for v in checkpoint_rgb[label].values()), (label, checkpoint_rgb[label])
+                            assert all(v == 0 for c, v in checkpoint_rgb[label].items() if not (a.wrist_near_fix and c == WRIST)), (label, checkpoint_rgb[label])  # [packaged]
                 if i > b: hidden.append(concealed(env, family))
                 if i < h:
                     policy.observe(images); video.append_reference(images, i)
@@ -184,7 +220,7 @@
                 states.append(env.sim.get_state().flatten().copy()); observations.append(encode_state(obs, io)); actions.append(action)
                 video.append_action(images, step, case['instruction'])
                 obs = env.step(action)[0]; steps = step+1
-                images = camera_frames(env, io, KEYS)
+                images = render_frames(env, io, a.wrist_near_fix)  # [packaged]
                 assert all(v.shape == (256, 256, 3) and v.dtype == np.uint8 and v.std() > 5 for v in images.values())
                 policy.observe(images)
                 current = flags(env, family, origin, chores_done)
--- original/make_plan_v2.py
+++ packaged/make_plan_v2.py
@@ -3,7 +3,14 @@
 from pathlib import Path
 import h5py
 
-E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108')
+ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103'
+ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT)  # [packaged] relocatable root, default = original
+E = Path(ROOT)/'evaluation-ck30000-20261108'
+
+
+def L(p):  # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT
+    p = str(p)
+    return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p)
 OLD = E/'cotrain-ck3000-20261114'
 N = E/'cotrain-delay-n10-20261115'
 sys.path.insert(0, str(OLD/'code'))
--- original/policy_entry_bounded.py
+++ packaged/policy_entry_bounded.py
@@ -3,7 +3,7 @@
 import sys
 from pathlib import Path
 
-root = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108/cotrain-ck3000-20261114')
+root = Path(os.environ.get('RDR_ROOT', '/data/robo_ttt/robocasa_memory_20261103'))/'evaluation-ck30000-20261108'/'cotrain-ck3000-20261114'  # [packaged] relocatable root
 os.environ.update(GIT_CONFIG_COUNT='1', GIT_CONFIG_KEY_0='safe.directory',
                   GIT_CONFIG_VALUE_0=str(root.parent/'SimpleMemVLA'))
 sys.path.insert(0, str(root/'author-code'))
--- original/rollout_stats.py
+++ packaged/rollout_stats.py
@@ -4,7 +4,14 @@
 import h5py
 import numpy as np
 
-E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108')
+ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103'
+ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT)  # [packaged] relocatable root, default = original
+E = Path(ROOT)/'evaluation-ck30000-20261108'
+
+
+def L(p):  # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT
+    p = str(p)
+    return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p)
 OLD = E/'cotrain-ck3000-20261114'; N = E/'cotrain-delay-n10-20261115'
 ARM, BASE = slice(0, 6), slice(7, 11)  # native action: arm 0-5, gripper 6, base/torso 7-10, mode 11
 
--- original/run_stage.py
+++ packaged/run_stage.py
@@ -2,7 +2,14 @@
 import argparse, fcntl, hashlib, json, os, subprocess, time
 from pathlib import Path
 
-E = Path('/data/robo_ttt/robocasa_memory_20261103/evaluation-ck30000-20261108')
+ORIGINAL_ROOT = '/data/robo_ttt/robocasa_memory_20261103'
+ROOT = __import__('os').environ.get('RDR_ROOT', ORIGINAL_ROOT)  # [packaged] relocatable root, default = original
+E = Path(ROOT)/'evaluation-ck30000-20261108'
+
+
+def L(p):  # [packaged] map an original absolute path recorded in plans / source metadata onto RDR_ROOT
+    p = str(p)
+    return Path(ROOT+p[len(ORIGINAL_ROOT):]) if p.startswith(ORIGINAL_ROOT) else Path(p)
 R = E.parent
 N = E/'cotrain-delay-n10-20261115'
 HERE = Path(__file__).resolve().parent