Add files using upload-large-folder tool
Browse files- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-023631c9-84c3-44a8-86f0-5eae46cd682c1758617643748-2025_09_23-10.54.11.633/source.csv +10 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-0692028e-98ba-48e2-9ebc-ba3f1c4cd5a21759257473788-2025_09_30-20.38.00.177/source.csv +19 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-12f40b2b-48a7-497c-a003-dd2d4f41983d1765533231519-2025_12_12-10.53.56.404/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-1b85b896-114f-4adc-b559-52f92a3a305a1762181559268-2025_11_03-15.52.54.585/source.csv +5 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-1c973de0-6be0-4d96-a6b9-3da6c2c9d2721756538623658-2025_08_30-08.23.47.981/source.csv +5 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-1ebafea1-3b03-42e3-9fcb-f77691a4a6661758882427735-2025_09_26-12.27.24.970/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-20194a13-4640-4c1b-9e26-6b88dd86963a1766586898739-2025_12_24-15.35.09.94/source.csv +14 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-3334d6a5-5e72-43ad-a8da-1813285fd7a51758271588339-2025_09_19-10.46.34.637/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-33fc4e7e-94fe-43e5-b385-1c4730f8870e1767605900421-2026_01_05-10.38.50.565/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-3bffc30a-6fb0-48dd-ab21-3fe225eb22c51757148592262-2025_09_06-10.49.57.58/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-3cc4c729-59f0-4fab-9ef2-7e984f91ed9a1756976763530-2025_09_04-11.06.10.579/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-41b9d3a7-e49d-4fb5-ac82-5e55b78f6f611761398957344-2025_10_25-15.29.41.853/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-4d667d63-df3b-4c2f-9829-cbc24fb4ff5d1767609520115-2026_01_05-11.38.46.560/source.csv +6 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-53781591-135c-4837-bb7b-7551872ec06a1763025484154-2025_11_13-10.18.11.147/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-59175e55-ecae-446f-be12-8861032d4f481751613426266-2025_07_04-09.17.44.620/source.csv +16 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-65bd7149-5424-43f9-8618-556923c89f3e1762712224460-2025_11_09-19.17.10.464/source.csv +4 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-667f558c-c85b-45c3-9621-f920186c4d561764772496749-2025_12_03-15.35.04.989/source.csv +6 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-69b3ec1c-9de9-4a08-b72c-2106545215f31759658466061-2025_10_05-12.01.13.925/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-70e1b9a4-9447-4be7-85f9-ea3b825230fe1765227767400-2025_12_08-22.02.58.450/source.csv +103 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-76eea157-7b6f-494c-8c5d-4a51e6e2b49d1759266847108-2025_09_30-23.14.13.32/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-7bb39648-a065-4847-8b07-5024f699fc131758998987531-2025_09_27-20.49.55.850/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-81c2c0be-5633-4bef-b439-115d6aef8f341763318955037-2025_11_16-19.49.31.87/source.csv +5 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-89e32a43-dc9e-46d6-874e-f60a6cb0b3071767607509804-2026_01_05-11.05.16.288/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-8c6fe2f6-5c87-474b-8190-b29853bcc7151755414648501-2025_08_17-09.10.53.985/source.csv +4 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-971339fb-c463-429e-a956-f7bb98fdea341755623101217-2025_08_19-19.05.03.822/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-9f142d59-1199-4718-91b8-9c661493a1b51763125195520-2025_11_14-14.00.04.00/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-ac6664bd-508f-405e-9f34-c2691ea9a56e1761555883090-2025_10_27-10.04.54.408/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-beadbbc6-30c2-409e-bd4b-c1b78eed0f3c1755872503826-2025_08_22-16.21.51.549/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-d5c0f30b-efff-4cba-9421-06a8c78914011759343086476-2025_10_01-20.24.54.587/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-dea29b8c-1428-44de-be76-3b6707ae1c481762331529047-2025_11_05-09.32.27.633/source.csv +0 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-e5295f7c-e65d-4455-aaa4-44e96e5467f81765288393722-2025_12_09-14.53.21.307/source.csv +57 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-e6fd64e1-70f6-461f-bc3d-ac75f6654a311756111953368-2025_08_25-10.52.42.401/source.csv +119 -0
- 1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-eb393a0e-6aef-412a-bef0-408ff847ad2c1764928526101-2025_12_05-10.55.35.367/source.csv +2 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-02f1e1f4-094a-4d7b-957e-88354d5de1001754231283463-2025_08_03-16.28.12.317/source.csv +515 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-07bd0028-3336-4375-9dd9-453a62e0affc1758023418620-2025_09_16-13.50.36.784/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-0e85c644-d3bf-4fc0-b546-5324075f1cc91757500459100-2025_09_10-12.34.40.648/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-1ae480a2-bc7d-4b65-b456-3679a88992ae1752076515942-2025_07_09-17.56.33.471/source.csv +19 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-249f1768-ea07-4d12-8b50-2383233eade61754215674347-2025_08_03-12.08.35.58/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-311b67df-2f46-4805-a16c-07606ec1fc001751032376516-2025_06_27-15.53.06.902/source.csv +2 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-66197d0b-1341-4b69-bb71-811a07151bee1759437984150-2025_10_02-22.47.02.640/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-8bf77bbd-2546-4cc2-b4c2-aa8a23cdc8e51758545574283-2025_09_22-14.53.22.970/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-8ebe1d51-f3d9-465d-9dcc-9f20b1658e961759413231847-2025_10_02-15.54.19.385/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-a61250bb-ca2a-471a-a3f2-baf03ed793791758104983691-2025_09_17-12.30.25.600/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-b6479f87-a6dd-4f48-918b-47aeda5068fc1750926520523-2025_06_26-10.29.13.179/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-b8280b40-f43a-4e79-816b-40c4a8f904a41757329807390-2025_09_08-13.11.16.646/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-cccb8167-b56c-49f5-8a6d-fb1d433ccf181754984083218-2025_08_12-09.36.49.473/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-dd953f38-c05c-432b-887a-f1b903a654ea1757946579500-2025_09_15-16.29.47.578/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-ef114a72-0eb6-4a23-a381-0f0468cdd19e1758035815330-2025_09_16-17.17.38.386/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-f95bc203-868d-4b00-95ac-111a3a77ba441753772820552-2025_07_29-09.07.39.448/source.csv +0 -0
- 927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-fbdad54f-458b-4a49-b398-aff5c8bb59901759170581539-2025_09_29-20.30.43.940/source.csv +155 -0
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-023631c9-84c3-44a8-86f0-5eae46cd682c1758617643748-2025_09_23-10.54.11.633/source.csv
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
1,3,"genie.py",0,0,"from typing import Dict\n\nimport einops\nimport jax\nimport jax.numpy as jnp\nimport flax.nnx as nnx\nimport orbax.checkpoint as ocp\n\nfrom models.dynamics import DynamicsMaskGIT, DynamicsCausal\nfrom models.lam import LatentActionModel\nfrom models.tokenizer import TokenizerVQVAE\n\n\nclass Genie(nnx.Module):\n """"""Genie model""""""\n\n def __init__(\n self,\n in_dim: int,\n tokenizer_dim: int,\n tokenizer_ffn_dim: int,\n latent_patch_dim: int,\n num_patch_latents: int,\n patch_size: int,\n tokenizer_num_blocks: int,\n tokenizer_num_heads: int,\n lam_dim: int,\n lam_ffn_dim: int,\n latent_action_dim: int,\n num_latent_actions: int,\n lam_patch_size: int,\n lam_num_blocks: int,\n lam_num_heads: int,\n lam_co_train: bool,\n use_gt_actions: bool,\n dyna_type: str,\n dyna_dim: int,\n dyna_ffn_dim: int,\n dyna_num_blocks: int,\n dyna_num_heads: int,\n param_dtype: jnp.dtype,\n dtype: jnp.dtype,\n use_flash_attention: bool,\n decode: bool,\n rngs: nnx.Rngs,\n dropout: float = 0.0,\n mask_limit: float = 0.0,\n ):\n # --- Tokenizer ---\n self.in_dim = in_dim\n self.tokenizer_dim = tokenizer_dim\n self.tokenizer_ffn_dim = tokenizer_ffn_dim\n self.latent_patch_dim = latent_patch_dim\n self.num_patch_latents = num_patch_latents\n self.patch_size = patch_size\n self.tokenizer_num_blocks = tokenizer_num_blocks\n self.tokenizer_num_heads = tokenizer_num_heads\n # --- LAM ---\n self.lam_dim = lam_dim\n self.lam_ffn_dim = lam_ffn_dim\n self.latent_action_dim = latent_action_dim\n self.num_latent_actions = num_latent_actions\n self.lam_patch_size = lam_patch_size\n self.lam_num_blocks = lam_num_blocks\n self.lam_num_heads = lam_num_heads\n self.lam_co_train = lam_co_train\n self.use_gt_actions = use_gt_actions\n # --- Dynamics ---\n self.dyna_type = dyna_type\n self.dyna_dim = dyna_dim\n self.dyna_ffn_dim = dyna_ffn_dim\n self.dyna_num_blocks = dyna_num_blocks\n self.dyna_num_heads = dyna_num_heads\n self.param_dtype = param_dtype\n self.dtype = dtype\n self.use_flash_attention = use_flash_attention\n self.dropout = dropout\n self.mask_limit = mask_limit\n self.decode = decode\n\n self.tokenizer = TokenizerVQVAE(\n in_dim=self.in_dim,\n model_dim=self.tokenizer_dim,\n ffn_dim=self.tokenizer_ffn_dim,\n latent_dim=self.latent_patch_dim,\n num_latents=self.num_patch_latents,\n patch_size=self.patch_size,\n num_blocks=self.tokenizer_num_blocks,\n num_heads=self.tokenizer_num_heads,\n dropout=0.0,\n codebook_dropout=0.0,\n param_dtype=self.param_dtype,\n dtype=self.dtype,\n use_flash_attention=self.use_flash_attention,\n rngs=rngs,\n )\n if self.use_gt_actions:\n self.action_embed = nnx.Embed(\n self.num_latent_actions, self.latent_action_dim, rngs=rngs\n )\n self.lam = None\n else:\n self.lam = LatentActionModel(\n in_dim=self.in_dim,\n model_dim=self.lam_dim,\n ffn_dim=self.lam_ffn_dim,\n latent_dim=self.latent_patch_dim,\n num_latents=self.num_latent_actions,\n patch_size=self.lam_patch_size,\n num_blocks=self.lam_num_blocks,\n num_heads=self.lam_num_heads,\n dropout=0.0,\n codebook_dropout=0.0,\n param_dtype=self.param_dtype,\n dtype=self.dtype,\n use_flash_attention=self.use_flash_attention,\n rngs=rngs,\n )\n self.action_embed = None\n if self.dyna_type == ""maskgit"":\n self.dynamics = DynamicsMaskGIT(\n model_dim=self.dyna_dim,\n ffn_dim=self.dyna_ffn_dim,\n num_latents=self.num_patch_latents,\n latent_action_dim=self.latent_action_dim,\n num_blocks=self.dyna_num_blocks,\n num_heads=self.dyna_num_heads,\n dropout=self.dropout,\n mask_limit=self.mask_limit,\n param_dtype=self.param_dtype,\n dtype=self.dtype,\n use_flash_attention=self.use_flash_attention,\n rngs=rngs,\n )\n elif self.dyna_type == ""causal"":\n self.dynamics = DynamicsCausal(\n model_dim=self.dyna_dim,\n ffn_dim=self.dyna_ffn_dim,\n num_latents=self.num_patch_latents,\n latent_action_dim=self.latent_action_dim,\n num_blocks=self.dyna_num_blocks,\n num_heads=self.dyna_num_heads,\n dropout=self.dropout,\n param_dtype=self.param_dtype,\n dtype=self.dtype,\n use_flash_attention=self.use_flash_attention,\n decode=decode,\n rngs=rngs,\n )\n else:\n raise ValueError(f""Invalid dynamics type: {self.dyna_type}"")\n\n def __call__(\n self,\n batch: Dict[str, jax.Array],\n training: bool = True,\n ) -> Dict[str, jax.Array]:\n videos_BTHWC = batch[""videos""]\n tokenizer_outputs = self.tokenizer.vq_encode(videos_BTHWC, training=False)\n token_indices_BTN = tokenizer_outputs[""indices""]\n latent_actions_BTm11L = None\n action_embeddings_BTm11L = None\n if self.use_gt_actions:\n assert self.action_embed is not None\n action_indices_E = None\n action_embeddings_BT1L = self.action_embed(batch[""actions""]).reshape(\n *batch[""actions""].shape[:2], 1, self.latent_action_dim\n )\n action_embeddings_BTm11L = action_embeddings_BT1L[:, 1:]\n else:\n assert self.lam is not None\n lam_outputs = self.lam.vq_encode(videos_BTHWC, training=False)\n z_q_BTm11L = lam_outputs[""z_q""]\n action_indices_E = lam_outputs[""indices""]\n latent_actions_BTm11L = jax.lax.cond(\n self.lam_co_train,\n lambda: z_q_BTm11L,\n lambda: jax.lax.stop_gradient(z_q_BTm11L),\n )\n outputs = dict(\n video_tokens=jax.lax.stop_gradient(token_indices_BTN),\n latent_actions=(\n action_embeddings_BTm11L\n if self.use_gt_actions\n else latent_actions_BTm11L\n ),\n )\n outputs[""mask_rng""] = batch[""rng""]\n dyna_logits_BTNV, dyna_mask = self.dynamics(outputs, training)\n outputs[""token_logits""] = dyna_logits_BTNV\n outputs[""mask""] = dyna_mask\n mle_indices_BTN = jnp.argmax(outputs[""token_logits""], axis=-1)\n H, W = batch[""videos""].shape[2:4]\n outputs[""recon""] = self.tokenizer.decode(mle_indices_BTN, (H, W))\n if action_indices_E is not None:\n outputs[""lam_indices""] = action_indices_E\n return outputs\n\n def sample(\n self,\n batch: Dict[str, jax.Array],\n seq_len: int,\n temperature: float = 1,\n sample_argmax: bool = False,\n maskgit_steps: int = 25,\n ) -> tuple[jax.Array, jax.Array]:\n if self.dyna_type == ""maskgit"":\n return self.sample_maskgit(\n batch, seq_len, maskgit_steps, temperature, sample_argmax\n )\n elif self.dyna_type == ""causal"":\n return self.sample_causal(batch, seq_len, temperature, sample_argmax)\n else:\n raise ValueError(f""Dynamics model type unknown: {self.dyna_type}"")\n\n def sample_maskgit(\n self,\n batch: Dict[str, jax.Array],\n seq_len: int,\n steps: int = 25,\n temperature: float = 1,\n sample_argmax: bool = False,\n ) -> tuple[jax.Array, jax.Array]:\n """"""\n Autoregressively samples up to `seq_len` future frames, following Figure 8 of the paper.\n\n - Input frames are tokenized once.\n - Future frames are generated autoregressively in token space.\n - All frames are detokenized in a single pass.\n\n Note:\n - For interactive or step-wise sampling, detokenization should occur after each action.\n - To maintain consistent tensor shapes across timesteps, all current and future frames are decoded at every step.\n - Temporal causal structure is preserved by\n a) reapplying the mask before each decoding step.\n b) a temporal causal mask is applied within each ST-transformer block.\n\n Dimension keys:\n B: batch size\n T: number of input (conditioning) frames\n N: number of patches per frame\n M: model dimension\n S: sequence length\n H: height\n W: width\n E: B * (S - 1)\n P: S * N\n """"""\n assert isinstance(self.dynamics, DynamicsMaskGIT)\n # --- Encode videos and actions ---\n videos_BTHWC = batch[""videos""]\n tokenizer_out = self.tokenizer.vq_encode(videos_BTHWC, training=False)\n token_idxs_BTN = tokenizer_out[""indices""]\n B, T, N = token_idxs_BTN.shape\n pad_shape = (B, seq_len - T, N)\n pad = jnp.zeros(pad_shape, dtype=token_idxs_BTN.dtype)\n token_idxs_BSN = jnp.concatenate([token_idxs_BTN, pad], axis=1)\n init_logits_BSNV = jnp.zeros(\n shape=(*token_idxs_BSN.shape, self.num_patch_latents)\n )\n if self.use_gt_actions:\n assert self.action_embed is not None\n latent_actions_BT1L = self.action_embed(batch[""actions""]).reshape(\n *batch[""actions""].shape[:2], 1, self.latent_action_dim\n )\n latent_actions_BTm11L = latent_actions_BT1L[:, 1:]\n action_tokens_EL = latent_actions_BTm11L.reshape(-1, self.latent_action_dim)\n else:\n assert self.lam is not None\n latent_actions_E = batch[""latent_actions""]\n action_tokens_EL = self.lam.vq.get_codes(latent_actions_E)\n\n # --- Extract submodule state ---\n dynamics_state = nnx.state(self.dynamics)\n\n @nnx.scan(in_axes=(nnx.Carry, 0), out_axes=nnx.Carry)\n def maskgit_step_fn(\n carry: tuple[jax.Array, jax.Array, jax.Array, jax.Array, jax.Array],\n step: jax.Array,\n ) -> tuple[jax.Array, jax.Array, jax.Array, jax.Array, jax.Array]:\n rng, token_idxs_BSN, logits_BSNV, mask_BSN, action_tokens_EL = carry\n S, N = token_idxs_BSN.shape[1:]\n L = action_tokens_EL.shape[-1]\n\n # We need to reconstruct the submodule inside scan body to prevent trace context mismatches\n dynamics_maskgit = DynamicsMaskGIT(\n model_dim=self.dyna_dim,\n ffn_dim=self.dyna_ffn_dim,\n num_latents=self.num_patch_latents,\n latent_action_dim=self.latent_action_dim,\n num_blocks=self.dyna_num_blocks,\n num_heads=self.dyna_num_heads,\n dropout=self.dropout,\n mask_limit=self.mask_limit,\n param_dtype=self.param_dtype,\n dtype=self.dtype,\n use_flash_attention=self.use_flash_attention,\n rngs=nnx.Rngs(0),\n )\n nnx.update(dynamics_maskgit, dynamics_state)\n\n # --- Construct + encode video ---\n vid_embed_BSNM = dynamics_maskgit.patch_embed(token_idxs_BSN)\n mask_token_111M = dynamics_maskgit.mask_token.value\n mask_expanded_BSN1 = mask_BSN[..., None]\n vid_embed_BSNM = jnp.where(\n mask_expanded_BSN1, mask_token_111M, vid_embed_BSNM\n )\n\n # --- Predict transition ---\n action_tokens_BSm1L = jnp.reshape(action_tokens_EL, (B, S - 1, L))\n act_embed_BSm1M = dynamics_maskgit.action_up(action_tokens_BSm1L)\n act_embed_BSM = jnp.pad(act_embed_BSm1M, ((0, 0), (1, 0), (0, 0)))\n act_embed_BS1M = jnp.reshape(\n act_embed_BSM, (B, S, 1, act_embed_BSM.shape[-1])\n )\n vid_embed_BSNM += act_embed_BS1M\n unmasked_ratio = jnp.cos(jnp.pi * (step + 1) / (steps * 2))\n step_temp = temperature * (1.0 - unmasked_ratio)\n final_logits_BSNV = dynamics_maskgit.transformer(vid_embed_BSNM) / step_temp\n\n # --- Sample new tokens for final frame ---\n if sample_argmax:\n sampled_token_idxs_BSN = jnp.argmax(final_logits_BSNV, axis=-1)\n else:\n rng, _rng = jax.random.split(rng)\n sampled_token_idxs_BSN = jax.random.categorical(_rng, final_logits_BSNV)\n gather_fn = jax.vmap(jax.vmap(jax.vmap(lambda x, y: x[y])))\n final_token_probs_BSN = gather_fn(\n jax.nn.softmax(final_logits_BSNV), sampled_token_idxs_BSN\n )\n final_token_probs_BSN += ~mask_BSN\n # Update masked tokens and logits only\n token_idxs_BSN = jnp.where(mask_BSN, sampled_token_idxs_BSN, token_idxs_BSN)\n logits_BSNV = jnp.where(\n jnp.expand_dims(mask_BSN, -1), final_logits_BSNV, logits_BSNV\n )\n\n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n final_token_probs_flat_BP = einops.rearrange(\n final_token_probs_BSN, ""b s n -> b (s n)""\n )\n idx_mask_P = (\n jnp.arange(final_token_probs_flat_BP.shape[-1])\n <= N - num_unmasked_tokens\n )\n sorted_idxs_BP = jnp.argsort(final_token_probs_flat_BP, axis=-1)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask_P))\n mask_flat_BP = einops.rearrange(mask_BSN, ""b s n -> b (s n)"")\n new_mask_flat_BP = mask_update_fn(mask_flat_BP, sorted_idxs_BP)\n new_mask_BSN = einops.rearrange(new_mask_flat_BP, ""b (s n) -> b s n"", n=N)\n\n new_carry = (\n rng,\n token_idxs_BSN,\n logits_BSNV,\n new_mask_BSN,\n action_tokens_EL,\n )\n return new_carry\n\n @nnx.scan(in_axes=(nnx.Carry, 0), out_axes=nnx.Carry)\n def generation_step_fn(\n carry: tuple[jax.Array, jax.Array, jax.Array], step_t: jax.Array\n ) -> tuple[jax.Array, jax.Array, jax.Array]:\n rng, current_token_idxs_BSN, current_logits_BSNV = carry\n rng, step_rng = jax.random.split(rng)\n\n # Mask current frame (i.e., t == step_t)\n mask_S = jnp.arange(seq_len) == step_t\n mask_BSN = jnp.broadcast_to(mask_S[None, :, None], (B, seq_len, N)).astype(\n bool\n )\n masked_token_idxs_BSN = current_token_idxs_BSN * ~mask_BSN\n masked_logits_BSNV = current_logits_BSNV * jnp.expand_dims(~mask_BSN, -1)\n\n # --- Initialize and run MaskGIT loop ---\n init_carry_maskgit = (\n step_rng,\n masked_token_idxs_BSN,\n masked_logits_BSNV,\n mask_BSN,\n action_tokens_EL,\n )\n final_carry_maskgit = maskgit_step_fn(init_carry_maskgit, jnp.arange(steps))\n updated_token_idxs_BSN = final_carry_maskgit[1]\n updated_logits_BSNV = final_carry_maskgit[2]\n new_carry = (rng, updated_token_idxs_BSN, updated_logits_BSNV)\n return new_carry\n\n # --- Run the autoregressive generation using jax.lax.scan ---\n initial_carry = (batch[""rng""], token_idxs_BSN, init_logits_BSNV)\n timesteps_to_scan = jnp.arange(T, seq_len)\n final_carry = generation_step_fn(initial_carry, timesteps_to_scan)\n final_token_idxs_BSN = final_carry[1]\n final_logits_BSNV = final_carry[2]\n\n # --- Decode all tokens at once at the end ---\n H, W = batch[""videos""].shape[2:4]\n final_frames_BSHWC = self.tokenizer.decode(\n final_token_idxs_BSN,\n video_hw=(H, W),\n )\n return final_frames_BSHWC, final_logits_BSNV\n\n def sample_causal(\n self,\n batch: Dict[str, jax.Array],\n seq_len: int,\n temperature: float = 1,\n sample_argmax: bool = False,\n ) -> tuple[jax.Array, jax.Array]:\n """"""\n Autoregressively samples up to `seq_len` future frames, following Figure 8 of the paper.\n\n - Input frames are tokenized once.\n - Future frames are generated autoregressively in token space.\n - All frames are detokenized in a single pass.\n\n Note:\n - For interactive or step-wise sampling, detokenization should occur after each action.\n - To maintain consistent tensor shapes across timesteps, all current and future frames are decoded at every step.\n - Temporal causal structure is preserved by\n a) reapplying the mask before each decoding step.\n b) a temporal causal mask is applied within each ST-transformer block.\n\n Dimension keys:\n B: batch size\n T: number of input (conditioning) frames\n N: number of patches per frame\n M: model dimension\n S: sequence length\n H: height\n W: width\n E: B * (S - 1)\n """"""\n assert isinstance(self.dynamics, DynamicsCausal)\n # --- Encode videos and actions ---\n videos_BTHWC = batch[""videos""]\n tokenizer_out = self.tokenizer.vq_encode(videos_BTHWC, training=False)\n token_idxs_BTN = tokenizer_out[""indices""]\n B, T, N = token_idxs_BTN.shape\n pad_shape = (B, seq_len - T, N)\n pad = jnp.zeros(pad_shape, dtype=token_idxs_BTN.dtype)\n token_idxs_BSN = jnp.concatenate([token_idxs_BTN, pad], axis=1)\n logits_BSNV = jnp.zeros((*token_idxs_BSN.shape, self.num_patch_latents))\n dynamics_state = nnx.state(self.dynamics)\n\n if self.use_gt_actions:\n assert self.action_embed is not None\n latent_actions_BT1L = self.action_embed(batch[""actions""]).reshape(\n *batch[""actions""].shape[:2], 1, self.latent_action_dim\n )\n latent_actions_BTm11L = latent_actions_BT1L[:, 1:]\n action_tokens_EL = latent_actions_BTm11L.reshape(-1, self.latent_action_dim)\n else:\n assert self.lam is not None\n latent_actions_E = batch[""latent_actions""]\n action_tokens_EL = self.lam.vq.get_codes(latent_actions_E)\n\n @nnx.scan(in_axes=(nnx.Carry, 0), out_axes=nnx.Carry)\n def causal_step_fn(\n carry: tuple[jax.Array, jax.Array, jax.Array, jax.Array, jax.Array],\n step_n: jax.Array,\n ) -> tuple[jax.Array, jax.Array, jax.Array, jax.Array, jax.Array]:\n rng, token_idxs_BSN, logits_BSNV, action_tokens_EL, step_t = carry\n S, N = token_idxs_BSN.shape[1:]\n L = action_tokens_EL.shape[-1]\n\n # We need to reconstruct the submodule inside scan body to prevent trace context mismatches\n dynamics_causal = DynamicsCausal(\n model_dim=self.dyna_dim,\n ffn_dim=self.dyna_ffn_dim,\n num_latents=self.num_patch_latents,\n latent_action_dim=self.latent_action_dim,\n num_blocks=self.dyna_num_blocks,\n num_heads=self.dyna_num_heads,\n dropout=self.dropout,\n param_dtype=self.param_dtype,\n dtype=self.dtype,\n use_flash_attention=self.use_flash_attention,\n decode=self.decode,\n rngs=nnx.Rngs(0),\n )\n nnx.update(dynamics_causal, dynamics_state)\n\n # --- Construct + encode video ---\n vid_embed_BSNM = dynamics_causal.patch_embed(token_idxs_BSN)\n\n # --- Predict transition ---\n action_tokens_BSm1L = jnp.reshape(action_tokens_EL, (B, S - 1, L))\n act_embed_BSm1M = dynamics_causal.action_up(action_tokens_BSm1L)\n act_embed_BSM = jnp.pad(act_embed_BSm1M, ((0, 0), (1, 0), (0, 0)))\n act_embed_BS1M = jnp.reshape(\n act_embed_BSM, (B, S, 1, act_embed_BSM.shape[-1])\n )\n vid_embed_BSNp1M = jnp.concatenate([act_embed_BS1M, vid_embed_BSNM], axis=2)\n final_logits_BTNp1V = (\n dynamics_causal.transformer(vid_embed_BSNp1M, (step_t, step_n))\n / temperature\n )\n final_logits_BV = final_logits_BTNp1V[:, step_t, step_n, :]\n\n # --- Sample new tokens for final frame ---\n if sample_argmax:\n sampled_token_idxs_B = jnp.argmax(final_logits_BV, axis=-1)\n else:\n rng, _rng = jax.random.split(rng)\n sampled_token_idxs_B = jax.random.categorical(_rng, final_logits_BV)\n # Update next tokens only\n token_idxs_BSN = token_idxs_BSN.at[:, step_t, step_n].set(\n sampled_token_idxs_B\n )\n logits_BSNV = logits_BSNV.at[:, step_t, step_n].set(final_logits_BV)\n\n new_carry = (rng, token_idxs_BSN, logits_BSNV, action_tokens_EL, step_t)\n return new_carry\n\n @nnx.scan(in_axes=(nnx.Carry, 0), out_axes=nnx.Carry)\n def generation_step_fn(\n carry: tuple[jax.Array, jax.Array, jax.Array], step_t: jax.Array\n ) -> tuple[jax.Array, jax.Array, jax.Array]:\n rng, current_token_idxs_BSN, current_logits_BSNV = carry\n rng, step_rng = jax.random.split(rng)\n\n # --- Initialize and run causal loop ---\n init_carry_causal = (\n step_rng,\n current_token_idxs_BSN,\n current_logits_BSNV,\n action_tokens_EL,\n step_t,\n )\n final_carry_causal = causal_step_fn(init_carry_causal, jnp.arange(N))\n updated_token_idxs_BSN = final_carry_causal[1]\n updated_logits_BSNV = final_carry_causal[2]\n new_carry = (rng, updated_token_idxs_BSN, updated_logits_BSNV)\n return new_carry\n\n # --- Run the autoregressive generation using jax.lax.scan ---\n initial_carry = (batch[""rng""], token_idxs_BSN, logits_BSNV)\n timesteps_to_scan = jnp.arange(T, seq_len)\n final_carry = generation_step_fn(initial_carry, timesteps_to_scan)\n final_token_idxs_BSN = final_carry[1]\n final_logits_BSNV = final_carry[2]\n\n # --- Decode all tokens at once at the end ---\n H, W = batch[""videos""].shape[2:4]\n final_frames_BSHWC = self.tokenizer.decode(\n final_token_idxs_BSN,\n video_hw=(H, W),\n )\n return final_frames_BSHWC, final_logits_BSNV\n\n def vq_encode(self, batch: Dict[str, jax.Array], training: bool) -> jax.Array:\n # --- Preprocess videos ---\n assert self.lam is not None\n video_BTHWC = batch[""videos""]\n lam_output: Dict[str, jax.Array] = self.lam.vq_encode(\n video_BTHWC, training=training\n )\n lam_indices_E = lam_output[""indices""]\n return lam_indices_E\n\n\n# FIXME (f.srambical): add conversion script for old checkpoints\ndef restore_genie_components(\n optimizer: nnx.Optimizer,\n sharding: jax.sharding.NamedSharding,\n rng: jax.Array,\n args,\n) -> nnx.Optimizer:\n """"""Restore pre-trained Genie components""""""\n rng_tokenizer, rng_lam = jax.random.split(rng)\n rngs_tokenizer = nnx.Rngs(rng_tokenizer)\n rngs_lam = nnx.Rngs(rng_lam)\n\n tx = optimizer.tx\n model = optimizer.model\n handler_registry = ocp.handlers.DefaultCheckpointHandlerRegistry()\n handler_registry.add(\n ""model_state"", ocp.args.PyTreeRestore, ocp.handlers.PyTreeCheckpointHandler\n )\n\n checkpoint_options = ocp.CheckpointManagerOptions(\n step_format_fixed_length=6,\n )\n tokenizer_checkpoint_manager = ocp.CheckpointManager(\n directory=args.tokenizer_checkpoint,\n options=checkpoint_options,\n handler_registry=handler_registry,\n )\n dummy_tokenizer = TokenizerVQVAE(\n in_dim=args.image_channels,\n model_dim=args.tokenizer_dim,\n ffn_dim=args.tokenizer_ffn_dim,\n latent_dim=args.latent_patch_dim,\n num_latents=args.num_patch_latents,\n patch_size=args.patch_size,\n num_blocks=args.tokenizer_num_blocks,\n num_heads=args.tokenizer_num_heads,\n dropout=args.dropout,\n codebook_dropout=args.dropout,\n param_dtype=args.param_dtype,\n dtype=args.dtype,\n use_flash_attention=args.use_flash_attention,\n rngs=rngs_tokenizer,\n )\n dummy_tokenizer_optimizer = nnx.Optimizer(dummy_tokenizer, tx)\n dummy_tokenizer_optimizer_state = nnx.state(dummy_tokenizer_optimizer)\n abstract_sharded_tokenizer_optimizer_state = _create_abstract_sharded_pytree(\n dummy_tokenizer_optimizer_state, sharding\n )\n restored_tokenizer = tokenizer_checkpoint_manager.restore(\n step=tokenizer_checkpoint_manager.latest_step(),\n args=ocp.args.Composite(\n model_state=ocp.args.PyTreeRestore( # type: ignore\n abstract_sharded_tokenizer_optimizer_state # type: ignore\n ),\n ),\n )[""model_state""]\n nnx.update(dummy_tokenizer_optimizer.model, restored_tokenizer.model)\n model.tokenizer = dummy_tokenizer_optimizer.model\n tokenizer_checkpoint_manager.close()\n\n if args.lam_checkpoint:\n lam_checkpoint_manager = ocp.CheckpointManager(\n directory=args.lam_checkpoint,\n options=checkpoint_options,\n handler_registry=handler_registry,\n )\n dummy_lam = LatentActionModel(\n in_dim=args.image_channels,\n model_dim=args.lam_dim,\n ffn_dim=args.lam_ffn_dim,\n latent_dim=args.latent_patch_dim,\n num_latents=args.num_latent_actions,\n patch_size=args.lam_patch_size,\n num_blocks=args.lam_num_blocks,\n num_heads=args.lam_num_heads,\n dropout=args.dropout,\n codebook_dropout=args.dropout,\n param_dtype=args.param_dtype,\n dtype=args.dtype,\n use_flash_attention=args.use_flash_attention,\n rngs=rngs_lam,\n )\n dummy_lam_optimizer = nnx.Optimizer(dummy_lam, tx)\n dummy_lam_optimizer_state = nnx.state(dummy_lam_optimizer)\n abstract_sharded_lam_optimizer_state = _create_abstract_sharded_pytree(\n dummy_lam_optimizer_state, sharding\n )\n restored_lam_optimizer = lam_checkpoint_manager.restore(\n step=lam_checkpoint_manager.latest_step(),\n args=ocp.args.Composite(\n model_state=ocp.args.PyTreeRestore( # type: ignore\n abstract_sharded_lam_optimizer_state # type: ignore\n ),\n ),\n )[""model_state""]\n nnx.update(dummy_lam_optimizer.model, restored_lam_optimizer.model)\n model.lam = dummy_lam_optimizer.model\n # Remove the LAM decoder to save memory and avoid unnecessary computation.\n del model.lam.decoder\n lam_checkpoint_manager.close()\n\n # Reinitialize the optimizer states\n optimizer = nnx.Optimizer(model, tx)\n return optimizer\n\n\ndef _create_abstract_sharded_pytree(\n pytree_template: nnx.GraphState, sharding_spec: jax.sharding.NamedSharding\n) -> jax.Array:\n """"""Replaces arrays in a pytree with ShapeDtypeStructs having the given sharding.""""""\n\n def map_fn(leaf_template):\n if hasattr(leaf_template, ""shape"") and hasattr(leaf_template, ""dtype""):\n return jax.ShapeDtypeStruct(\n leaf_template.shape, leaf_template.dtype, sharding=sharding_spec\n )\n return leaf_template\n\n return jax.tree_util.tree_map(map_fn, pytree_template)\n",python,tab
|
| 3 |
+
2,136,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"10:54:11 AM [info] Activating crowd-code\n10:54:11 AM [info] Recording started\n10:54:11 AM [info] Initializing git provider using file system watchers...\n",Log,tab
|
| 4 |
+
3,172,"extension-output-pdoom-org.crowd-code-#1-crowd-code",153,0,"10:54:11 AM [info] Git repository found\n10:54:11 AM [info] Git provider initialized successfully\n10:54:11 AM [info] Initial git state: [object Object]\n",Log,content
|
| 5 |
+
4,4275,"TERMINAL",0,0,"",,terminal_command
|
| 6 |
+
5,8212,"genie.py",0,0,"",python,tab
|
| 7 |
+
6,9295,"TERMINAL",0,0,"ls /fast/project/HFMI_SynergyUnit/jafar_ws/data/breakout/train/",,terminal_command
|
| 8 |
+
7,9350,"TERMINAL",0,0,"]633;Cdata_0000.array_record data_0084.array_record data_0168.array_record data_0252.array_record data_0336.array_record data_0420.array_record data_0504.array_record data_0588.array_record\r\ndata_0001.array_record data_0085.array_record data_0169.array_record data_0253.array_record data_0337.array_record data_0421.array_record data_0505.array_record data_0589.array_record\r\ndata_0002.array_record data_0086.array_record data_0170.array_record data_0254.array_record data_0338.array_record data_0422.array_record data_0506.array_record data_0590.array_record\r\ndata_0003.array_record data_0087.array_record data_0171.array_record data_0255.array_record data_0339.array_record data_0423.array_record data_0507.array_record data_0591.array_record\r\ndata_0004.array_record data_0088.array_record data_0172.array_record data_0256.array_record data_0340.array_record data_0424.array_record data_0508.array_record data_0592.array_record\r\ndata_0005.array_record data_0089.array_record data_0173.array_record data_0257.array_record data_0341.array_record data_0425.array_record data_0509.array_record data_0593.array_record\r\ndata_0006.array_record data_0090.array_record data_0174.array_record data_0258.array_record data_0342.array_record data_0426.array_record data_0510.array_record data_0594.array_record\r\ndata_0007.array_record data_0091.array_record data_0175.array_record data_0259.array_record data_0343.array_record data_0427.array_record data_0511.array_record data_0595.array_record\r\ndata_0008.array_record data_0092.array_record data_0176.array_record data_0260.array_record data_0344.array_record data_0428.array_record data_0512.array_record data_0596.array_record\r\ndata_0009.array_record data_0093.array_record data_0177.array_record data_0261.array_record data_0345.array_record data_0429.array_record data_0513.array_record data_0597.array_record\r\ndata_0010.array_record data_0094.array_record data_0178.array_record data_0262.array_record data_0346.array_record data_0430.array_record data_0514.array_record data_0598.array_record\r\ndata_0011.array_record data_0095.array_record data_0179.array_record data_0263.array_record data_0347.array_record data_0431.array_record data_0515.array_record data_0599.array_record\r\ndata_0012.array_record data_0096.array_record data_0180.array_record data_0264.array_record data_0348.array_record data_0432.array_record data_0516.array_record data_0600.array_record\r\ndata_0013.array_record data_0097.array_record data_0181.array_record data_0265.array_record data_0349.array_record data_0433.array_record data_0517.array_record data_0601.array_record\r\ndata_0014.array_record data_0098.array_record data_0182.array_record data_0266.array_record data_0350.array_record data_0434.array_record data_0518.array_record data_0602.array_record\r\ndata_0015.array_record data_0099.array_record data_0183.array_record data_0267.array_record data_0351.array_record data_0435.array_record data_0519.array_record data_0603.array_record\r\ndata_0016.array_record data_0100.array_record data_0184.array_record data_0268.array_record data_0352.array_record data_0436.array_record data_0520.array_record data_0604.array_record\r\ndata_0017.array_record data_0101.array_record data_0185.array_record data_0269.array_record data_0353.array_record data_0437.array_record data_0521.array_record data_0605.array_record\r\ndata_0018.array_record data_0102.array_record data_0186.array_record data_0270.array_record data_0354.array_record data_0438.array_record data_0522.array_record data_0606.array_record\r\ndata_0019.array_record data_0103.array_record data_0187.array_record data_0271.array_record data_0355.array_record data_0439.array_record data_0523.array_record data_0607.array_record\r\ndata_0020.array_record data_0104.array_record data_0188.array_record data_0272.array_record data_0356.array_record data_0440.array_record data_0524.array_record data_0608.array_record\r\ndata_0021.array_record data_0105.array_record data_0189.array_record data_0273.array_record data_0357.array_record data_0441.array_record data_0525.array_record data_0609.array_record\r\ndata_0022.array_record data_0106.array_record data_0190.array_record data_0274.array_record data_0358.array_record data_0442.array_record data_0526.array_record data_0610.array_record\r\ndata_0023.array_record data_0107.array_record data_0191.array_record data_0275.array_record data_0359.array_record data_0443.array_record data_0527.array_record data_0611.array_record\r\ndata_0024.array_record data_0108.array_record data_0192.array_record data_0276.array_record data_0360.array_record data_0444.array_record data_0528.array_record data_0612.array_record\r\ndata_0025.array_record data_0109.array_record data_0193.array_record data_0277.array_record data_0361.array_record data_0445.array_record data_0529.array_record data_0613.array_record\r\ndata_0026.array_record data_0110.array_record data_0194.array_record data_0278.array_record data_0362.array_record data_0446.array_record data_0530.array_record data_0614.array_record\r\ndata_0027.array_record data_0111.array_record data_0195.array_record data_0279.array_record data_0363.array_record data_0447.array_record data_0531.array_record data_0615.array_record\r\ndata_0028.array_record data_0112.array_record data_0196.array_record data_0280.array_record data_0364.array_record data_0448.array_record data_0532.array_record data_0616.array_record\r\ndata_0029.array_record data_0113.array_record data_0197.array_record data_0281.array_record data_0365.array_record data_0449.array_record data_0533.array_record data_0617.array_record\r\ndata_0030.array_record data_0114.array_record data_0198.array_record data_0282.array_record data_0366.array_record data_0450.array_record data_0534.array_record data_0618.array_record\r\ndata_0031.array_record data_0115.array_record data_0199.array_record data_0283.array_record data_0367.array_record data_0451.array_record data_0535.array_record data_0619.array_record\r\ndata_0032.array_record data_0116.array_record data_0200.array_record data_0284.array_record data_0368.array_record data_0452.array_record data_0536.array_record data_0620.array_record\r\ndata_0033.array_record data_0117.array_record data_0201.array_record data_0285.array_record data_0369.array_record data_0453.array_record data_0537.array_record data_0621.array_record\r\ndata_0034.array_record data_0118.array_record data_0202.array_record data_0286.array_record data_0370.array_record data_0454.array_record data_0538.array_record data_0622.array_record\r\ndata_0035.array_record data_0119.array_record data_0203.array_record data_0287.array_record data_0371.array_record data_0455.array_record data_0539.array_record data_0623.array_record\r\ndata_0036.array_record data_0120.array_record data_0204.array_record data_0288.array_record data_0372.array_record data_0456.array_record data_0540.array_record data_0624.array_record\r\ndata_0037.array_record data_0121.array_record data_0205.array_record data_0289.array_record data_0373.array_record data_0457.array_record data_0541.array_record data_0625.array_record\r\ndata_0038.array_record data_0122.array_record data_0206.array_record data_0290.array_record data_0374.array_record data_0458.array_record data_0542.array_record data_0626.array_record\r\ndata_0039.array_record data_0123.array_record data_0207.array_record data_0291.array_record data_0375.array_record data_0459.array_record data_0543.array_record data_0627.array_record\r\ndata_0040.array_record data_0124.array_record data_0208.array_record data_0292.array_record data_0376.array_record data_0460.array_record data_0544.array_record data_0628.array_record\r\ndata_0041.array_record data_0125.array_record data_0209.array_record data_0293.array_record data_0377.array_record data_0461.array_record data_0545.array_record data_0629.array_record\r\ndata_0042.array_record data_0126.array_record data_0210.array_record data_0294.array_record data_0378.array_record data_0462.array_record data_0546.array_record data_0630.array_record\r\ndata_0043.array_record data_0127.array_record data_0211.array_record data_0295.array_record data_0379.array_record data_0463.array_record data_0547.array_record data_0631.array_record\r\ndata_0044.array_record data_0128.array_record data_0212.array_record data_0296.array_record data_0380.array_record data_0464.array_record data_0548.array_record data_0632.array_record\r\ndata_0045.array_record data_0129.array_record data_0213.array_record data_0297.array_record data_0381.array_record data_0465.array_record data_0549.array_record data_0633.array_record\r\ndata_0046.array_record data_0130.array_record data_0214.array_record data_0298.array_record data_0382.array_record data_0466.array_record data_0550.array_record data_0634.array_record\r\ndata_0047.array_record data_0131.array_record data_0215.array_record data_0299.array_record data_0383.array_record data_0467.array_record data_0551.array_record data_0635.array_record\r\ndata_0048.array_record data_0132.array_record data_0216.array_record data_0300.array_record data_0384.array_record data_0468.array_record data_0552.array_record data_0636.array_record\r\ndata_0049.array_record data_0133.array_record data_0217.array_record data_0301.array_record data_0385.array_record data_0469.array_record data_0553.array_record data_0637.array_record\r\ndata_0050.array_record data_0134.array_record data_0218.array_record data_0302.array_record data_0386.array_record data_0470.array_record data_0554.array_record data_0638.array_record\r\ndata_0051.array_record data_0135.array_record data_0219.array_record data_0303.array_record data_0387.array_record data_0471.array_record data_0555.array_record data_0639.array_record\r\ndata_0052.array_record data_0136.array_record data_0220.array_record data_0304.array_record data_0388.array_record data_0472.array_record data_0556.array_record data_0640.array_record\r\ndata_0053.array_record data_0137.array_record data_0221.array_record data_0305.array_record data_0389.array_record data_0473.array_record data_0557.array_record data_0641.array_record\r\ndata_0054.array_record data_0138.array_record data_0222.array_record data_0306.array_record data_0390.array_record data_0474.array_record data_0558.array_record data_0642.array_record\r\ndata_0055.array_record data_0139.array_record data_0223.array_record data_0307.array_record data_0391.array_record data_0475.array_record data_0559.array_record data_0643.array_record\r\ndata_0056.array_record data_0140.array_record data_0224.array_record data_0308.array_record data_0392.array_record data_0476.array_record data_0560.array_record data_0644.array_record\r\ndata_0057.array_record data_0141.array_record data_0225.array_record data_0309.array_record data_0393.array_record data_0477.array_record data_0561.array_record data_0645.array_record\r\ndata_0058.array_record data_0142.array_record data_0226.array_record data_0310.array_record data_0394.array_record data_0478.array_record data_0562.array_record data_0646.array_record\r\ndata_0059.array_record data_0143.array_record data_0227.array_record data_0311.array_record data_0395.array_record data_0479.array_record data_0563.array_record data_0647.array_record\r\ndata_0060.array_record data_0144.array_record data_0228.array_record data_0312.array_record data_0396.array_record data_0480.array_record data_0564.array_record data_0648.array_record\r\ndata_0061.array_record data_0145.array_record data_0229.array_record data_0313.array_record data_0397.array_record data_0481.array_record data_0565.array_record data_0649.array_record\r\ndata_0062.array_record data_0146.array_record data_0230.array_record data_0314.array_record data_0398.array_record data_0482.array_record data_0566.array_record data_0650.array_record\r\ndata_0063.array_record data_0147.array_record data_0231.array_record data_0315.array_record data_0399.array_record data_0483.array_record data_0567.array_record data_0651.array_record\r\ndata_0064.array_record data_0148.array_record data_0232.array_record data_0316.array_record data_0400.array_record data_0484.array_record data_0568.array_record data_0652.array_record\r\ndata_0065.array_record data_0149.array_record data_0233.array_record data_0317.array_record data_0401.array_record data_0485.array_record data_0569.array_record data_0653.array_record\r\ndata_0066.array_record data_0150.array_record data_0234.array_record data_0318.array_record data_0402.array_record data_0486.array_record data_0570.array_record data_0654.array_record\r\ndata_0067.array_record data_0151.array_record data_0235.array_record data_0319.array_record data_0403.array_record data_0487.array_record data_0571.array_record data_0655.array_record\r\ndata_0068.array_record data_0152.array_record data_0236.array_record data_0320.array_record data_0404.array_record data_0488.array_record data_0572.array_record data_0656.array_record\r\ndata_0069.array_record data_0153.array_record data_0237.array_record data_0321.array_record data_0405.array_record data_0489.array_record data_0573.array_record data_0657.array_record\r\ndata_0070.array_record data_0154.array_record data_0238.array_record data_0322.array_record data_0406.array_record data_0490.array_record data_0574.array_record data_0658.array_record\r\ndata_0071.array_record data_0155.array_record data_0239.array_record data_0323.array_record data_0407.array_record data_0491.array_record data_0575.array_record data_0659.array_record\r\ndata_0072.array_record data_0156.array_record data_0240.array_record data_0324.array_record data_0408.array_record data_0492.array_record data_0576.array_record data_0660.array_record\r\ndata_0073.array_record data_0157.array_record data_0241.array_record data_0325.array_record data_0409.array_record data_0493.array_record data_0577.array_record data_0661.array_record\r\ndata_0074.array_record data_0158.array_record data_0242.array_record data_0326.array_record data_0410.array_record data_0494.array_record data_0578.array_record data_0662.array_record\r\ndata_0075.array_record data_0159.array_record data_0243.array_record data_0327.array_record data_0411.array_record data_0495.array_record data_0579.array_record data_0663.array_record\r\ndata_0076.array_record data_0160.array_record data_0244.array_record data_0328.array_record data_0412.array_record data_0496.array_record data_0580.array_record data_0664.array_record\r\ndata_0077.array_record data_0161.array_record data_0245.array_record data_0329.array_record data_0413.array_record data_0497.array_record data_0581.array_record\r\ndata_0078.array_record data_0162.array_record data_0246.array_record data_0330.array_record data_0414.array_record data_0498.array_record data_0582.array_record\r\ndata_0079.array_record data_0163.array_record data_0247.array_record data_0331.array_record data_0415.array_record data_0499.array_record data_0583.array_record\r\ndata_0080.array_record data_0164.array_record data_0248.array_record data_0332.array_record data_0416.array_record data_0500.array_record data_0584.array_record\r\ndata_0081.array_record data_0165.array_record data_0249.array_record data_0333.array_record data_0417.array_record data_0501.array_record data_0585.array_record\r\ndata_0082.array_record data_0166.array_record data_0250.array_record data_0334.array_record data_0418.array_record data_0502.array_record data_0586.array_record\r\ndata_0083.array_record data_0167.array_record data_0251.array_record data_0335.array_record data_0419.array_record data_0503.array_record data_0587.array_record\r\n]0;franz.srambical@hai-login2:~/jafar",,terminal_output
|
| 9 |
+
8,10583,"TERMINAL",0,0,"",,terminal_command
|
| 10 |
+
9,118684,"TERMINAL",0,0,"",,terminal_command
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-0692028e-98ba-48e2-9ebc-ba3f1c4cd5a21759257473788-2025_09_30-20.38.00.177/source.csv
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
2,169,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"8:38:00 PM [info] Activating crowd-code\n8:38:00 PM [info] Recording started\n8:38:00 PM [info] Initializing git provider using file system watchers...\n8:38:00 PM [info] Git repository found\n8:38:00 PM [info] Git provider initialized successfully\n8:38:00 PM [info] Initial git state: [object Object]\n",Log,tab
|
| 3 |
+
3,5360,"TERMINAL",0,0,"",,terminal_command
|
| 4 |
+
4,12136,"TERMINAL",0,0,"",,terminal_command
|
| 5 |
+
5,69015,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"",Log,tab
|
| 6 |
+
6,78165,"TERMINAL",0,0,"",,terminal_focus
|
| 7 |
+
7,86274,"TERMINAL",0,0,"git pull",,terminal_command
|
| 8 |
+
8,86329,"TERMINAL",0,0,"]633;C",,terminal_output
|
| 9 |
+
9,87717,"TERMINAL",0,0,"[33mhint: You have divergent branches and need to specify how to reconcile them.[m\r\n[33mhint: You can do so by running one of the following commands sometime before[m\r\n[33mhint: your next pull:[m\r\n[33mhint:[m\r\n[33mhint: git config pull.rebase false # merge[m\r\n[33mhint: git config pull.rebase true # rebase[m\r\n[33mhint: git config pull.ff only # fast-forward only[m\r\n[33mhint:[m\r\n[33mhint: You can replace ""git config"" with ""git config --global"" to set a default[m\r\n[33mhint: preference for all repositories. You can also pass --rebase, --no-rebase,[m\r\n[33mhint: or --ff-only on the command line to override the configured default per[m\r\n[33mhint: invocation.[m\r\nfatal: Need to specify how to reconcile divergent branches.\r\n]0;franz.srambical@hai-login1:~/jafar/slurm",,terminal_output
|
| 10 |
+
10,95773,"TERMINAL",0,0,"git config pull.rebase false",,terminal_command
|
| 11 |
+
11,95780,"TERMINAL",0,0,"]633;C]0;franz.srambical@hai-login1:~/jafar/slurm",,terminal_output
|
| 12 |
+
12,96798,"TERMINAL",0,0,"git pull",,terminal_command
|
| 13 |
+
13,96850,"TERMINAL",0,0,"]633;C",,terminal_output
|
| 14 |
+
14,105808,"TERMINAL",0,0,"hint: Waiting for your editor to close the file... [?1049h[22;0;0t[>4;2m[?1h=[?2004h[?1004h[1;14r[?12h[?12l[22;2t[22;1t[27m[23m[29m[m[H[2J[?25l[14;1H""~/jafar/slurm/.git/MERGE_MSG"" 6L, 273B[2;1H▽[6n[2;1H [3;1HPzz\[0%m[6n[3;1H [1;1H[>c]10;?]11;?[1;1H[38;5;130mMerge branch 'main' of github.com:p-doom/slurm[m\r\n[34m# Please enter a commit message to explain why this merge is necessary,[m[2;72H[K[3;1H[34m# especially if it merges an updated upstream into a topic branch.[m[3;67H[K[4;1H[34m#\r\n# Lines starting with '#' will be ignored, and an empty message aborts\r\n# the commit.[m\r\n[94m~ [8;1H~ [9;1H~ [10;1H~ [11;1H~ [12;1H~ [13;1H~ [m[14;117H1,1[11CAll[1;1H[?25hP+q436f\P+q6b75\P+q6b64\P+q6b72\P+q6b6c\P+q2332\P+q2334\P+q2569\P+q2a37\P+q6b31\[?12$p[?25l[14;107H/[1;1H[14;108H3[1;1H[14;109Hb[1;1H[14;110H3[1;1H[14;111Hb[1;1H[14;112H/[1;1H[14;113H3[1;1H[14;114Hb[1;1H[14;115H3[1;1H[14;116Hb[1;1H[14;107H [1;1H[?25h[?25l[14;107H/[1;1H[14;108Hf[1;1H[14;109H8[1;1H[14;110Hf[1;1H[14;111H8[1;1H[14;112H/[1;1H[14;113Hf[1;1H[14;114H8[1;1H[14;115Hf[1;1H[14;116H8[1;1H[14;107H [1;1H[?25h",,terminal_output
|
| 15 |
+
15,110961,"TERMINAL",0,0,"[?25l[14;107H:[1;1H[14;1H[K[14;1H:[?25h",,terminal_output
|
| 16 |
+
16,111345,"TERMINAL",0,0,"w",,terminal_output
|
| 17 |
+
17,111364,"TERMINAL",0,0,"q",,terminal_output
|
| 18 |
+
18,111726,"TERMINAL",0,0,"\r[?25l[?2004l[>4;m"".git/MERGE_MSG"" 6L, 273B written\r[23;2t[23;1t\r\r\n[?1004l[?2004l[?1l>[?25h[>4;m[?1049l[23;0;0t\r[KMerge made by the 'ort' strategy.\r\n",,terminal_output
|
| 19 |
+
19,111773,"TERMINAL",0,0," jobs/franz/berlin/coinrun/mila_submission/ablations/coinrun_dynamics_causal.sh | 71 [32m++++++++++++++++++++++++++++++++++++[m\r\n .../berlin/coinrun/mila_submission/ablations/coinrun_dynamics_ffn_dim_ablation.sh | 72 [32m+++++++++++++++++++++++++++++++++++++[m\r\n jobs/franz/berlin/coinrun/mila_submission/ablations/coinrun_dynamics_gt_actions.sh | 71 [32m++++++++++++++++++++++++++++++++++++[m\r\n .../franz/berlin/coinrun/mila_submission/ablations/coinrun_dynamics_no_cotraining.sh | 72 [32m+++++++++++++++++++++++++++++++++++++[m\r\n .../franz/berlin/coinrun/mila_submission/ablations/coinrun_dynamics_no_flash_attn.sh | 71 [32m++++++++++++++++++++++++++++++++++++[m\r\n jobs/mihir/horeka/breakout/noise_schedule_runs/causal/train_dyn_single_gpu._sh | 67 [32m++++++++++++++++++++++++++++++++++[m\r\n jobs/mihir/horeka/breakout/noise_schedule_runs/causal/train_dyn_single_gpu_50k.sh | 65 [32m+++++++++++++++++++++++++++++++++[m\r\n .../breakout/noise_schedule_runs/causal/train_dyn_single_gpu_50k_no_noise_aug.sh | 66 [32m++++++++++++++++++++++++++++++++++[m\r\n .../horeka/breakout/noise_schedule_runs/causal/train_dyn_single_gpu_gt_actions._sh | 63 [32m++++++++++++++++++++++++++++++++[m\r\n .../breakout/noise_schedule_runs/causal/train_dyn_single_gpu_gt_actions_50k.sh | 61 [32m+++++++++++++++++++++++++++++++[m\r\n .../noise_schedule_runs/causal/train_dyn_single_gpu_gt_actions_smaller_lr_50k._sh | 61 [32m+++++++++++++++++++++++++++++++[m\r\n .../horeka/breakout/noise_schedule_runs/causal/train_dyn_single_gpu_no_noise_aug._sh | 68 [32m+++++++++++++++++++++++++++++++++++[m\r\n .../breakout/noise_schedule_runs/causal/train_dyn_single_gpu_smaller_lr_50k._sh | 65 [32m+++++++++++++++++++++++++++++++++[m\r\n jobs/mihir/horeka/breakout/noise_schedule_runs/full-prec/train_dyn_single_gpu.sh | 2 [31m--[m\r\n jobs/mihir/horeka/coinrun/ablations/train_dyn_default-grain-ablation.sh | 81 [32m+++++++++++++++++++++++++++++++++++++++++[m\r\n jobs/mihir/horeka/coinrun/ablations/train_dyn_default-no-noise-main.sh | 81 [32m+++++++++++++++++++++++++++++++++++++++++[m\r\n jobs/mihir/horeka/coinrun/ablations/train_dyn_default-no-noise.sh | 82 [32m++++++++++++++++++++++++++++++++++++++++++[m\r\n jobs/mihir/horeka/coinrun/ablations/train_dyn_default-sqrt-ablation.sh | 81 [32m+++++++++++++++++++++++++++++++++++++++++[m\r\n jobs/mihir/horeka/coinrun/default_runs/train_dyn_default.sh | 81 [32m+++++++++++++++++++++++++++++++++++++++++[m\r\n jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh | 5 [32m++[m[31m-[m\r\n jobs/mihir/horeka/coinrun/default_runs/train_tokenizer_default.sh | 32 [32m++++++++++++++[m[31m---[m\r\n jobs/mihir/horeka/minecraft/default_runs/train_lam_8_nodes.sbatch | 70 [32m++++++++++++++++++++++++++++++++++++[m\r\n jobs/mihir/horeka/minecraft/default_runs/train_tokenizer_8_nodes.sbatch | 71 [32m++++++++++++++++++++++++++++++++++++[m\r\n jobs/mihir/horeka/preprocessing/coinrun_chunked.sh | 11 [32m+++[m[31m---[m\r\n jobs/mihir/horeka/preprocessing/coinrun_chunked_500m.sh | 21 [32m+++++++++++[m\r\n jobs/mihir/horeka/preprocessing/doom_chunked.sh | 23 [32m++++++++++++[m\r\n 26 files changed, 1499 insertions(+), 15 deletions(-)\r\n create mode 100644 jobs/franz/berlin/coinrun/mila_submission/ablations/coinrun_dynamics_causal.sh\r\n create mode 100644 jobs/franz/berlin/coinrun/mila_submission/ablations/coinrun_dynamics_ffn_dim_ablation.sh\r\n create mode 100644 jobs/franz/berlin/coinrun/mila_submission/ablations/coinrun_dynamics_gt_actions.sh\r\n create mode 100644 jobs/franz/berlin/coinrun/mila_submission/ablations/coinrun_dynamics_no_cotraining.sh\r\n create mode 100644 jobs/franz/berlin/coinrun/mila_submission/ablations/coinrun_dynamics_no_flash_attn.sh\r\n create mode 100644 jobs/mihir/horeka/breakout/noise_schedule_runs/causal/train_dyn_single_gpu._sh\r\n create mode 100644 jobs/mihir/horeka/breakout/noise_schedule_runs/causal/train_dyn_single_gpu_50k.sh\r\n create mode 100644 jobs/mihir/horeka/breakout/noise_schedule_runs/causal/train_dyn_single_gpu_50k_no_noise_aug.sh\r\n create mode 100644 jobs/mihir/horeka/breakout/noise_schedule_runs/causal/train_dyn_single_gpu_gt_actions._sh\r\n create mode 100644 jobs/mihir/horeka/breakout/noise_schedule_runs/causal/train_dyn_single_gpu_gt_actions_50k.sh\r\n create mode 100644 jobs/mihir/horeka/breakout/noise_schedule_runs/causal/train_dyn_single_gpu_gt_actions_smaller_lr_50k._sh\r\n create mode 100644 jobs/mihir/horeka/breakout/noise_schedule_runs/causal/train_dyn_single_gpu_no_noise_aug._sh\r\n create mode 100644 jobs/mihir/horeka/breakout/noise_schedule_runs/causal/train_dyn_single_gpu_smaller_lr_50k._sh\r\n create mode 100644 jobs/mihir/horeka/coinrun/ablations/train_dyn_default-grain-ablation.sh\r\n create mode 100644 jobs/mihir/horeka/coinrun/ablations/train_dyn_default-no-noise-main.sh\r\n create mode 100644 jobs/mihir/horeka/coinrun/ablations/train_dyn_default-no-noise.sh\r\n create mode 100644 jobs/mihir/horeka/coinrun/ablations/train_dyn_default-sqrt-ablation.sh\r\n create mode 100644 jobs/mihir/horeka/coinrun/default_runs/train_dyn_default.sh\r\n create mode 100644 jobs/mihir/horeka/minecraft/default_runs/train_lam_8_nodes.sbatch\r\n create mode 100644 jobs/mihir/horeka/minecraft/default_runs/train_tokenizer_8_nodes.sbatch\r\n create mode 100644 jobs/mihir/horeka/preprocessing/coinrun_chunked_500m.sh\r\n create mode 100644 jobs/mihir/horeka/preprocessing/doom_chunked.sh\r\n]0;franz.srambical@hai-login1:~/jafar/slurm",,terminal_output
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-12f40b2b-48a7-497c-a003-dd2d4f41983d1765533231519-2025_12_12-10.53.56.404/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-1b85b896-114f-4adc-b559-52f92a3a305a1762181559268-2025_11_03-15.52.54.585/source.csv
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
1,3,"/home/franz.srambical/jafar/slurm/jobs/franz/berlin/atari/data_upload/upload_to_hf.sh",0,0,"#!/usr/bin/env bash\n\n#SBATCH --nodes=1\n#SBATCH --ntasks-per-node=1\n#SBATCH --time=24:00:00\n#SBATCH --cpus-per-task=8\n#SBATCH --gres=gpu:1\n#SBATCH --output=/fast/project/HFMI_SynergyUnit/jafar_ws/logs/franz/atari/data_upload/%x_%j.log\n#SBATCH --error=/fast/project/HFMI_SynergyUnit/jafar_ws/logs/franz/atari/data_upload/%x_%j.log\n#SBATCH --job-name=upload_to_hf\n\nsource .venv/bin/activate\n\npython slurm/utils/mihir/upload_hf_dataset.py /fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/alien p-doom/atari-alien-dataset --repo-type dataset\npython slurm/utils/mihir/upload_hf_dataset.py /fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/amidar p-doom/atari-amidar-dataset --repo-type dataset\npython slurm/utils/mihir/upload_hf_dataset.py /fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/assault p-doom/atari-assault-dataset --repo-type dataset\npython slurm/utils/mihir/upload_hf_dataset.py /fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/asterix p-doom/atari-asterix-dataset --repo-type dataset\npython slurm/utils/mihir/upload_hf_dataset.py /fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/bank_heist p-doom/atari-bank_heist-dataset --repo-type dataset\npython slurm/utils/mihir/upload_hf_dataset.py /fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/battle_zone p-doom/atari-battle_zone-dataset --repo-type dataset\npython slurm/utils/mihir/upload_hf_dataset.py /fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/boxing p-doom/atari-boxing-dataset --repo-type dataset\npython slurm/utils/mihir/upload_hf_dataset.py /fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/breakout p-doom/atari-breakout-dataset --repo-type dataset\npython slurm/utils/mihir/upload_hf_dataset.py /fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/chopper_command p-doom/atari-chopper_command-dataset --repo-type dataset\npython slurm/utils/mihir/upload_hf_dataset.py /fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/crazy_climber p-doom/atari-crazy_climber-dataset --repo-type dataset\npython slurm/utils/mihir/upload_hf_dataset.py /fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/demon_attack p-doom/atari-demon_attack-dataset --repo-type dataset\npython slurm/utils/mihir/upload_hf_dataset.py /fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/pong p-doom/atari-pong-dataset --repo-type dataset",shellscript,tab
|
| 3 |
+
2,399,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"3:52:54 PM [info] Activating crowd-code\n3:52:54 PM [info] Recording started\n3:52:54 PM [info] Initializing git provider using file system watchers...\n",Log,tab
|
| 4 |
+
3,602,"extension-output-pdoom-org.crowd-code-#1-crowd-code",150,0,"3:52:54 PM [info] Git repository found\n3:52:54 PM [info] Git provider initialized successfully\n3:52:54 PM [info] Initial git state: [object Object]\n",Log,content
|
| 5 |
+
4,765849,"/home/franz.srambical/jafar/slurm/jobs/franz/berlin/atari/data_upload/upload_to_hf.sh",0,0,"",shellscript,tab
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-1c973de0-6be0-4d96-a6b9-3da6c2c9d2721756538623658-2025_08_30-08.23.47.981/source.csv
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
2,48,"tasks",0,0,"",Log,tab
|
| 3 |
+
3,96,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"",Log,tab
|
| 4 |
+
4,1503,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"8:23:47 AM [info] Activating crowd-code\n8:23:47 AM [info] Recording started\n8:23:47 AM [info] Initializing git provider using file system watchers...\n8:23:47 AM [info] No workspace folder found\n",Log,content
|
| 5 |
+
5,2029,"extension-output-pdoom-org.crowd-code-#1-crowd-code",194,0,"8:23:49 AM [info] Retrying git provider initialization...\n8:23:49 AM [info] No workspace folder found\n",Log,content
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-1ebafea1-3b03-42e3-9fcb-f77691a4a6661758882427735-2025_09_26-12.27.24.970/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-20194a13-4640-4c1b-9e26-6b88dd86963a1766586898739-2025_12_24-15.35.09.94/source.csv
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
1,2,"scripts/run-sft-torchrun.sh",0,0,"#!/bin/bash\n#\n# Ray-free SFT Training Script\n#\nexport PYTHONUNBUFFERED=1\nexport PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True\n# FIXME(f.srambical): this is hardcoded for now\nGPUS_PER_NODE=${SLURM_GPUS_ON_NODE}\nNUM_NODES=${SLURM_JOB_NUM_NODES}\nNODE_RANK=${SLURM_NODEID}\nMASTER_ADDR=${MASTER_ADDR:-$(scontrol show hostnames $SLURM_JOB_NODELIST | head -n 1)}\n\nNVLINK_COUNT=$(nvidia-smi | grep -o ""NVLink"" | wc -l)\nif [ ""$NVLINK_COUNT"" -gt 0 ]; then\n HAS_NVLINK=1\nelse\n HAS_NVLINK=0\nfi\necho ""HAS_NVLINK: $HAS_NVLINK (detected $NVLINK_COUNT NVLink references)""\n\nexport NCCL_DEBUG=INFO\nexport TORCH_DISTRIBUTED_DEBUG=INFO\n\nSCRIPT_DIR=""$(cd -- ""$(dirname -- ""${BASH_SOURCE[0]}"")"" &>/dev/null && pwd)""\n\nRUN_ID=${RUN_ID:-""run_$(date +%Y%m%d_%H%M%S)""}\nLOAD_PATH=""/fast/project/HFMI_SynergyUnit/tab_model/huggingface/Qwen3-0.6B""\nSAVE_PATH=""/fast/project/HFMI_SynergyUnit/tab_model/huggingface/shared_data/${RUN_ID}/checkpoints""\n\nCKPT_ARGS=(\n --hf-checkpoint /fast/project/HFMI_SynergyUnit/tab_model/huggingface/Qwen3-0.6B\n --load ${LOAD_PATH}\n --ref-load /fast/project/HFMI_SynergyUnit/tab_model/huggingface/Qwen3-0.6B\n --save ${SAVE_PATH}\n --save-interval 1000\n)\n\nSFT_ARGS=(\n --rollout-function-path miles.rollout.sft_rollout.generate_rollout\n --prompt-data /fast/project/HFMI_SynergyUnit/tab_model/huggingface/nemo_hf_part_jsonl_4k_tokens.jsonl\n --val-prompt-data /fast/project/HFMI_SynergyUnit/tab_model/huggingface/nemo_hf_part_jsonl_4k_tokens_validation.jsonl\n --val-interval 1000\n --val-steps 100\n --input-key messages\n --apply-chat-template\n --rollout-shuffle\n --num-rollout 10000\n --rollout-batch-size 16\n --global-batch-size 16\n\n --loss-type sft_loss\n --calculate-per-token-loss\n --disable-compute-advantages-and-returns\n)\n\nLORA_ARGS=(\n --use-lora\n --lora-rank 8\n --lora-alpha 16\n --lora-dropout 0.0\n --lora-target-modules q_proj v_proj\n)\n\nOPTIMIZER_ARGS=(\n --optimizer adam\n --lr 1e-4\n --lr-decay-style WSD\n --lr-wsd-decay-style linear\n --lr-warmup-iters 500\n --lr-decay-iters 10000\n --lr-wsd-decay-iters 2000\n --weight-decay 0.1\n --adam-beta1 0.9\n --adam-beta2 0.98\n)\n\nWANDB_ARGS=(\n --use-wandb\n --wandb-project crowd-pilot-miles\n --wandb-team instant-uv\n --wandb-group qwen3-0.6b-sft-torchrun\n)\n\nTRAIN_BACKEND_ARGS=(\n --train-backend fsdp\n --update-weight-buffer-size 536870912\n --attn-implementation flash_attention_3\n)\n\nPERF_ARGS=(\n --use-dynamic-batch-size\n --max-tokens-per-gpu 9216\n)\n\nMISC_ARGS=(\n --rollout-max-context-len 8192\n --rollout-max-prompt-len 8000\n --rollout-max-response-len 8192\n --dump-details /fast/project/HFMI_SynergyUnit/tab_model/huggingface/shared_data/qwen3-600M-fsdp-1116-noref/dump_details\n)\n\ntorchrun \\n --nproc_per_node=${GPUS_PER_NODE} \\n --nnodes=${NUM_NODES} \\n --node_rank=${NODE_RANK} \\n --master_addr=${MASTER_ADDR} \\n --master_port=${MASTER_PORT:-29500} \\n train_sft.py \\n ${CKPT_ARGS[@]} \\n ${SFT_ARGS[@]} \\n ${LORA_ARGS[@]} \\n ${OPTIMIZER_ARGS[@]} \\n ${WANDB_ARGS[@]} \\n ${TRAIN_BACKEND_ARGS[@]} \\n ${PERF_ARGS[@]} \\n ${MISC_ARGS[@]}\n",shellscript,tab
|
| 3 |
+
2,128,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"3:35:09 PM [info] Activating crowd-code\n3:35:09 PM [info] Recording started\n3:35:09 PM [info] Initializing git provider using file system watchers...\n",Log,tab
|
| 4 |
+
3,175,"extension-output-pdoom-org.crowd-code-#1-crowd-code",150,0,"3:35:09 PM [info] Git repository found\n3:35:09 PM [info] Git provider initialized successfully\n3:35:09 PM [info] Initial git state: [object Object]\n",Log,content
|
| 5 |
+
4,538023,"TERMINAL",0,0,"",,terminal_focus
|
| 6 |
+
5,538025,"scripts/run-sft-torchrun.sh",0,0,"",shellscript,tab
|
| 7 |
+
6,538730,"TERMINAL",0,0,"source /home/franz.srambical/miles/.venv/bin/activate",,terminal_command
|
| 8 |
+
7,538739,"TERMINAL",0,0,"]633;C]0;franz.srambical@hai-login2:~/miles",,terminal_output
|
| 9 |
+
8,539525,"TERMINAL",0,0,"squeue",,terminal_command
|
| 10 |
+
9,539548,"TERMINAL",0,0,"]633;C JOBID USER PARTITION NODES CPUS ST SUBMIT_TIME START_TIME TIME TIME_LIMIT NODELIST(REASON)\r\n 38543 xiao.liu interacti 1 64 PD 2025-12-24T10:38:15 2025-12-24T16:01:06 0:00 23:59:00 (Resources)\r\n 38561 alfred.ngu interacti 1 4 PD 2025-12-24T15:38:02 N/A 0:00 2:00:00 (Priority)\r\n 38556 mihir.maha interacti 1 2 R 2025-12-24T13:44:18 2025-12-24T13:44:22 1:59:46 2:00:00 hai006\r\n 38526 xiao.liu interacti 1 128 R 2025-12-24T01:52:12 2025-12-24T01:52:12 13:51:56 23:59:00 hai002\r\n 38525 xiao.liu interacti 1 128 R 2025-12-24T01:51:21 2025-12-24T01:51:21 13:52:47 23:59:00 hai003\r\n 38518 franz.sram interacti 1 200 R 2025-12-23T21:54:04 2025-12-23T21:54:04 17:50:04 1-00:00:00 hai007\r\n 38505 xiao.liu interacti 1 128 R 2025-12-23T16:02:06 2025-12-23T16:02:06 23:42:02 23:59:00 hai006\r\n 38527 nishant.ku standard 3 624 R 2025-12-24T02:30:11 2025-12-24T10:38:14 5:05:54 1-00:00:00 hai[001,004-005]\r\n 38528 xiao.liu standard 1 128 R 2025-12-24T03:28:17 2025-12-24T03:28:18 12:15:50 23:59:00 hai008\r\n]0;franz.srambical@hai-login2:~/miles",,terminal_output
|
| 11 |
+
10,544358,"TERMINAL",0,0,"scancel --me",,terminal_command
|
| 12 |
+
11,544386,"TERMINAL",0,0,"]633;C]0;franz.srambical@hai-login2:~/miles",,terminal_output
|
| 13 |
+
12,571012,"TERMINAL",0,0,"squeue",,terminal_command
|
| 14 |
+
13,571017,"TERMINAL",0,0,"]633;C JOBID USER PARTITION NODES CPUS ST SUBMIT_TIME START_TIME TIME TIME_LIMIT NODELIST(REASON)\r\n 38518 franz.sram interacti 1 200 CG 2025-12-23T21:54:04 2025-12-23T21:54:04 17:50:09 1-00:00:00 hai007\r\n 38543 xiao.liu interacti 1 64 PD 2025-12-24T10:38:15 2025-12-24T15:44:40 0:00 23:59:00 (Resources)\r\n 38561 alfred.ngu interacti 1 4 PD 2025-12-24T15:38:02 N/A 0:00 2:00:00 (Priority)\r\n 38556 mihir.maha interacti 1 2 R 2025-12-24T13:44:18 2025-12-24T13:44:22 2:00:18 2:00:00 hai006\r\n 38526 xiao.liu interacti 1 128 R 2025-12-24T01:52:12 2025-12-24T01:52:12 13:52:28 23:59:00 hai002\r\n 38525 xiao.liu interacti 1 128 R 2025-12-24T01:51:21 2025-12-24T01:51:21 13:53:19 23:59:00 hai003\r\n 38505 xiao.liu interacti 1 128 R 2025-12-23T16:02:06 2025-12-23T16:02:06 23:42:34 23:59:00 hai006\r\n 38527 nishant.ku standard 3 624 R 2025-12-24T02:30:11 2025-12-24T10:38:14 5:06:26 1-00:00:00 hai[001,004-005]\r\n 38528 xiao.liu standard 1 128 R 2025-12-24T03:28:17 2025-12-24T03:28:18 12:16:22 23:59:00 hai008\r\n]0;franz.srambical@hai-login2:~/miles",,terminal_output
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-3334d6a5-5e72-43ad-a8da-1813285fd7a51758271588339-2025_09_19-10.46.34.637/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-33fc4e7e-94fe-43e5-b385-1c4730f8870e1767605900421-2026_01_05-10.38.50.565/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-3bffc30a-6fb0-48dd-ab21-3fe225eb22c51757148592262-2025_09_06-10.49.57.58/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-3cc4c729-59f0-4fab-9ef2-7e984f91ed9a1756976763530-2025_09_04-11.06.10.579/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-41b9d3a7-e49d-4fb5-ac82-5e55b78f6f611761398957344-2025_10_25-15.29.41.853/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-4d667d63-df3b-4c2f-9829-cbc24fb4ff5d1767609520115-2026_01_05-11.38.46.560/source.csv
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
1,3,"/home/franz.srambical/slurm/dev/franz/berlin/crowd-pilot/crowd_pilot_serializer/serialize_16k_glm.sh",0,0,"./target/release/crowd-pilot-serialize \\n--csv-root=""/fast/project/HFMI_SynergyUnit/tab_model/data/hf_part_csv/"" \\n--output-dir=""/fast/project/HFMI_SynergyUnit/tab_model/data/glm/miles_hf_part_jsonl_16k_tokens/"" \\n--max-tokens-per-conversation 16384 \\n--tokenizer=""zai-org/GLM-4.5-Air""\n",shellscript,tab
|
| 3 |
+
2,214,"tasks",0,0,"",Log,tab
|
| 4 |
+
3,215,"/home/franz.srambical/slurm/dev/franz/berlin/crowd-pilot/crowd_pilot_serializer/serialize_16k_glm.sh",0,0,"",shellscript,tab
|
| 5 |
+
4,222,"TERMINAL",0,0,"",,terminal_focus
|
| 6 |
+
5,235,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"11:38:46 AM [info] Activating crowd-code\n11:38:46 AM [info] Recording started\n11:38:46 AM [info] Initializing git provider using file system watchers...\n11:38:46 AM [info] Git repository found\n11:38:46 AM [info] Git provider initialized successfully\n11:38:46 AM [info] Initial git state: [object Object]\n",Log,tab
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-53781591-135c-4837-bb7b-7551872ec06a1763025484154-2025_11_13-10.18.11.147/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-59175e55-ecae-446f-be12-8861032d4f481751613426266-2025_07_04-09.17.44.620/source.csv
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
1,5,"tests/test_checkpointer.py",0,0,"import unittest\nimport tempfile\nimport os\nimport jax\nimport jax.numpy as jnp\nfrom flax.training import orbax_utils\nfrom orbax.checkpoint import PyTreeCheckpointer\nfrom pathlib import Path\n\nfrom models.tokenizer import TokenizerVQVAE\nfrom flax.training.train_state import TrainState\nimport optax\nfrom jax.sharding import Mesh, PartitionSpec, NamedSharding\nfrom jax.experimental.mesh_utils import create_device_mesh\n\nclass DistributedCheckpointerTest(unittest.TestCase):\n def setUp(self):\n super().setUp()\n self._temp_dir_manager = tempfile.TemporaryDirectory()\n self.checkpoint_dir = Path(self._temp_dir_manager.name)\n self.addCleanup(self._temp_dir_manager.cleanup)\n\n # FIXME (f.srambical): If the tests pass, we should use the default model config instead\n self.model_kwargs = dict(\n in_dim=3,\n model_dim=8,\n latent_dim=4,\n num_latents=16,\n patch_size=2,\n num_blocks=1,\n num_heads=1,\n dropout=0.0,\n codebook_dropout=0.0,\n )\n self.image_shape = (8, 8, 3)\n self.seq_len = 2\n self.batch_size = 2\n self.seed = 0\n\n def test_distributed_checkpointing(self):\n jax.distributed.initialize()\n num_devices = jax.device_count()\n self.assertGreater(num_devices, 0)\n\n model = TokenizerVQVAE(**self.model_kwargs)\n rng = jax.random.PRNGKey(self.seed)\n dummy_inputs = dict(\n videos=jnp.zeros((self.batch_size, self.seq_len, *self.image_shape), dtype=jnp.float32)\n )\n params = model.init(rng, dummy_inputs)\n\n tx = optax.adam(1e-3)\n state = TrainState.create(apply_fn=model.apply, params=params, tx=tx)\n\n device_mesh_arr = create_device_mesh((num_devices,))\n mesh = Mesh(devices=device_mesh_arr, axis_names=(""data"",))\n replicated_sharding = NamedSharding(mesh, PartitionSpec())\n state = jax.device_put(state, replicated_sharding)\n\n ckpt = {""model"": state}\n orbax_checkpointer = PyTreeCheckpointer()\n save_args = orbax_utils.save_args_from_target(ckpt)\n ckpt_path = str(self.checkpoint_dir / ""test_ckpt"")\n orbax_checkpointer.save(ckpt_path, ckpt, save_args=save_args)\n self.assertTrue(os.path.exists(ckpt_path))\n\n restore_target = {""model"": state}\n restore_args = orbax_utils.restore_args_from_target(restore_target)\n restored = orbax_checkpointer.restore(ckpt_path, item=restore_target, restore_args=restore_args)\n # Compare parameters recursively, handling nested structure\n def compare_params(original, restored):\n if isinstance(original, dict):\n for k in original.keys():\n compare_params(original[k], restored[k])\n else:\n self.assertTrue(jnp.allclose(original, restored))\n \n compare_params(state.params, restored[""model""].params)\n\nif __name__ == ""__main__"":\n unittest.main()\n",python,tab
|
| 3 |
+
2,568,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"9:17:43 AM [info] Activating crowd-code\n9:17:44 AM [info] Recording started\n9:17:44 AM [info] Initializing git provider using file system watchers...\n",Log,tab
|
| 4 |
+
3,1547,"extension-output-pdoom-org.crowd-code-#1-crowd-code",150,0,"9:17:45 AM [info] Git repository found\n9:17:45 AM [info] Git provider initialized successfully\n9:17:45 AM [info] Initial git state: [object Object]\n",Log,content
|
| 5 |
+
4,1648,"tests/test_checkpointer.py",0,0,"",python,tab
|
| 6 |
+
5,3081,"TERMINAL",0,0,"/usr/bin/python3 /ictstr01/home/aih/franz.srambical/.cursor-server/extensions/ms-python.python-2024.12.3-linux-x64/python_files/printEnvVariablesToFile.py /ictstr01/home/aih/franz.srambical/.cursor-server/extensions/ms-python.python-2024.12.3-linux-x64/python_files/deactivate/bash/envVars.txt",,terminal_command
|
| 7 |
+
6,3095,"TERMINAL",0,0,"]633;E;/usr/bin/python3 /ictstr01/home/aih/franz.srambical/.cursor-server/extensions/ms-python.python-2024.12.3-linux-x64/python_files/printEnvVariablesToFile.py /ictstr01/home/aih/franz.srambical/.cursor-server/extensions/ms-python.python-2024.12.3-linux-x64/python_files/deactivate/bash/envVars.txt;b730ba2f-be2c-4b6f-9f0d-d578d409e7ab]633;C]0;franz.srambical@hpc-submit01:/ictstr01/home/aih/franz.srambical/.cursor-server/extensions/ms-python.python-2024.12.3-linux-x64/python_files/deactivate/bash]633;D;0]633;P;Cwd=/ictstr01/home/aih/franz.srambical/.cursor-server/extensions/ms-python.python-2024.12.3-linux-x64/python_files/deactivate/bash",,terminal_output
|
| 8 |
+
7,13336,"TERMINAL",0,0,"salloc --reservation=haicu_stefan -p gpu_p --time=05:00:00 --job-name=interactive_bash --qos=gpu_normal --gres=gpu:4 -w supergpu16 --cpus-per-task=8",,terminal_command
|
| 9 |
+
8,13419,"TERMINAL",0,0,"]633;E;salloc --reservation=haicu_stefan -p gpu_p --time=05:00:00 --job-name=interactive_bash --qos=gpu_normal --gres=gpu:4 -w supergpu16 --cpus-per-task=8;a8707c05-ae9b-4a50-91c9-fa9c06501dad]633;Csalloc: Required node not available (down, drained or reserved)\r\nsalloc: Pending job allocation 26666565\r\nsalloc: job 26666565 queued and waiting for resources\r\n",,terminal_output
|
| 10 |
+
9,79296,"TERMINAL",0,0,"^Csalloc: Job allocation 26666565 has been revoked.\r\nsalloc: Job aborted due to signal\r\n",,terminal_output
|
| 11 |
+
10,82221,"TERMINAL",0,0,"sinfo supergpu16",,terminal_command
|
| 12 |
+
11,82252,"TERMINAL",0,0,"\r\n[?2004l\r]633;E;sinfo supergpu16;a8707c05-ae9b-4a50-91c9-fa9c06501dad]633;CPARTITION AVAIL TIMELIMIT NODES STATE NODELIST\r\ninteractive_cpu_p up 12:00:00 1 down* cpusrv54\r\ninteractive_cpu_p up 12:00:00 1 mix cpusrv75\r\ninteractive_cpu_p up 12:00:00 4 idle cpusrv[51-53,55]\r\ncpu_p up 3-00:00:00 1 down* supercpu02\r\ncpu_p up 3-00:00:00 2 drain cpusrv[57,74]\r\ncpu_p up 3-00:00:00 84 mix cpusrv[02,05-27,31-33,35-39,41-47,49-50,56,58,61-65,72-73,75,77,79,82-83,89,92,94,96-104,106-108,110,112-113,115-117,119,121-122,124-127],supercpu01\r\ncpu_p up 3-00:00:00 19 alloc cpusrv[28,59-60,78,80-81,84-88,90-91,93,109,111,114,118,123]\r\ncpu_p up 3-00:00:00 8 idle cpusrv[30,40,48,69-71,95,105]\r\ninteractive_gpu_p up 12:00:00 1 inval gpusrv25\r\ninteractive_gpu_p up 12:00:00 3 idle gpusrv[22-24]\r\ngpu_p up 2-00:00:00 3 mix- supergpu[14,17,19]\r\ngpu_p up 2-00:00:00 2 down* gpusrv34,supergpu07\r\ngpu_p up 2-00:00:00 1 drain supergpu16\r\ngpu_p up 2-00:00:00 2 resv supergpu[05,18]\r\ngpu_p up 2-00:00:00 52 mix gpusrv[11-12,15,18,26-33,38-40,42-46,50-55,57-77],supergpu[02-03,08-09,15]\r\ngpu_p up 2-00:00:00 11 idle gpusrv[09-10,13-14,16-17,35,41,47-49]\r\ncemp_gpu_p up 5-00:00:00 1 down* supercpu02\r\ncemp_gpu_p up 5-00:00:00 3 mix supercpu01,supergpu[06,10]\r\ncemp_gpu_p up 5-00:00:00 3 idle supergpu[11-13]\r\nbcf_p up 14-00:00:0 1 mix cpusrv29\r\nbcf_p up 14-00:00:0 1 idle cpusrv128\r\n]0;franz.srambical@hpc-submit01:/lustre/groups/haicu/workspace/franz.srambical/jafar]633;D;0",,terminal_output
|
| 13 |
+
12,144962,"TERMINAL",0,0,"scontrol show node supergpu16~",,terminal_command
|
| 14 |
+
13,144987,"TERMINAL",0,0,"]633;E;scontrol show node supergpu16~;a8707c05-ae9b-4a50-91c9-fa9c06501dad]633;C",,terminal_output
|
| 15 |
+
14,147337,"TERMINAL",0,0,"scontrol show node supergpu16",,terminal_command
|
| 16 |
+
15,147379,"TERMINAL",0,0,"\r\n[?2004l\r]633;E;scontrol show node supergpu16;a8707c05-ae9b-4a50-91c9-fa9c06501dad]633;C",,terminal_output
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-65bd7149-5424-43f9-8618-556923c89f3e1762712224460-2025_11_09-19.17.10.464/source.csv
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
1,4,"crowd-pilot-extension/src/extension.ts",0,0,"import * as vscode from 'vscode';\nimport * as http from 'http';\nimport { Buffer } from 'buffer';\n\nconst HOSTNAME = 'hai005';\nconst PORT = 30000;\n\nexport function activate(context: vscode.ExtensionContext) {\n\n\tconsole.log('[crowd-pilot] Extension activated');\n\n\t// Configure terminal to allow tab keybinding to work\n\t(async () => {\n\t\tconst config = vscode.workspace.getConfiguration('terminal.integrated');\n\t\tconst commandsToSkipShell = config.get<string[]>('commandsToSkipShell', []);\n\t\tlet updated = false;\n\t\tif (!commandsToSkipShell.includes('crowd-pilot.modelRun')) {\n\t\t\tcommandsToSkipShell.push('crowd-pilot.modelRun');\n\t\t\tupdated = true;\n\t\t}\n\t\tif (!commandsToSkipShell.includes('crowd-pilot.hideUi')) {\n\t\t\tcommandsToSkipShell.push('crowd-pilot.hideUi');\n\t\t\tupdated = true;\n\t\t}\n\t\tif (updated) {\n\t\t\tawait config.update('commandsToSkipShell', commandsToSkipShell, vscode.ConfigurationTarget.Global);\n\t\t}\n\t})().catch((err) => console.error('[crowd-pilot] Startup initialization error:', err));\n\n\tconst hideUi = vscode.commands.registerCommand('crowd-pilot.hideUi', () => {\n\t\thidePreviewUI();\n\t});\n\n\tconst modelRun = vscode.commands.registerCommand('crowd-pilot.modelRun', async () => {\n\t\tconst editor = vscode.window.activeTextEditor;\n\t\tif (!editor) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst plan = await requestModelActions(editor);\n\n\t\t\tif (!previewVisible) {\n\t\t\t\tshowPreviewUI(plan);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst runPlan = currentPlan ?? plan;\n\t\t\thidePreviewUI();\n\t\t\tawait executePlan(runPlan);\n\t\t\tvscode.window.showInformationMessage('All actions emitted');\n\t\t} catch (err) {\n\t\t\tconst errorMessage = err instanceof Error ? err.message : String(err);\n\t\t\tvscode.window.showErrorMessage(`Model run failed: ${errorMessage}`);\n\t\t}\n\t});\n\n\tconst sglangTest = vscode.commands.registerCommand('crowd-pilot.sglangTest', async () => {\n\t\ttry {\n\t\t\tawait callSGLangChat();\n\t\t} catch (err) {\n\t\t\tconst errorMessage = err instanceof Error ? err.message : String(err);\n\t\t\tvscode.window.showErrorMessage(`SGLang test failed: ${errorMessage}`);\n\t\t}\n\t});\n\n\tcontext.subscriptions.push(hideUi, sglangTest, modelRun);\n}\n\nexport function deactivate() {}\n\n// -------------------- Plan Types & Execution --------------------\ntype PlannedAction =\n| { kind: 'showTextDocument' }\n| { kind: 'setSelections', selections: Array<{ start: [number, number], end: [number, number] }> }\n| { kind: 'editInsert', position: [number, number], text: string }\n| { kind: 'terminalShow' }\n| { kind: 'terminalSendText', text: string };\n\nlet currentPlan: PlannedAction[] | undefined;\n\nasync function executePlan(plan: PlannedAction[]): Promise<void> {\n\tconst editor = vscode.window.activeTextEditor;\n\tif (!editor) { return; }\n\tconst doc = editor.document;\n\tconst term = vscode.window.terminals[0] ?? vscode.window.createTerminal('Test');\n\tfor (const action of plan) {\n\t\tif (action.kind === 'showTextDocument') {\n\t\t\tawait vscode.window.showTextDocument(doc);\n\t\t\tcontinue;\n\t\t}\n\t\tif (action.kind === 'setSelections') {\n\t\t\teditor.selections = action.selections.map(s => new vscode.Selection(\n\t\t\t\tnew vscode.Position(s.start[0], s.start[1]),\n\t\t\t\tnew vscode.Position(s.end[0], s.end[1])\n\t\t\t));\n\t\t\tcontinue;\n\t\t}\n\t\tif (action.kind === 'editInsert') {\n\t\t\tawait editor.edit((e: vscode.TextEditorEdit) => e.insert(new vscode.Position(action.position[0], action.position[1]), action.text));\n\t\t\tcontinue;\n\t\t}\n\t\tif (action.kind === 'terminalShow') {\n\t\t\tterm.show();\n\t\t\tcontinue;\n\t\t}\n\t\tif (action.kind === 'terminalSendText') {\n\t\t\tterm.sendText(action.text);\n\t\t\tcontinue;\n\t\t}\n\t}\n}\n\n// -------------------- UI State & Helpers --------------------\nconst UI_CONTEXT_KEY = 'crowdPilot.uiVisible';\nlet previewVisible = false;\nlet previewQuickPick: vscode.QuickPick<(vscode.QuickPickItem & { index: number })> | undefined;\n\nfunction showPreviewUI(plan: PlannedAction[]): void {\n\tconst items: (vscode.QuickPickItem & { index: number })[] = plan.map((action, index) => {\n\t\tswitch (action.kind) {\n\t\t\tcase 'showTextDocument':\n\t\t\t\treturn { index, label: '$(file) Focus active text document' };\n\t\t\tcase 'setSelections':\n\t\t\t\t{\n\t\t\t\t\tconst cursors = action.selections.map(s => `(${s.start[0]}, ${s.start[1]})`).join(', ');\n\t\t\t\t\treturn { index, label: `$(cursor) Move cursor to ${cursors}` };\n\t\t\t\t}\n\t\t\tcase 'editInsert':\n\t\t\t\treturn { index, label: `$(pencil) Insert ""${action.text.replace(/\n/g, '\\n')}"" at (${action.position[0]}, ${action.position[1]})` };\n\t\t\tcase 'terminalShow':\n\t\t\t\treturn { index, label: '$(terminal) Focus terminal' };\n\t\t\tcase 'terminalSendText':\n\t\t\t\treturn { index, label: `$(terminal) Run ""${action.text}"" in terminal` };\n\t\t}\n\t});\n if (!previewQuickPick) {\n previewQuickPick = vscode.window.createQuickPick<(vscode.QuickPickItem & { index: number })>();\n\t\tpreviewQuickPick.title = 'crowd-pilot: preview';\n\t\tpreviewQuickPick.matchOnDetail = true;\n\t\tpreviewQuickPick.ignoreFocusOut = true;\n\t\tpreviewQuickPick.canSelectMany = false;\n previewQuickPick.onDidAccept(async () => {\n const qp = previewQuickPick!;\n const selected = qp.selectedItems?.[0];\n qp.hide();\n if (selected) {\n await executePlan([plan[selected.index]]);\n vscode.window.showInformationMessage('Action executed');\n }\n });\n\t\tpreviewQuickPick.onDidHide(() => {\n\t\t\tpreviewVisible = false;\n\t\t\tvscode.commands.executeCommand('setContext', UI_CONTEXT_KEY, false);\n\t\t\ttry { previewQuickPick?.dispose(); } catch {}\n\t\t\tpreviewQuickPick = undefined;\n\t\t});\n\t}\n\tpreviewQuickPick.items = items;\n\tpreviewQuickPick.placeholder = 'Press Tab to run all, Enter for selected, or Esc to hide';\n\tpreviewQuickPick.show();\n\tpreviewVisible = true;\n\tvscode.commands.executeCommand('setContext', UI_CONTEXT_KEY, true);\n\tcurrentPlan = plan;\n}\n\nfunction hidePreviewUI(): void {\n\tif (previewQuickPick) {\n\t\ttry { previewQuickPick.hide(); } catch {}\n\t\treturn;\n\t}\n\tpreviewVisible = false;\n\tvscode.commands.executeCommand('setContext', UI_CONTEXT_KEY, false);\n}\n\n// -------------------- SGLang Client (simple test) --------------------\nasync function callSGLangChat(): Promise<void> {\n\tconst requestBody = {\n\t\tmodel: 'qwen/qwen2.5-0.5b-instruct',\n\t\tmessages: [\n\t\t\t{ role: 'user', content: 'What is the capital of France?' }\n\t\t]\n\t};\n\tconst postData = JSON.stringify(requestBody);\n\n\tconst options = {\n\t\thostname: HOSTNAME,\n\t\tport: PORT,\n\t\tpath: '/v1/chat/completions',\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t'Content-Length': Buffer.byteLength(postData)\n\t\t}\n\t};\n\n\ttry {\n\t\tconst json = await new Promise<any>((resolve, reject) => {\n\t\t\tconst req = http.request(options, (res: http.IncomingMessage) => {\n\t\t\t\tlet data = '';\n\t\t\t\tres.on('data', (chunk: Buffer) => {\n\t\t\t\t\tdata += chunk.toString();\n\t\t\t\t});\n\t\t\t\tres.on('end', () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresolve(JSON.parse(data));\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\treject(new Error(`Failed to parse response: ${err instanceof Error ? err.message : String(err)}`));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\n\t\t\treq.on('error', (err: Error) => {\n\t\t\t\treject(err);\n\t\t\t});\n\n\t\t\treq.write(postData);\n\t\t\treq.end();\n\t\t});\n\n\t\tvscode.window.showInformationMessage(`SGLang response: ${JSON.stringify(json, null, 2)}`);\n\t} catch (err) {\n\t\tconst errorMessage = err instanceof Error ? err.message : String(err);\n\t\tvscode.window.showErrorMessage(`SGLang request failed: ${errorMessage}`);\n\t}\n}\n\n// -------------------- Model-planned Actions --------------------\nasync function requestModelActions(editor: vscode.TextEditor): Promise<PlannedAction[]> {\n\tconst schemaDescription = [\n\t\t'Role: You suggest the next VS Code editor/terminal action to progress the current task.',\n\t\t'Output ONLY a JSON array (no prose, no code fences). Length exactly 1.',\n\t\t'Coordinates are zero-based [line, column].',\n\t\t'Allowed actions (JSON schema-like):',\n\t\t'{ kind: ""showTextDocument"" }',\n\t\t'{ kind: ""setSelections"", selections: Array<{ start: [number, number], end: [number, number] }> }',\n\t\t'{ kind: ""editInsert"", position: [number, number], text: string }',\n\t\t'{ kind: ""terminalShow"" }',\n\t\t'{ kind: ""terminalSendText"", text: string }',\n\t\t'Guidelines:',\n\t\t'- If you you insert text, insert until the logical end of the current statement or block.',\n\t\t'- When inserting text, make sure to not repeat existing text (except when replacing existing text).',\n\t\t'- Use double-quoted JSON strings.'\n\t].join('\n');\n\n\tconst doc = editor.document;\n\tconst cursor = editor.selection.active;\n\tconst contextRange = new vscode.Range(new vscode.Position(0, 0), cursor);\n\tconst contextCode = doc.getText(contextRange);\n\tconst maxContextChars = 20000;\n\tconst allLines = contextCode.split(/\r?\n/);\n\tlet startLineIndex = 0;\n\tlet visibleLines = allLines;\n\tif (contextCode.length > maxContextChars) {\n\t\tlet acc = 0;\n\t\tlet idx = allLines.length;\n\t\twhile (idx > 0 && acc <= maxContextChars) {\n\t\t\tidx--;\n\t\t\tacc += allLines[idx].length + 1;\n\t\t}\n\t\tstartLineIndex = idx;\n\t\tvisibleLines = allLines.slice(idx);\n\t}\n\tconst numberedContext = visibleLines.map((line, i) => `${startLineIndex + i}: ${line}`).join('\n');\n\n\tconst tabbingPrompt = [\n\t\t'Your role: Propose the single next action according to the schema to help the developer progress.',\n\t\t'',\n\t\t'Available context:',\n\t\t`- File: ${doc.fileName}`,\n\t\t`- Language: ${doc.languageId}`,\n\t\t`- Cursor: (${cursor.line}, ${cursor.character})`,\n\t\t'',\n\t\t'Current file content up to the cursor (zero-based line numbers):',\n\t\t'```',\n\t\tnumberedContext,\n\t\t'```',\n\t\t'',\n\t\t'Respond with ONLY a JSON array containing exactly one action.'\n\t].join('\n');\n\n\tconst requestBody = {\n\t\tmodel: 'qwen/qwen2.5-0.5b-instruct',\n\t\tmessages: [\n\t\t\t{ role: 'system', content: schemaDescription },\n\t\t\t{ role: 'user', content: tabbingPrompt }\n\t\t]\n\t};\n\n\tconst postData = JSON.stringify(requestBody);\n\tconst options = {\n\t\thostname: HOSTNAME,\n\t\tport: PORT,\n\t\tpath: '/v1/chat/completions',\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t'Content-Length': Buffer.byteLength(postData)\n\t\t}\n\t};\n\n\tconst json = await new Promise<any>((resolve, reject) => {\n\t\tconst req = http.request(options, (res: http.IncomingMessage) => {\n\t\t\tlet data = '';\n\t\t\tres.on('data', (chunk: Buffer) => { data += chunk.toString(); });\n\t\t\tres.on('end', () => {\n\t\t\t\ttry {\n\t\t\t\t\tresolve(JSON.parse(data));\n\t\t\t\t} catch (err) {\n\t\t\t\t\treject(new Error(`Failed to parse response: ${err instanceof Error ? err.message : String(err)}`));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\treq.on('error', (err: Error) => reject(err));\n\t\treq.write(postData);\n\t\treq.end();\n\t});\n\n\tconst content = extractChatContent(json);\n\tif (typeof content !== 'string' || content.trim().length === 0) {\n\t\tthrow new Error('Empty model content');\n\t}\n\tconst actions = parsePlannedActions(content);\n\tif (actions.length === 0) {\n\t\tthrow new Error('No valid actions parsed from model output');\n\t}\n\treturn actions;\n}\n\nfunction extractChatContent(json: any): string | undefined {\n\ttry {\n\t\tif (json && Array.isArray(json.choices) && json.choices[0]) {\n\t\t\tconst choice = json.choices[0];\n\t\t\tif (choice.message && typeof choice.message.content === 'string') {\n\t\t\t\treturn choice.message.content;\n\t\t\t}\n\t\t\tif (typeof choice.text === 'string') {\n\t\t\t\treturn choice.text;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction parsePlannedActions(raw: string): PlannedAction[] {\n\tlet text = raw.trim();\n\ttext = text.replace(/^```(?:json)?\s*/i, '').replace(/```\s*$/i, '').trim();\n\tconst arrayMatch = text.match(/\[[\s\S]*\]/);\n\tconst jsonText = arrayMatch ? arrayMatch[0] : text;\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(jsonText);\n\t} catch (err) {\n\t\treturn [];\n\t}\n\tif (!Array.isArray(parsed)) { return []; }\n\tconst result: PlannedAction[] = [];\n\tfor (const item of parsed) {\n\t\tif (!item || typeof item !== 'object' || typeof (item as any).kind !== 'string') { continue; }\n\t\tswitch ((item as any).kind) {\n\t\t\tcase 'showTextDocument':\n\t\t\t\tresult.push({ kind: 'showTextDocument' });\n\t\t\t\tbreak;\n\t\t\tcase 'setSelections': {\n\t\t\t\tconst selections = Array.isArray((item as any).selections) ? (item as any).selections : [];\n\t\t\t\tconst norm = selections.map((s: any) => ({\n\t\t\t\t\tstart: Array.isArray(s?.start) && s.start.length === 2 ? [Number(s.start[0]) || 0, Number(s.start[1]) || 0] as [number, number] : [0, 0] as [number, number],\n\t\t\t\t\tend: Array.isArray(s?.end) && s.end.length === 2 ? [Number(s.end[0]) || 0, Number(s.end[1]) || 0] as [number, number] : [0, 0] as [number, number]\n\t\t\t\t}));\n\t\t\t\tresult.push({ kind: 'setSelections', selections: norm });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'editInsert': {\n\t\t\t\tconst pos = Array.isArray((item as any).position) && (item as any).position.length === 2 ? [Number((item as any).position[0]) || 0, Number((item as any).position[1]) || 0] as [number, number] : [0, 0] as [number, number];\n\t\t\t\tconst text = typeof (item as any).text === 'string' ? (item as any).text : '';\n\t\t\t\tresult.push({ kind: 'editInsert', position: pos, text });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'terminalShow':\n\t\t\t\tresult.push({ kind: 'terminalShow' });\n\t\t\t\tbreak;\n\t\t\tcase 'terminalSendText': {\n\t\t\t\tconst text = typeof (item as any).text === 'string' ? (item as any).text : '';\n\t\t\t\tresult.push({ kind: 'terminalSendText', text });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn result;\n}\n",typescript,tab
|
| 3 |
+
2,199,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"7:17:10 PM [info] Activating crowd-code\n7:17:10 PM [info] Recording started\n7:17:10 PM [info] Initializing git provider using file system watchers...\n7:17:10 PM [info] Git repository found\n7:17:10 PM [info] Git provider initialized successfully\n7:17:10 PM [info] Initial git state: [object Object]\n",Log,tab
|
| 4 |
+
3,2876,"crowd-pilot-extension/src/extension.ts",0,0,"",typescript,tab
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-667f558c-c85b-45c3-9621-f920186c4d561764772496749-2025_12_03-15.35.04.989/source.csv
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
1,3,"src/extension.ts",0,0,"import * as vscode from 'vscode';\nimport * as http from 'http';\nimport { Buffer } from 'buffer';\n\nconst HOSTNAME = 'hai001';\nconst PORT = 30000;\n\nexport function activate(context: vscode.ExtensionContext) {\n\n\tconsole.log('[crowd-pilot] Extension activated');\n\n\t// Configure terminal to allow tab keybinding to work\n\t(async () => {\n\t\tconst config = vscode.workspace.getConfiguration('terminal.integrated');\n\t\tconst commandsToSkipShell = config.get<string[]>('commandsToSkipShell', []);\n\t\tlet updated = false;\n\t\tif (!commandsToSkipShell.includes('crowd-pilot.modelRun')) {\n\t\t\tcommandsToSkipShell.push('crowd-pilot.modelRun');\n\t\t\tupdated = true;\n\t\t}\n\t\tif (!commandsToSkipShell.includes('crowd-pilot.hideUi')) {\n\t\t\tcommandsToSkipShell.push('crowd-pilot.hideUi');\n\t\t\tupdated = true;\n\t\t}\n\t\tif (updated) {\n\t\t\tawait config.update('commandsToSkipShell', commandsToSkipShell, vscode.ConfigurationTarget.Global);\n\t\t}\n\t})().catch((err) => console.error('[crowd-pilot] Startup initialization error:', err));\n\n\tconst hideUi = vscode.commands.registerCommand('crowd-pilot.hideUi', () => {\n\t\thidePreviewUI(true);\n\t});\n\n\tconst modelRun = vscode.commands.registerCommand('crowd-pilot.modelRun', async () => {\n\t\tconst editor = vscode.window.activeTextEditor;\n\t\tif (!editor) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\t// Confirm only when a suggestion is visible\n\t\t\tif (!previewVisible) { return; }\n\t\t\tlet action: PlannedAction | undefined = currentAction;\n\t\t\tif (!action) {\n\t\t\t\tconst single = await requestModelActions(editor);\n\t\t\t\tcurrentAction = single;\n\t\t\t\taction = single;\n\t\t\t}\n\t\t\tif (!action) {\n\t\t\t\thidePreviewUI();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\thidePreviewUI(false);\n\t\t\tawait executeAction(action);\n\t\t\tautoShowNextAction();\n\t\t} catch (err) {\n\t\t\tconst errorMessage = err instanceof Error ? err.message : String(err);\n\t\t\tvscode.window.showErrorMessage(`Model run failed: ${errorMessage}`);\n\t\t}\n\t});\n\n\tconst sglangTest = vscode.commands.registerCommand('crowd-pilot.sglangTest', async () => {\n\t\ttry {\n\t\t\tawait callSGLangChat();\n\t\t} catch (err) {\n\t\t\tconst errorMessage = err instanceof Error ? err.message : String(err);\n\t\t\tvscode.window.showErrorMessage(`SGLang test failed: ${errorMessage}`);\n\t\t}\n\t});\n\n\t// Auto-preview listeners\n\tconst onSelChange = vscode.window.onDidChangeTextEditorSelection((e) => {\n\t\tif (e.textEditor === vscode.window.activeTextEditor) {\n\t\t\tsuppressAutoPreview = false;\n\t\t\tautoShowNextAction();\n\t\t}\n\t});\n\tconst onActiveChange = vscode.window.onDidChangeActiveTextEditor(() => {\n\t\tsuppressAutoPreview = false;\n\t\tautoShowNextAction();\n\t});\n\tconst onDocChange = vscode.workspace.onDidChangeTextDocument((e) => {\n\t\tif (vscode.window.activeTextEditor?.document === e.document) {\n\t\t\tsuppressAutoPreview = false;\n\t\t\tautoShowNextAction();\n\t\t}\n\t});\n\n\tcontext.subscriptions.push(hideUi, sglangTest, modelRun, onSelChange, onActiveChange, onDocChange);\n}\n\nexport function deactivate() {}\n\n// -------------------- Plan Types & Execution --------------------\ntype PlannedAction =\n| { kind: 'showTextDocument' }\n| { kind: 'setSelections', selections: Array<{ start: [number, number], end: [number, number] }> }\n| { kind: 'editInsert', position: [number, number], text: string }\n| { kind: 'editDelete', range: { start: [number, number], end: [number, number] } }\n| { kind: 'editReplace', range: { start: [number, number], end: [number, number] }, text: string }\n| { kind: 'terminalShow' }\n| { kind: 'terminalSendText', text: string };\n\nlet currentAction: PlannedAction | undefined;\n\nasync function executeAction(action: PlannedAction): Promise<void> {\n\tconst editor = vscode.window.activeTextEditor;\n\tif (!editor) { return; }\n\tconst doc = editor.document;\n\tconst term = vscode.window.terminals[0] ?? vscode.window.createTerminal('Test');\n\tif (action.kind === 'showTextDocument') {\n\t\tawait vscode.window.showTextDocument(doc);\n\t\treturn;\n\t}\n\tif (action.kind === 'setSelections') {\n\t\teditor.selections = action.selections.map(s => new vscode.Selection(\n\t\t\tnew vscode.Position(s.start[0], s.start[1]),\n\t\t\tnew vscode.Position(s.end[0], s.end[1])\n\t\t));\n\t\tif (editor.selections.length > 0) {\n\t\t\teditor.revealRange(editor.selections[0], vscode.TextEditorRevealType.InCenterIfOutsideViewport);\n\t\t}\n\t\treturn;\n\t}\n\tif (action.kind === 'editInsert') {\n\t\tawait editor.edit((e: vscode.TextEditorEdit) => e.insert(new vscode.Position(action.position[0], action.position[1]), action.text));\n\t\treturn;\n\t}\n\tif (action.kind === 'editDelete') {\n\t\tconst range = new vscode.Range(\n\t\t\tnew vscode.Position(action.range.start[0], action.range.start[1]),\n\t\t\tnew vscode.Position(action.range.end[0], action.range.end[1])\n\t\t);\n\t\tawait editor.edit((e: vscode.TextEditorEdit) => e.delete(range));\n\t\treturn;\n\t}\n\tif (action.kind === 'editReplace') {\n\t\tconst range = new vscode.Range(\n\t\t\tnew vscode.Position(action.range.start[0], action.range.start[1]),\n\t\t\tnew vscode.Position(action.range.end[0], action.range.end[1])\n\t\t);\n\t\tawait editor.edit((e: vscode.TextEditorEdit) => e.replace(range, action.text));\n\t\treturn;\n\t}\n\tif (action.kind === 'terminalShow') {\n\t\tterm.show();\n\t\treturn;\n\t}\n\tif (action.kind === 'terminalSendText') {\n\t\tterm.sendText(action.text);\n\t\treturn;\n\t}\n}\n\n// -------------------- UI State & Helpers --------------------\nconst UI_CONTEXT_KEY = 'crowdPilot.uiVisible';\nlet previewVisible = false;\nlet decorationDeleteType: vscode.TextEditorDecorationType | undefined;\nlet decorationReplaceType: vscode.TextEditorDecorationType | undefined;\nlet decorationReplaceBlockType: vscode.TextEditorDecorationType | undefined;\nlet mockStep = 0;\nlet suppressAutoPreview = false;\n\nfunction disposePreviewDecorations() {\n\ttry { decorationDeleteType?.dispose(); } catch {}\n\ttry { decorationReplaceType?.dispose(); } catch {}\n\ttry { decorationReplaceBlockType?.dispose(); } catch {}\n\tdecorationDeleteType = undefined;\n\tdecorationReplaceType = undefined;\n\tdecorationReplaceBlockType = undefined;\n}\n\nfunction getDynamicMargin(editor: vscode.TextEditor, anchorLine: number, text: string): string {\n\t// Count lines in the preview text\n\tconst lines = text.split(/\r?\n/);\n\tconst height = lines.length;\n\t\n\t// We need to check the document lines that will be covered by this panel.\n\t// The panel starts at 'anchorLine' and extends downwards by 'height' lines.\n\t// However, visually, since it's 'after', it sits to the right of 'anchorLine',\n\t// and then flows down.\n\t// So we check document lines from anchorLine to anchorLine + height - 1.\n\t\n\tconst doc = editor.document;\n\tlet maxLen = 0;\n\tconst startLine = anchorLine;\n\tconst endLine = Math.min(doc.lineCount - 1, anchorLine + height - 1);\n\t\n\tfor (let i = startLine; i <= endLine; i++) {\n\t\tconst lineText = doc.lineAt(i).text;\n\t\t// Simple approximation: assume tabs are 4 spaces if we can't get config easily, \n\t\t// or just treat them as 1 char (which might underestimate). \n\t\t// Better to overestimate: treat tab as 4 chars.\n\t\tconst len = lineText.replace(/\t/g, ' ').length;\n\t\tif (len > maxLen) {\n\t\t\tmaxLen = len;\n\t\t}\n\t}\n\t\n\t// Length of the anchor line itself\n\tconst anchorLineText = doc.lineAt(anchorLine).text;\n\tconst anchorLen = anchorLineText.replace(/\t/g, ' ').length;\n\t\n\t// The offset needed is maxLen - anchorLen.\n\t// If maxLen <= anchorLen, offset is 0 (margin is just base padding).\n\t// If maxLen > anchorLen, we need to push right by (maxLen - anchorLen).\n\t\n\tconst diff = Math.max(0, maxLen - anchorLen);\n\t// Base margin 2rem is roughly 4ch. Let's use ch units for everything to be consistent.\n\t// 1ch is width of '0'. In monospace, mostly consistent.\n\t// Add 3ch extra padding for safety/visual gap.\n\tconst margin = diff + 4; \n\treturn `${margin}ch`;\n}\n\nfunction showPreviewUI(action: PlannedAction): void {\n\tconst editor = vscode.window.activeTextEditor;\n\tif (!editor) { return; }\n\tdisposePreviewDecorations();\n\n\t// FIXME (f.srambical): add file switch \n\tconst next = (action.kind === 'editInsert' || action.kind === 'editDelete' || action.kind === 'editReplace' || action.kind === 'terminalSendText' || action.kind === 'setSelections') ? action : undefined;\n\tif (!next) {\n\t\tpreviewVisible = false;\n\t\tvscode.commands.executeCommand('setContext', UI_CONTEXT_KEY, false);\n\t\tcurrentAction = action;\n\t\treturn;\n\t}\n\n\tconst trimText = (t: string) => {\n\t\tconst oneLine = t.replace(/\r?\n/g, '\\n');\n\t\treturn oneLine.length > 80 ? oneLine.slice(0, 77) + '…' : oneLine;\n\t};\n\n\tif (next.kind === 'setSelections') {\n\t\t// For setSelections, we only preview the primary selection's start/active position\n\t\tconst selection = next.selections[0];\n\t\tconst targetPos = new vscode.Position(selection.start[0], selection.start[1]);\n\t\t// Check if the target position is visible\n\t\tconst isVisible = editor.visibleRanges.some(r => r.contains(targetPos));\n\t\t\n\t\tlet anchorPos = targetPos;\n\t\tlet label = ""↳ Move Cursor Here"";\n\n\t\tif (!isVisible && editor.visibleRanges.length > 0) {\n\t\t\tconst firstVisible = editor.visibleRanges[0].start;\n\t\t\tconst lastVisible = editor.visibleRanges[editor.visibleRanges.length - 1].end;\n\t\t\t\n\t\t\tif (targetPos.isBefore(firstVisible)) {\n\t\t\t\tanchorPos = editor.document.lineAt(firstVisible.line).range.end;\n\t\t\t} else {\n\t\t\t\tanchorPos = editor.document.lineAt(lastVisible.line).range.end;\n\t\t\t}\n\n\t\t\tif (targetPos.line < anchorPos.line) {\n\t\t\t\tlabel = `↑ Move Cursor to Line ${targetPos.line + 1}`;\n\t\t\t} else {\n\t\t\t\tlabel = `↓ Move Cursor to Line ${targetPos.line + 1}`;\n\t\t\t}\n\t\t}\n\n\t\tconst margin = getDynamicMargin(editor, anchorPos.line, label);\n\n\t\tdecorationReplaceBlockType = vscode.window.createTextEditorDecorationType({\n\t\t\tafter: {\n\t\t\t\tcontentText: '',\n\t\t\t\tcolor: new vscode.ThemeColor('charts.purple'),\n\t\t\t\tbackgroundColor: new vscode.ThemeColor('editor.background'),\n\t\t\t\tfontStyle: 'italic',\n\t\t\t\tfontWeight: '600',\n\t\t\t\tmargin: `0 0 0 ${margin}`,\n\t\t\t\ttextDecoration: `none; display: inline-block; white-space: pre; content: ""${label}""; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`\n\t\t\t}\n\t\t});\n\t\teditor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(anchorPos, anchorPos) }]);\n\t} else if (next.kind === 'terminalSendText') {\n\t\tconst cursor = editor.selection.active;\n\t\tconst lineEnd = editor.document.lineAt(cursor.line).range.end;\n\t\tconst cmd = next.text.replace(/""/g, '\\""').replace(/\r?\n/g, '\\A ');\n\t\tconst margin = getDynamicMargin(editor, cursor.line, ""↳ Execute in Terminal:\n"" + next.text);\n\n\t\tdecorationReplaceBlockType = vscode.window.createTextEditorDecorationType({\n\t\t\tafter: {\n\t\t\t\tcontentText: '',\n\t\t\t\tcolor: new vscode.ThemeColor('charts.purple'),\n\t\t\t\tbackgroundColor: new vscode.ThemeColor('editor.background'),\n\t\t\t\tfontStyle: 'italic',\n\t\t\t\tfontWeight: '600',\n\t\t\t\tmargin: `0 0 0 ${margin}`,\n\t\t\t\ttextDecoration: `none; display: inline-block; white-space: pre; content: ""↳ Execute in Terminal:\\A ${cmd}""; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`\n\t\t\t}\n\t\t});\n\t\teditor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(lineEnd, lineEnd) }]);\n\t} else if (next.kind === 'editInsert') {\n\t\tconst posLine = next.position[0];\n\t\tconst fullBlock = next.text;\n\t\tconst cssContent = fullBlock\n\t\t\t.replace(/""/g, '\\""')\n\t\t\t.replace(/\r?\n/g, '\\A ');\n\n\t\tconst docLineCount = editor.document.lineCount;\n\t\t// If inserting at EOF (or beyond), attach to the last line.\n\t\t// Otherwise, attach to the line AT the insertion point and shift visually UP into the gap.\n\t\tlet anchorLine = posLine;\n\t\tlet shiftUp = true;\n\t\t\n\t\tif (anchorLine >= docLineCount) {\n\t\t\tanchorLine = docLineCount - 1;\n\t\t\tshiftUp = false; // At EOF, we just append below or to the right\n\t\t}\n\n\t\tconst anchorPos = new vscode.Position(anchorLine, Number.MAX_VALUE); \n\t\t\n\t\t// We attach to the line AT the insertion point.\n\t\t// The panel floats to the right of this line.\n\t\t// The dashed line connects the start of this line to the panel.\n\t\t// This indicates that the new text will be inserted at this line position (pushing the current line down).\n\t\tconst marginCheckLine = anchorLine;\n\t\tconst margin = getDynamicMargin(editor, marginCheckLine, fullBlock);\n\n\t\tconst topOffset = '0';\n\n\t\t// Dashed line style\n\t\t// We use 'before' decoration for the line.\n\t\t// It needs to be absolute, full width (or enough to reach left), \n\t\t// and aligned with the panel top.\n\t\tconst beforeDecoration = {\n\t\t\tcontentText: '',\n\t\t\ttextDecoration: `none; position: absolute; left: 0; width: 100vw; border-top: 1px dashed var(--vscode-charts-purple); top: 0; height: 0; z-index: 99; pointer-events: none;`\n\t\t};\n\n\t\tdecorationReplaceBlockType = vscode.window.createTextEditorDecorationType({\n\t\t\tbefore: beforeDecoration,\n\t\t\tafter: {\n\t\t\t\tcontentText: '',\n\t\t\t\tcolor: new vscode.ThemeColor('charts.purple'),\n\t\t\t\tbackgroundColor: new vscode.ThemeColor('editor.background'),\n\t\t\t\tfontStyle: 'italic',\n\t\t\t\tfontWeight: '600',\n\t\t\t\tmargin: `0 0 0 ${margin}`,\n\t\t\t\ttextDecoration: `none; display: inline-block; white-space: pre; content: ""${cssContent}""; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top; top: ${topOffset};`\n\t\t\t}\n\t\t});\n\t\teditor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(anchorPos, anchorPos) }]);\n\t} else if (next.kind === 'editDelete') {\n\t\tconst range = new vscode.Range(\n\t\t\tnew vscode.Position(next.range.start[0], next.range.start[1]),\n\t\t\tnew vscode.Position(next.range.end[0], next.range.end[1])\n\t\t);\n\t\tdecorationDeleteType = vscode.window.createTextEditorDecorationType({\n\t\t\tbackgroundColor: 'rgba(255, 60, 60, 0.18)',\n\t\t\tborder: '1px solid rgba(255, 60, 60, 0.35)',\n\t\t\ttextDecoration: 'line-through'\n\t\t});\n\t\teditor.setDecorations(decorationDeleteType, [{ range }]);\n\t} else if (next.kind === 'editReplace') {\n\t\tconst range = new vscode.Range(\n\t\t\tnew vscode.Position(next.range.start[0], next.range.start[1]),\n\t\t\tnew vscode.Position(next.range.end[0], next.range.end[1])\n\t\t);\n\t\t// Highlight original range (to be replaced)\n\t\tdecorationReplaceType = vscode.window.createTextEditorDecorationType({\n\t\t\tbackgroundColor: 'rgba(255,165,0,0.15)',\n\t\t\tborder: '1px dashed rgba(255,165,0,0.45)',\n\t\t\tcolor: new vscode.ThemeColor('disabledForeground'),\n\t\t\ttextDecoration: 'line-through'\n\t\t});\n\t\teditor.setDecorations(decorationReplaceType, [{ range }]);\n\n\t\t// Show replacement block to the right of the first replaced line\n\t\tconst fullBlock = next.text;\n\t\t\n\t\t// CSS-escape the text for the 'content' property:\n\t\t// - Escape double quotes\n\t\t// - Replace newlines with \A (CSS newline)\n\t\tconst cssContent = fullBlock\n\t\t\t.replace(/""/g, '\\""')\n\t\t\t.replace(/\r?\n/g, '\\A '); \n\n\t\t// Attach 'after' decoration to the start of the replacement range\n\t\t// (Actually, attaching to the end of the first line is safer for 'after')\n\t\tconst anchorLine = range.start.line;\n\t\tconst anchorPos = new vscode.Position(anchorLine, Number.MAX_VALUE);\n\t\tconst margin = getDynamicMargin(editor, anchorLine, fullBlock);\n\n\t\tdecorationReplaceBlockType = vscode.window.createTextEditorDecorationType({\n\t\t\tafter: {\n\t\t\t\tcontentText: '', // Handled by CSS content\n\t\t\t\tcolor: new vscode.ThemeColor('charts.purple'),\n\t\t\t\tbackgroundColor: new vscode.ThemeColor('editor.background'),\n\t\t\t\tfontStyle: 'italic',\n\t\t\t\tfontWeight: '600',\n\t\t\t\tmargin: `0 0 0 ${margin}`,\n\t\t\t\ttextDecoration: `none; display: inline-block; white-space: pre; content: ""${cssContent}""; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`\n\t\t\t}\n\t\t});\n\t\teditor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(anchorPos, anchorPos) }]);\n\t}\n\n\tpreviewVisible = true;\n\tvscode.commands.executeCommand('setContext', UI_CONTEXT_KEY, true);\n\tcurrentAction = action;\n}\n\nfunction hidePreviewUI(suppress?: boolean): void {\n\tdisposePreviewDecorations();\n\tpreviewVisible = false;\n\tvscode.commands.executeCommand('setContext', UI_CONTEXT_KEY, false);\n\tif (suppress) {\n\t\tsuppressAutoPreview = true;\n\t}\n}\n\n// -------------------- Hardcoded single-step actions --------------------\nfunction getHardcodedNextAction(editor: vscode.TextEditor): PlannedAction | undefined {\n\tconst cursor = editor.selection.active;\n\tconst doc = editor.document;\n\tconst lineCount = doc.lineCount;\n\tconst clamp = (n: number, min: number, max: number) => Math.max(min, Math.min(max, n));\n\n\t// Step 0: Insert multiline content two lines below the cursor (start of target line)\n\tif (mockStep === 0) {\n\t\tconst targetLine = clamp(cursor.line + 2, 0, Math.max(0, lineCount - 1));\n\t\treturn {\n\t\t\tkind: 'editInsert',\n\t\t\tposition: [targetLine, 0],\n\t\t\ttext: '/* crowd-pilot: insert start */\nline A\nline B\n/* crowd-pilot: insert end */\n'\n\t\t};\n\t}\n\t// Step 1: Replace a two-line range three and four lines below the cursor\n\tif (mockStep === 1) {\n\t\tconst startLine = clamp(cursor.line + 3, 0, Math.max(0, lineCount - 1));\n\t\tconst endLine = clamp(startLine + 1, 0, Math.max(0, lineCount - 1));\n\t\tconst endChar = doc.lineAt(endLine).range.end.character;\n\t\tconst range = {\n\t\t\tstart: [startLine, 0] as [number, number],\n\t\t\tend: [endLine, endChar] as [number, number]\n\t\t};\n\t\tconst replacement = [\n\t\t\t'/* crowd-pilot: replacement */',\n\t\t\t'REPLACED LINE 1',\n\t\t\t'REPLACED LINE 2'\n\t\t].join('\n');\n\t\treturn { kind: 'editReplace', range, text: replacement };\n\t}\n\t// Step 2: Delete a three-line range six to eight lines below the cursor\n\tif (mockStep === 2) {\n\t\tconst startLine = clamp(cursor.line + 6, 0, Math.max(0, lineCount - 1));\n\t\tconst endLine = clamp(startLine + 2, 0, Math.max(0, lineCount - 1));\n\t\t\n\t\t// To fully delete the lines including the newline, we target the start of the next line.\n\t\tlet endPosLine = endLine + 1;\n\t\tlet endPosChar = 0;\n\t\t\n\t\tif (endPosLine >= lineCount) {\n\t\t\t// If deleting the last line(s), just go to the end of the document\n\t\t\tendPosLine = lineCount - 1;\n\t\t\tendPosChar = doc.lineAt(endPosLine).range.end.character;\n\t\t}\n\n\t\tconst range = {\n\t\t\tstart: [startLine, 0] as [number, number],\n\t\t\tend: [endPosLine, endPosChar] as [number, number]\n\t\t};\n\t\treturn { kind: 'editDelete', range };\n\t}\n\t// Step 3: Execute in Terminal\n\tif (mockStep === 3) {\n\t\treturn { kind: 'terminalSendText', text: 'echo ""Hello World""' };\n\t}\n\t// Step 4: Move Cursor to End of File\n\tif (mockStep === 4) {\n\t\tconst lastLine = doc.lineCount - 1;\n\t\tconst lastChar = doc.lineAt(lastLine).range.end.character;\n\t\treturn {\n\t\t\tkind: 'setSelections',\n\t\t\tselections: [{ start: [lastLine, lastChar], end: [lastLine, lastChar] }]\n\t\t};\n\t}\n\treturn undefined;\n}\n\nfunction advanceMockStep(): void {\n\tmockStep = (mockStep + 1) % 5;\n}\n\nasync function autoShowNextAction(): Promise<void> {\n\tif (suppressAutoPreview) { return; }\n\tconst editor = vscode.window.activeTextEditor;\n\tif (!editor) { return; }\n\ttry {\n\t\tconst next = await requestModelActions(editor);\n\t\tif (next) {\n\t\t\tshowPreviewUI(next);\n\t\t} else {\n\t\t\thidePreviewUI();\n\t\t}\n\t} catch (err) {\n\t\thidePreviewUI();\n\t}\n}\n\n// -------------------- SGLang Client (simple test) --------------------\nasync function callSGLangChat(): Promise<void> {\n\tconst requestBody = {\n\t\tmodel: 'qwen/qwen2.5-0.5b-instruct',\n\t\tmessages: [\n\t\t\t{ role: 'user', content: 'What is the capital of France?' }\n\t\t]\n\t};\n\tconst postData = JSON.stringify(requestBody);\n\n\tconst options = {\n\t\thostname: HOSTNAME,\n\t\tport: PORT,\n\t\tpath: '/v1/chat/completions',\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t'Content-Length': Buffer.byteLength(postData)\n\t\t}\n\t};\n\n\ttry {\n\t\tconst json = await new Promise<any>((resolve, reject) => {\n\t\t\tconst req = http.request(options, (res: http.IncomingMessage) => {\n\t\t\t\tlet data = '';\n\t\t\t\tres.on('data', (chunk: Buffer) => {\n\t\t\t\t\tdata += chunk.toString();\n\t\t\t\t});\n\t\t\t\tres.on('end', () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresolve(JSON.parse(data));\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\treject(new Error(`Failed to parse response: ${err instanceof Error ? err.message : String(err)}`));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\n\t\t\treq.on('error', (err: Error) => {\n\t\t\t\treject(err);\n\t\t\t});\n\n\t\t\treq.write(postData);\n\t\t\treq.end();\n\t\t});\n\n\t\tvscode.window.showInformationMessage(`SGLang response: ${JSON.stringify(json, null, 2)}`);\n\t} catch (err) {\n\t\tconst errorMessage = err instanceof Error ? err.message : String(err);\n\t\tvscode.window.showErrorMessage(`SGLang request failed: ${errorMessage}`);\n\t}\n}\n\n// -------------------- Model-planned Actions --------------------\nasync function requestModelActions(editor: vscode.TextEditor): Promise<PlannedAction> {\n\tconst schemaDescription = [\n\t\t'Role: You suggest the next VS Code editor/terminal action to progress the current task.',\n\t\t'Output ONLY a JSON object (no prose, no code fences).',\n\t\t'Coordinates are zero-based [line, column].',\n\t\t'Allowed actions (JSON schema-like):',\n\t\t'{ kind: ""sowTextDocument"" }',\n\t\t'{ kind: ""setSelections"", selections: Array<{ start: [number, number], end: [number, number] }> }',\n\t\t'{ kind: ""editInsert"", position: [number, number], text: string }',\n\t\t'{ kind: ""editDelete"", range: { start: [number, number], end: [number, number] } }',\n\t\t'{ kind: ""editReplace"", range: { start: [number, number], end: [number, number] }, text: string }',\n\t\t'{ kind: ""terminalShow"" }',\n\t\t'{ kind: ""terminalSendText"", text: string }',\n\t\t'Guidelines:',\n\t\t'- If you you insert text, insert until the logical end of the current statement or block.',\n\t\t'- When inserting text, make sure to not repeat existing text (except when replacing existing text).',\n\t\t'- Use double-quoted JSON strings.'\n\t].join('\n');\n\n\tconst doc = editor.document;\n\tconst cursor = editor.selection.active;\n\tconst fullText = doc.getText();\n\tconst numberedContext = fullText.split(/\r?\n/).map((line, i) => `${i}: ${line}`).join('\n');\n\n\tconst tabbingPrompt = [\n\t\t'Your role: Propose the single next action according to the schema to help the developer progress.',\n\t\t'',\n\t\t'Available context:',\n\t\t`- File: ${doc.fileName}`,\n\t\t`- Language: ${doc.languageId}`,\n\t\t`- Cursor: (${cursor.line}, ${cursor.character})`,\n\t\t'',\n\t\t'Full file content (zero-based line numbers):',\n\t\t'```',\n\t\tnumberedContext,\n\t\t'```',\n\t\t'',\n\t\t'Respond with ONLY a JSON object containing exactly one action.'\n\t].join('\n');\n\n\tconst requestBody = {\n\t\tmodel: 'qwen/qwen2.5-0.5b-instruct',\n\t\tmessages: [\n\t\t\t{ role: 'system', content: schemaDescription },\n\t\t\t{ role: 'user', content: tabbingPrompt }\n\t\t]\n\t};\n\n\tconst postData = JSON.stringify(requestBody);\n\tconst options = {\n\t\thostname: HOSTNAME,\n\t\tport: PORT,\n\t\tpath: '/v1/chat/completions',\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t'Content-Length': Buffer.byteLength(postData)\n\t\t}\n\t};\n\n\tconst json = await new Promise<any>((resolve, reject) => {\n\t\tconst req = http.request(options, (res: http.IncomingMessage) => {\n\t\t\tlet data = '';\n\t\t\tres.on('data', (chunk: Buffer) => { data += chunk.toString(); });\n\t\t\tres.on('end', () => {\n\t\t\t\ttry {\n\t\t\t\t\tresolve(JSON.parse(data));\n\t\t\t\t} catch (err) {\n\t\t\t\t\treject(new Error(`Failed to parse response: ${err instanceof Error ? err.message : String(err)}`));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\treq.on('error', (err: Error) => reject(err));\n\t\treq.write(postData);\n\t\treq.end();\n\t});\n\n\tconst content = extractChatContent(json);\n\tif (typeof content !== 'string' || content.trim().length === 0) {\n\t\tthrow new Error('Empty model content');\n\t}\n\tconst action = parsePlannedAction(content);\n\tif (!action) {\n\t\tthrow new Error('No valid action parsed from model output');\n\t}\n\treturn action;\n}\n\nfunction extractChatContent(json: any): string | undefined {\n\ttry {\n\t\tif (json && Array.isArray(json.choices) && json.choices[0]) {\n\t\t\tconst choice = json.choices[0];\n\t\t\tif (choice.message && typeof choice.message.content === 'string') {\n\t\t\t\treturn choice.message.content;\n\t\t\t}\n\t\t\tif (typeof choice.text === 'string') {\n\t\t\t\treturn choice.text;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction parsePlannedAction(raw: string): PlannedAction | undefined {\n\tlet text = raw.trim();\n\ttext = text.replace(/^```(?:json)?\s*/i, '').replace(/```\s*$/i, '').trim();\n\ttext = text.replace(/<think>[\s\S]*?<\/think>/gi, '').trim();\n\tlet parsed: any;\n\ttry {\n\t\tparsed = JSON.parse(text);\n\t} catch (err) {\n\t\treturn undefined;\n\t}\n\tif (Array.isArray(parsed)) {\n\t\tconsole.error('Model should not return an array.');\n\t\treturn undefined;\n\t}\n\tswitch (parsed.kind) {\n\t\tcase 'showTextDocument':\n\t\t\treturn { kind: 'showTextDocument' };\n\t\tcase 'setSelections': {\n\t\t\tconst selections = Array.isArray(parsed.selections) ? parsed.selections : [];\n\t\t\tconst norm = selections.map((s: any) => ({\n\t\t\t\tstart: Array.isArray(s?.start) && s.start.length === 2 ? [Number(s.start[0]) || 0, Number(s.start[1]) || 0] as [number, number] : [0, 0] as [number, number],\n\t\t\t\tend: Array.isArray(s?.end) && s.end.length === 2 ? [Number(s.end[0]) || 0, Number(s.end[1]) || 0] as [number, number] : [0, 0] as [number, number]\n\t\t\t}));\n\t\t\treturn { kind: 'setSelections', selections: norm };\n\t\t}\n\t\tcase 'editInsert': {\n\t\t\tconst pos = Array.isArray(parsed.position) && parsed.position.length === 2 ? [Number(parsed.position[0]) || 0, Number(parsed.position[1]) || 0] as [number, number] : [0, 0] as [number, number];\n\t\t\tconst textVal = typeof parsed.text === 'string' ? parsed.text : '';\n\t\t\treturn { kind: 'editInsert', position: pos, text: textVal };\n\t\t}\n\t\tcase 'editDelete': {\n\t\t\tconst start = Array.isArray(parsed.range?.start) && parsed.range.start.length === 2 ? [Number(parsed.range.start[0]) || 0, Number(parsed.range.start[1]) || 0] as [number, number] : [0, 0] as [number, number];\n\t\t\tconst end = Array.isArray(parsed.range?.end) && parsed.range.end.length === 2 ? [Number(parsed.range.end[0]) || 0, Number(parsed.range.end[1]) || 0] as [number, number] : [0, 0] as [number, number];\n\t\t\treturn { kind: 'editDelete', range: { start, end } };\n\t\t}\n\t\tcase 'editReplace': {\n\t\t\tconst start = Array.isArray(parsed.range?.start) && parsed.range.start.length === 2 ? [Number(parsed.range.start[0]) || 0, Number(parsed.range.start[1]) || 0] as [number, number] : [0, 0] as [number, number];\n\t\t\tconst end = Array.isArray(parsed.range?.end) && parsed.range.end.length === 2 ? [Number(parsed.range.end[0]) || 0, Number(parsed.range.end[1]) || 0] as [number, number] : [0, 0] as [number, number];\n\t\t\tconst textVal = typeof parsed.text === 'string' ? parsed.text : '';\n\t\t\treturn { kind: 'editReplace', range: { start, end }, text: textVal };\n\t\t}\n\t\tcase 'terminalShow':\n\t\t\treturn { kind: 'terminalShow' };\n\t\tcase 'terminalSendText': {\n\t\t\tconst textVal = typeof parsed.text === 'string' ? parsed.text : '';\n\t\t\treturn { kind: 'terminalSendText', text: textVal };\n\t\t}\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}",typescript,tab
|
| 3 |
+
2,299,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"3:35:04 PM [info] Activating crowd-code\n3:35:04 PM [info] Recording started\n3:35:04 PM [info] Initializing git provider using file system watchers...\n3:35:05 PM [info] Git repository found\n3:35:05 PM [info] Git provider initialized successfully\n3:35:05 PM [info] Initial git state: [object Object]\n",Log,tab
|
| 4 |
+
3,5984208,"src/extension.ts",0,0,"",typescript,tab
|
| 5 |
+
4,5992260,"src/extension.ts",34,22785,"import * as https from 'https';\nimport * as http from 'http';\nimport { Buffer } from 'buffer';\n\n\nconst SGLANG_HOSTNAME = 'hai001';\nconst SGLANG_PORT = 30000;\nconst SGLANG_BASE_PATH = '/v1/chat/completions';\nconst SGLANG_MODEL_NAME = 'qwen/qwen3-0.6b';\n\nconst GEMINI_HOSTNAME = 'generativelanguage.googleapis.com';\nconst GEMINI_PORT = 443;\nconst GEMINI_BASE_PATH = '/v1beta/openai/chat/completions';\nconst GEMINI_MODEL_NAME = 'gemini-2.5-flash';\n\nconst USE_GEMINI = true;\n\nexport function activate(context: vscode.ExtensionContext) {\n\n\tconsole.log('[crowd-pilot] Extension activated');\n\n\t// Configure terminal to allow tab keybinding to work\n\t(async () => {\n\t\tconst config = vscode.workspace.getConfiguration('terminal.integrated');\n\t\tconst commandsToSkipShell = config.get<string[]>('commandsToSkipShell', []);\n\t\tlet updated = false;\n\t\tif (!commandsToSkipShell.includes('crowd-pilot.modelRun')) {\n\t\t\tcommandsToSkipShell.push('crowd-pilot.modelRun');\n\t\t\tupdated = true;\n\t\t}\n\t\tif (!commandsToSkipShell.includes('crowd-pilot.hideUi')) {\n\t\t\tcommandsToSkipShell.push('crowd-pilot.hideUi');\n\t\t\tupdated = true;\n\t\t}\n\t\tif (updated) {\n\t\t\tawait config.update('commandsToSkipShell', commandsToSkipShell, vscode.ConfigurationTarget.Global);\n\t\t}\n\t})().catch((err) => console.error('[crowd-pilot] Startup initialization error:', err));\n\n\tconst hideUi = vscode.commands.registerCommand('crowd-pilot.hideUi', () => {\n\t\thidePreviewUI(true);\n\t});\n\n\tconst modelRun = vscode.commands.registerCommand('crowd-pilot.modelRun', async () => {\n\t\tconst editor = vscode.window.activeTextEditor;\n\t\tif (!editor) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\t// Confirm only when a suggestion is visible\n\t\t\tif (!previewVisible) { return; }\n\t\t\tlet action: PlannedAction | undefined = currentAction;\n\t\t\tif (!action) {\n\t\t\t\tconst single = await requestModelActions(editor);\n\t\t\t\tcurrentAction = single;\n\t\t\t\taction = single;\n\t\t\t}\n\t\t\tif (!action) {\n\t\t\t\thidePreviewUI();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\thidePreviewUI(false);\n\t\t\tawait executeAction(action);\n\t\t\tautoShowNextAction();\n\t\t} catch (err) {\n\t\t\tconst errorMessage = err instanceof Error ? err.message : String(err);\n\t\t\tvscode.window.showErrorMessage(`Model run failed: ${errorMessage}`);\n\t\t}\n\t});\n\n\tconst sglangTest = vscode.commands.registerCommand('crowd-pilot.sglangTest', async () => {\n\t\ttry {\n\t\t\tawait callSGLangChat();\n\t\t} catch (err) {\n\t\t\tconst errorMessage = err instanceof Error ? err.message : String(err);\n\t\t\tvscode.window.showErrorMessage(`SGLang test failed: ${errorMessage}`);\n\t\t}\n\t});\n\n\t// Auto-preview listeners\n\tconst onSelChange = vscode.window.onDidChangeTextEditorSelection((e) => {\n\t\tif (e.textEditor === vscode.window.activeTextEditor) {\n\t\t\tsuppressAutoPreview = false;\n\t\t\tautoShowNextAction();\n\t\t}\n\t});\n\tconst onActiveChange = vscode.window.onDidChangeActiveTextEditor(() => {\n\t\tsuppressAutoPreview = false;\n\t\tautoShowNextAction();\n\t});\n\tconst onDocChange = vscode.workspace.onDidChangeTextDocument((e) => {\n\t\tif (vscode.window.activeTextEditor?.document === e.document) {\n\t\t\tsuppressAutoPreview = false;\n\t\t\tautoShowNextAction();\n\t\t}\n\t});\n\n\tcontext.subscriptions.push(hideUi, sglangTest, modelRun, onSelChange, onActiveChange, onDocChange);\n}\n\nexport function deactivate() {}\n\n// -------------------- Plan Types & Execution --------------------\ntype PlannedAction =\n| { kind: 'showTextDocument' }\n| { kind: 'setSelections', selections: Array<{ start: [number, number], end: [number, number] }> }\n| { kind: 'editInsert', position: [number, number], text: string }\n| { kind: 'editDelete', range: { start: [number, number], end: [number, number] } }\n| { kind: 'editReplace', range: { start: [number, number], end: [number, number] }, text: string }\n| { kind: 'terminalShow' }\n| { kind: 'terminalSendText', text: string };\n\nlet currentAction: PlannedAction | undefined;\n\nasync function executeAction(action: PlannedAction): Promise<void> {\n\tconst editor = vscode.window.activeTextEditor;\n\tif (!editor) { return; }\n\tconst doc = editor.document;\n\tconst term = vscode.window.terminals[0] ?? vscode.window.createTerminal('Test');\n\tif (action.kind === 'showTextDocument') {\n\t\tawait vscode.window.showTextDocument(doc);\n\t\treturn;\n\t}\n\tif (action.kind === 'setSelections') {\n\t\teditor.selections = action.selections.map(s => new vscode.Selection(\n\t\t\tnew vscode.Position(s.start[0], s.start[1]),\n\t\t\tnew vscode.Position(s.end[0], s.end[1])\n\t\t));\n\t\tif (editor.selections.length > 0) {\n\t\t\teditor.revealRange(editor.selections[0], vscode.TextEditorRevealType.InCenterIfOutsideViewport);\n\t\t}\n\t\treturn;\n\t}\n\tif (action.kind === 'editInsert') {\n\t\tawait editor.edit((e: vscode.TextEditorEdit) => e.insert(new vscode.Position(action.position[0], action.position[1]), action.text));\n\t\treturn;\n\t}\n\tif (action.kind === 'editDelete') {\n\t\tconst range = new vscode.Range(\n\t\t\tnew vscode.Position(action.range.start[0], action.range.start[1]),\n\t\t\tnew vscode.Position(action.range.end[0], action.range.end[1])\n\t\t);\n\t\tawait editor.edit((e: vscode.TextEditorEdit) => e.delete(range));\n\t\treturn;\n\t}\n\tif (action.kind === 'editReplace') {\n\t\tconst range = new vscode.Range(\n\t\t\tnew vscode.Position(action.range.start[0], action.range.start[1]),\n\t\t\tnew vscode.Position(action.range.end[0], action.range.end[1])\n\t\t);\n\t\tawait editor.edit((e: vscode.TextEditorEdit) => e.replace(range, action.text));\n\t\treturn;\n\t}\n\tif (action.kind === 'terminalShow') {\n\t\tterm.show();\n\t\treturn;\n\t}\n\tif (action.kind === 'terminalSendText') {\n\t\tterm.sendText(action.text);\n\t\treturn;\n\t}\n}\n\n// -------------------- UI State & Helpers --------------------\nconst UI_CONTEXT_KEY = 'crowdPilot.uiVisible';\nlet previewVisible = false;\nlet decorationDeleteType: vscode.TextEditorDecorationType | undefined;\nlet decorationReplaceType: vscode.TextEditorDecorationType | undefined;\nlet decorationReplaceBlockType: vscode.TextEditorDecorationType | undefined;\nlet mockStep = 0;\nlet suppressAutoPreview = false;\n\nfunction disposePreviewDecorations() {\n\ttry { decorationDeleteType?.dispose(); } catch {}\n\ttry { decorationReplaceType?.dispose(); } catch {}\n\ttry { decorationReplaceBlockType?.dispose(); } catch {}\n\tdecorationDeleteType = undefined;\n\tdecorationReplaceType = undefined;\n\tdecorationReplaceBlockType = undefined;\n}\n\nfunction getDynamicMargin(editor: vscode.TextEditor, anchorLine: number, text: string): string {\n\t// Count lines in the preview text\n\tconst lines = text.split(/\r?\n/);\n\tconst height = lines.length;\n\t\n\t// We need to check the document lines that will be covered by this panel.\n\t// The panel starts at 'anchorLine' and extends downwards by 'height' lines.\n\t// However, visually, since it's 'after', it sits to the right of 'anchorLine',\n\t// and then flows down.\n\t// So we check document lines from anchorLine to anchorLine + height - 1.\n\t\n\tconst doc = editor.document;\n\tlet maxLen = 0;\n\tconst startLine = anchorLine;\n\tconst endLine = Math.min(doc.lineCount - 1, anchorLine + height - 1);\n\t\n\tfor (let i = startLine; i <= endLine; i++) {\n\t\tconst lineText = doc.lineAt(i).text;\n\t\t// Simple approximation: assume tabs are 4 spaces if we can't get config easily, \n\t\t// or just treat them as 1 char (which might underestimate). \n\t\t// Better to overestimate: treat tab as 4 chars.\n\t\tconst len = lineText.replace(/\t/g, ' ').length;\n\t\tif (len > maxLen) {\n\t\t\tmaxLen = len;\n\t\t}\n\t}\n\t\n\t// Length of the anchor line itself\n\tconst anchorLineText = doc.lineAt(anchorLine).text;\n\tconst anchorLen = anchorLineText.replace(/\t/g, ' ').length;\n\t\n\t// The offset needed is maxLen - anchorLen.\n\t// If maxLen <= anchorLen, offset is 0 (margin is just base padding).\n\t// If maxLen > anchorLen, we need to push right by (maxLen - anchorLen).\n\t\n\tconst diff = Math.max(0, maxLen - anchorLen);\n\t// Base margin 2rem is roughly 4ch. Let's use ch units for everything to be consistent.\n\t// 1ch is width of '0'. In monospace, mostly consistent.\n\t// Add 3ch extra padding for safety/visual gap.\n\tconst margin = diff + 4; \n\treturn `${margin}ch`;\n}\n\nfunction showPreviewUI(action: PlannedAction): void {\n\tconst editor = vscode.window.activeTextEditor;\n\tif (!editor) { return; }\n\tdisposePreviewDecorations();\n\n\t// FIXME (f.srambical): add file switch \n\tconst next = (action.kind === 'editInsert' || action.kind === 'editDelete' || action.kind === 'editReplace' || action.kind === 'terminalSendText' || action.kind === 'setSelections') ? action : undefined;\n\tif (!next) {\n\t\tpreviewVisible = false;\n\t\tvscode.commands.executeCommand('setContext', UI_CONTEXT_KEY, false);\n\t\tcurrentAction = action;\n\t\treturn;\n\t}\n\n\tconst trimText = (t: string) => {\n\t\tconst oneLine = t.replace(/\r?\n/g, '\\n');\n\t\treturn oneLine.length > 80 ? oneLine.slice(0, 77) + '…' : oneLine;\n\t};\n\n\tif (next.kind === 'setSelections') {\n\t\t// For setSelections, we only preview the primary selection's start/active position\n\t\tconst selection = next.selections[0];\n\t\tconst targetPos = new vscode.Position(selection.start[0], selection.start[1]);\n\t\t// Check if the target position is visible\n\t\tconst isVisible = editor.visibleRanges.some(r => r.contains(targetPos));\n\t\t\n\t\tlet anchorPos = targetPos;\n\t\tlet label = ""↳ Move Cursor Here"";\n\n\t\tif (!isVisible && editor.visibleRanges.length > 0) {\n\t\t\tconst firstVisible = editor.visibleRanges[0].start;\n\t\t\tconst lastVisible = editor.visibleRanges[editor.visibleRanges.length - 1].end;\n\t\t\t\n\t\t\tif (targetPos.isBefore(firstVisible)) {\n\t\t\t\tanchorPos = editor.document.lineAt(firstVisible.line).range.end;\n\t\t\t} else {\n\t\t\t\tanchorPos = editor.document.lineAt(lastVisible.line).range.end;\n\t\t\t}\n\n\t\t\tif (targetPos.line < anchorPos.line) {\n\t\t\t\tlabel = `↑ Move Cursor to Line ${targetPos.line + 1}`;\n\t\t\t} else {\n\t\t\t\tlabel = `↓ Move Cursor to Line ${targetPos.line + 1}`;\n\t\t\t}\n\t\t}\n\n\t\tconst margin = getDynamicMargin(editor, anchorPos.line, label);\n\n\t\tdecorationReplaceBlockType = vscode.window.createTextEditorDecorationType({\n\t\t\tafter: {\n\t\t\t\tcontentText: '',\n\t\t\t\tcolor: new vscode.ThemeColor('charts.purple'),\n\t\t\t\tbackgroundColor: new vscode.ThemeColor('editor.background'),\n\t\t\t\tfontStyle: 'italic',\n\t\t\t\tfontWeight: '600',\n\t\t\t\tmargin: `0 0 0 ${margin}`,\n\t\t\t\ttextDecoration: `none; display: inline-block; white-space: pre; content: ""${label}""; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`\n\t\t\t}\n\t\t});\n\t\teditor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(anchorPos, anchorPos) }]);\n\t} else if (next.kind === 'terminalSendText') {\n\t\tconst cursor = editor.selection.active;\n\t\tconst lineEnd = editor.document.lineAt(cursor.line).range.end;\n\t\tconst cmd = next.text.replace(/""/g, '\\""').replace(/\r?\n/g, '\\A ');\n\t\tconst margin = getDynamicMargin(editor, cursor.line, ""↳ Execute in Terminal:\n"" + next.text);\n\n\t\tdecorationReplaceBlockType = vscode.window.createTextEditorDecorationType({\n\t\t\tafter: {\n\t\t\t\tcontentText: '',\n\t\t\t\tcolor: new vscode.ThemeColor('charts.purple'),\n\t\t\t\tbackgroundColor: new vscode.ThemeColor('editor.background'),\n\t\t\t\tfontStyle: 'italic',\n\t\t\t\tfontWeight: '600',\n\t\t\t\tmargin: `0 0 0 ${margin}`,\n\t\t\t\ttextDecoration: `none; display: inline-block; white-space: pre; content: ""↳ Execute in Terminal:\\A ${cmd}""; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`\n\t\t\t}\n\t\t});\n\t\teditor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(lineEnd, lineEnd) }]);\n\t} else if (next.kind === 'editInsert') {\n\t\tconst posLine = next.position[0];\n\t\tconst fullBlock = next.text;\n\t\tconst cssContent = fullBlock\n\t\t\t.replace(/""/g, '\\""')\n\t\t\t.replace(/\r?\n/g, '\\A ');\n\n\t\tconst docLineCount = editor.document.lineCount;\n\t\t// If inserting at EOF (or beyond), attach to the last line.\n\t\t// Otherwise, attach to the line AT the insertion point and shift visually UP into the gap.\n\t\tlet anchorLine = posLine;\n\t\tlet shiftUp = true;\n\t\t\n\t\tif (anchorLine >= docLineCount) {\n\t\t\tanchorLine = docLineCount - 1;\n\t\t\tshiftUp = false; // At EOF, we just append below or to the right\n\t\t}\n\n\t\tconst anchorPos = new vscode.Position(anchorLine, Number.MAX_VALUE); \n\t\t\n\t\t// We attach to the line AT the insertion point.\n\t\t// The panel floats to the right of this line.\n\t\t// The dashed line connects the start of this line to the panel.\n\t\t// This indicates that the new text will be inserted at this line position (pushing the current line down).\n\t\tconst marginCheckLine = anchorLine;\n\t\tconst margin = getDynamicMargin(editor, marginCheckLine, fullBlock);\n\n\t\tconst topOffset = '0';\n\n\t\t// Dashed line style\n\t\t// We use 'before' decoration for the line.\n\t\t// It needs to be absolute, full width (or enough to reach left), \n\t\t// and aligned with the panel top.\n\t\tconst beforeDecoration = {\n\t\t\tcontentText: '',\n\t\t\ttextDecoration: `none; position: absolute; left: 0; width: 100vw; border-top: 1px dashed var(--vscode-charts-purple); top: 0; height: 0; z-index: 99; pointer-events: none;`\n\t\t};\n\n\t\tdecorationReplaceBlockType = vscode.window.createTextEditorDecorationType({\n\t\t\tbefore: beforeDecoration,\n\t\t\tafter: {\n\t\t\t\tcontentText: '',\n\t\t\t\tcolor: new vscode.ThemeColor('charts.purple'),\n\t\t\t\tbackgroundColor: new vscode.ThemeColor('editor.background'),\n\t\t\t\tfontStyle: 'italic',\n\t\t\t\tfontWeight: '600',\n\t\t\t\tmargin: `0 0 0 ${margin}`,\n\t\t\t\ttextDecoration: `none; display: inline-block; white-space: pre; content: ""${cssContent}""; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top; top: ${topOffset};`\n\t\t\t}\n\t\t});\n\t\teditor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(anchorPos, anchorPos) }]);\n\t} else if (next.kind === 'editDelete') {\n\t\tconst range = new vscode.Range(\n\t\t\tnew vscode.Position(next.range.start[0], next.range.start[1]),\n\t\t\tnew vscode.Position(next.range.end[0], next.range.end[1])\n\t\t);\n\t\tdecorationDeleteType = vscode.window.createTextEditorDecorationType({\n\t\t\tbackgroundColor: 'rgba(255, 60, 60, 0.18)',\n\t\t\tborder: '1px solid rgba(255, 60, 60, 0.35)',\n\t\t\ttextDecoration: 'line-through'\n\t\t});\n\t\teditor.setDecorations(decorationDeleteType, [{ range }]);\n\t} else if (next.kind === 'editReplace') {\n\t\tconst range = new vscode.Range(\n\t\t\tnew vscode.Position(next.range.start[0], next.range.start[1]),\n\t\t\tnew vscode.Position(next.range.end[0], next.range.end[1])\n\t\t);\n\t\t// Highlight original range (to be replaced)\n\t\tdecorationReplaceType = vscode.window.createTextEditorDecorationType({\n\t\t\tbackgroundColor: 'rgba(255,165,0,0.15)',\n\t\t\tborder: '1px dashed rgba(255,165,0,0.45)',\n\t\t\tcolor: new vscode.ThemeColor('disabledForeground'),\n\t\t\ttextDecoration: 'line-through'\n\t\t});\n\t\teditor.setDecorations(decorationReplaceType, [{ range }]);\n\n\t\t// Show replacement block to the right of the first replaced line\n\t\tconst fullBlock = next.text;\n\t\t\n\t\t// CSS-escape the text for the 'content' property:\n\t\t// - Escape double quotes\n\t\t// - Replace newlines with \A (CSS newline)\n\t\tconst cssContent = fullBlock\n\t\t\t.replace(/""/g, '\\""')\n\t\t\t.replace(/\r?\n/g, '\\A '); \n\n\t\t// Attach 'after' decoration to the start of the replacement range\n\t\t// (Actually, attaching to the end of the first line is safer for 'after')\n\t\tconst anchorLine = range.start.line;\n\t\tconst anchorPos = new vscode.Position(anchorLine, Number.MAX_VALUE);\n\t\tconst margin = getDynamicMargin(editor, anchorLine, fullBlock);\n\n\t\tdecorationReplaceBlockType = vscode.window.createTextEditorDecorationType({\n\t\t\tafter: {\n\t\t\t\tcontentText: '', // Handled by CSS content\n\t\t\t\tcolor: new vscode.ThemeColor('charts.purple'),\n\t\t\t\tbackgroundColor: new vscode.ThemeColor('editor.background'),\n\t\t\t\tfontStyle: 'italic',\n\t\t\t\tfontWeight: '600',\n\t\t\t\tmargin: `0 0 0 ${margin}`,\n\t\t\t\ttextDecoration: `none; display: inline-block; white-space: pre; content: ""${cssContent}""; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`\n\t\t\t}\n\t\t});\n\t\teditor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(anchorPos, anchorPos) }]);\n\t}\n\n\tpreviewVisible = true;\n\tvscode.commands.executeCommand('setContext', UI_CONTEXT_KEY, true);\n\tcurrentAction = action;\n}\n\nfunction hidePreviewUI(suppress?: boolean): void {\n\tdisposePreviewDecorations();\n\tpreviewVisible = false;\n\tvscode.commands.executeCommand('setContext', UI_CONTEXT_KEY, false);\n\tif (suppress) {\n\t\tsuppressAutoPreview = true;\n\t}\n}\n\n// -------------------- Hardcoded single-step actions --------------------\nfunction getHardcodedNextAction(editor: vscode.TextEditor): PlannedAction | undefined {\n\tconst cursor = editor.selection.active;\n\tconst doc = editor.document;\n\tconst lineCount = doc.lineCount;\n\tconst clamp = (n: number, min: number, max: number) => Math.max(min, Math.min(max, n));\n\n\t// Step 0: Insert multiline content two lines below the cursor (start of target line)\n\tif (mockStep === 0) {\n\t\tconst targetLine = clamp(cursor.line + 2, 0, Math.max(0, lineCount - 1));\n\t\treturn {\n\t\t\tkind: 'editInsert',\n\t\t\tposition: [targetLine, 0],\n\t\t\ttext: '/* crowd-pilot: insert start */\nline A\nline B\n/* crowd-pilot: insert end */\n'\n\t\t};\n\t}\n\t// Step 1: Replace a two-line range three and four lines below the cursor\n\tif (mockStep === 1) {\n\t\tconst startLine = clamp(cursor.line + 3, 0, Math.max(0, lineCount - 1));\n\t\tconst endLine = clamp(startLine + 1, 0, Math.max(0, lineCount - 1));\n\t\tconst endChar = doc.lineAt(endLine).range.end.character;\n\t\tconst range = {\n\t\t\tstart: [startLine, 0] as [number, number],\n\t\t\tend: [endLine, endChar] as [number, number]\n\t\t};\n\t\tconst replacement = [\n\t\t\t'/* crowd-pilot: replacement */',\n\t\t\t'REPLACED LINE 1',\n\t\t\t'REPLACED LINE 2'\n\t\t].join('\n');\n\t\treturn { kind: 'editReplace', range, text: replacement };\n\t}\n\t// Step 2: Delete a three-line range six to eight lines below the cursor\n\tif (mockStep === 2) {\n\t\tconst startLine = clamp(cursor.line + 6, 0, Math.max(0, lineCount - 1));\n\t\tconst endLine = clamp(startLine + 2, 0, Math.max(0, lineCount - 1));\n\t\t\n\t\t// To fully delete the lines including the newline, we target the start of the next line.\n\t\tlet endPosLine = endLine + 1;\n\t\tlet endPosChar = 0;\n\t\t\n\t\tif (endPosLine >= lineCount) {\n\t\t\t// If deleting the last line(s), just go to the end of the document\n\t\t\tendPosLine = lineCount - 1;\n\t\t\tendPosChar = doc.lineAt(endPosLine).range.end.character;\n\t\t}\n\n\t\tconst range = {\n\t\t\tstart: [startLine, 0] as [number, number],\n\t\t\tend: [endPosLine, endPosChar] as [number, number]\n\t\t};\n\t\treturn { kind: 'editDelete', range };\n\t}\n\t// Step 3: Execute in Terminal\n\tif (mockStep === 3) {\n\t\treturn { kind: 'terminalSendText', text: 'echo ""Hello World""' };\n\t}\n\t// Step 4: Move Cursor to End of File\n\tif (mockStep === 4) {\n\t\tconst lastLine = doc.lineCount - 1;\n\t\tconst lastChar = doc.lineAt(lastLine).range.end.character;\n\t\treturn {\n\t\t\tkind: 'setSelections',\n\t\t\tselections: [{ start: [lastLine, lastChar], end: [lastLine, lastChar] }]\n\t\t};\n\t}\n\treturn undefined;\n}\n\nfunction advanceMockStep(): void {\n\tmockStep = (mockStep + 1) % 5;\n}\n\nasync function autoShowNextAction(): Promise<void> {\n\tif (suppressAutoPreview) { return; }\n\tconst editor = vscode.window.activeTextEditor;\n\tif (!editor) { return; }\n\ttry {\n\t\tconst next = await requestModelActions(editor);\n\t\tif (next) {\n\t\t\tshowPreviewUI(next);\n\t\t} else {\n\t\t\thidePreviewUI();\n\t\t}\n\t} catch (err) {\n\t\thidePreviewUI();\n\t}\n}\n\n// -------------------- SGLang Client (simple test) --------------------\nasync function callSGLangChat(): Promise<void> {\n\tconst config = vscode.workspace.getConfiguration();\n\t\n\tlet hostname: string;\n\tlet port: number;\n\tlet path: string;\n\tlet useHttps = true;\n\tlet modelName: string;\n\tconst headers: any = {\n\t\t'Content-Type': 'application/json'\n\t};\n\n\tif (!USE_GEMINI) {\n\t\t// SGLang\n\t\thostname = SGLANG_HOSTNAME;\n\t\tport = SGLANG_PORT;\n\t\tpath = SGLANG_BASE_PATH;\n\t\tuseHttps = false; \n\t\tmodelName = SGLANG_MODEL_NAME;\n\t} else {\n\t\t// Gemini\n\t\tconst apiKey = config.get<string>('crowd-pilot.apiKey');\n\t\tif (!apiKey) {\n\t\t\tvscode.window.showErrorMessage('Crowd Pilot: Please set your API Key in settings (crowd-pilot.apiKey).');\n\t\t\treturn;\n\t\t}\n\t\thostname = GEMINI_HOSTNAME;\n\t\tport = GEMINI_PORT;\n\t\tpath = GEMINI_BASE_PATH;\n\t\theaders['Authorization'] = `Bearer ${apiKey}`;\n\t\tmodelName = GEMINI_MODEL_NAME;\n\t}\n\n\tconst requestBody = {\n\t\tmodel: modelName,\n\t\tmessages: [\n\t\t\t{ role: 'user', content: 'What is the capital of France?' }\n\t\t]\n\t};\n\tconst postData = JSON.stringify(requestBody);\n\theaders['Content-Length'] = Buffer.byteLength(postData);\n\n\tconst options = {\n\t\thostname,\n\t\tport,\n\t\tpath,\n\t\tmethod: 'POST',\n\t\theaders\n\t};\n\n\tconst requestModule = useHttps ? https : http;\n\n\ttry {\n\t\tconst json = await new Promise<any>((resolve, reject) => {\n\t\t\tconst req = requestModule.request(options, (res: http.IncomingMessage) => {\n\t\t\t\tlet data = '';\n\t\t\t\tres.on('data', (chunk: Buffer) => {\n\t\t\t\t\tdata += chunk.toString();\n\t\t\t\t});\n\t\t\t\tres.on('end', () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresolve(JSON.parse(data));\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\treject(new Error(`Failed to parse response: ${err instanceof Error ? err.message : String(err)}`));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\n\t\t\treq.on('error', (err: Error) => {\n\t\t\t\treject(err);\n\t\t\t});\n\n\t\t\treq.write(postData);\n\t\t\treq.end();\n\t\t});\n\n\t\tvscode.window.showInformationMessage(`Response: ${JSON.stringify(json, null, 2)}`);\n\t} catch (err) {\n\t\tconst errorMessage = err instanceof Error ? err.message : String(err);\n\t\tvscode.window.showErrorMessage(`Request failed: ${errorMessage}`);\n\t}\n}\n\n// -------------------- Model-planned Actions --------------------\nasync function requestModelActions(editor: vscode.TextEditor): Promise<PlannedAction> {\n\tconst config = vscode.workspace.getConfiguration();\n\t\n\tlet hostname: string;\n\tlet port: number;\n\tlet path: string;\n\tlet useHttps = true;\n\tlet modelName: string;\n\tconst headers: any = {\n\t\t'Content-Type': 'application/json'\n\t};\n\n\tif (!USE_GEMINI) {\n\t\t// SGLang\n\t\thostname = SGLANG_HOSTNAME;\n\t\tport = SGLANG_PORT;\n\t\tpath = SGLANG_BASE_PATH;\n\t\tuseHttps = false;\n\t\tmodelName = SGLANG_MODEL_NAME;\n\t} else {\n\t\t// Gemini\n\t\tconst apiKey = config.get<string>('crowd-pilot.apiKey');\n\t\tif (!apiKey) {\n\t\t\tvscode.window.showErrorMessage('Crowd Pilot: Please set your API Key in settings (crowd-pilot.apiKey).');\n\t\t\tthrow new Error('API key not set');\n\t\t}\n\t\thostname = GEMINI_HOSTNAME;\n\t\tport = GEMINI_PORT;\n\t\tpath = GEMINI_BASE_PATH;\n\t\theaders['Authorization'] = `Bearer ${apiKey}`;\n\t\tmodelName = GEMINI_MODEL_NAME;\n\t}\n\n\tconst schemaDescription = [\n\t\t'Role: You suggest the next VS Code editor/terminal action to progress the current task.',\n\t\t'Output ONLY a JSON object (no prose, no code fences).',\n\t\t'Coordinates are zero-based [line, column].',\n\t\t'Allowed actions (JSON schema-like):',\n\t\t'{ kind: ""showTextDocument"" }',\n\t\t'{ kind: ""setSelections"", selections: Array<{ start: [number, number], end: [number, number] }> }',\n\t\t'{ kind: ""editInsert"", position: [number, number], text: string }',\n\t\t'{ kind: ""editDelete"", range: { start: [number, number], end: [number, number] } }',\n\t\t'{ kind: ""editReplace"", range: { start: [number, number], end: [number, number] }, text: string }',\n\t\t'{ kind: ""terminalShow"" }',\n\t\t'{ kind: ""terminalSendText"", text: string }',\n\t\t'Guidelines:',\n\t\t'- If you you insert text, insert until the logical end of the current statement or block.',\n\t\t'- When inserting text, make sure to not repeat existing text (except when replacing existing text).',\n\t\t'- Use double-quoted JSON strings.'\n\t].join('\n');\n\n\tconst doc = editor.document;\n\tconst cursor = editor.selection.active;\n\tconst fullText = doc.getText();\n\tconst numberedContext = fullText.split(/\r?\n/).map((line, i) => `${i}: ${line}`).join('\n');\n\n\tconst tabbingPrompt = [\n\t\t'Your role: Propose the single next action according to the schema to help the developer progress.',\n\t\t'',\n\t\t'Available context:',\n\t\t`- File: ${doc.fileName}`,\n\t\t`- Language: ${doc.languageId}`,\n\t\t`- Cursor: (${cursor.line}, ${cursor.character})`,\n\t\t'',\n\t\t'Full file content (zero-based line numbers):',\n\t\t'```',\n\t\tnumberedContext,\n\t\t'```',\n\t\t'',\n\t\t'Respond with ONLY a JSON object containing exactly one action.'\n\t].join('\n');\n\n\tconst requestBody = {\n\t\tmodel: modelName,\n\t\tmessages: [\n\t\t\t{ role: 'system', content: schemaDescription },\n\t\t\t{ role: 'user', content: tabbingPrompt }\n\t\t]\n\t};\n\n\tconst postData = JSON.stringify(requestBody);\n\theaders['Content-Length'] = Buffer.byteLength(postData);\n\n\tconst options = {\n\t\thostname,\n\t\tport,\n\t\tpath,\n\t\tmethod: 'POST',\n\t\theaders\n\t};\n\n\tconst requestModule = useHttps ? https : http;\n\n\tconst json = await new Promise<any>((resolve, reject) => {\n\t\tconst req = requestModule.request(options, (res: http.IncomingMessage) => {\n",typescript,content
|
| 6 |
+
5,5992314,"/fast/home/franz.srambical/crowd-pilot-extension/out/extension.js",0,0,"""use strict"";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (""get"" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, ""default"", { enumerable: true, value: v });\n}) : function(o, v) {\n o[""default""] = v;\n});\nvar __importStar = (this && this.__importStar) || (function () {\n var ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n };\n return function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== ""default"") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n };\n})();\nObject.defineProperty(exports, ""__esModule"", { value: true });\nexports.activate = activate;\nexports.deactivate = deactivate;\nconst vscode = __importStar(require(""vscode""));\nconst http = __importStar(require(""http""));\nconst buffer_1 = require(""buffer"");\nconst HOSTNAME = 'hai001';\nconst PORT = 30000;\nfunction activate(context) {\n console.log('[crowd-pilot] Extension activated');\n // Configure terminal to allow tab keybinding to work\n (async () => {\n const config = vscode.workspace.getConfiguration('terminal.integrated');\n const commandsToSkipShell = config.get('commandsToSkipShell', []);\n let updated = false;\n if (!commandsToSkipShell.includes('crowd-pilot.modelRun')) {\n commandsToSkipShell.push('crowd-pilot.modelRun');\n updated = true;\n }\n if (!commandsToSkipShell.includes('crowd-pilot.hideUi')) {\n commandsToSkipShell.push('crowd-pilot.hideUi');\n updated = true;\n }\n if (updated) {\n await config.update('commandsToSkipShell', commandsToSkipShell, vscode.ConfigurationTarget.Global);\n }\n })().catch((err) => console.error('[crowd-pilot] Startup initialization error:', err));\n const hideUi = vscode.commands.registerCommand('crowd-pilot.hideUi', () => {\n hidePreviewUI(true);\n });\n const modelRun = vscode.commands.registerCommand('crowd-pilot.modelRun', async () => {\n const editor = vscode.window.activeTextEditor;\n if (!editor) {\n return;\n }\n try {\n // Confirm only when a suggestion is visible\n if (!previewVisible) {\n return;\n }\n let action = currentAction;\n if (!action) {\n const single = await requestModelActions(editor);\n currentAction = single;\n action = single;\n }\n if (!action) {\n hidePreviewUI();\n return;\n }\n hidePreviewUI(false);\n await executeAction(action);\n autoShowNextAction();\n }\n catch (err) {\n const errorMessage = err instanceof Error ? err.message : String(err);\n vscode.window.showErrorMessage(`Model run failed: ${errorMessage}`);\n }\n });\n const sglangTest = vscode.commands.registerCommand('crowd-pilot.sglangTest', async () => {\n try {\n await callSGLangChat();\n }\n catch (err) {\n const errorMessage = err instanceof Error ? err.message : String(err);\n vscode.window.showErrorMessage(`SGLang test failed: ${errorMessage}`);\n }\n });\n // Auto-preview listeners\n const onSelChange = vscode.window.onDidChangeTextEditorSelection((e) => {\n if (e.textEditor === vscode.window.activeTextEditor) {\n suppressAutoPreview = false;\n autoShowNextAction();\n }\n });\n const onActiveChange = vscode.window.onDidChangeActiveTextEditor(() => {\n suppressAutoPreview = false;\n autoShowNextAction();\n });\n const onDocChange = vscode.workspace.onDidChangeTextDocument((e) => {\n if (vscode.window.activeTextEditor?.document === e.document) {\n suppressAutoPreview = false;\n autoShowNextAction();\n }\n });\n context.subscriptions.push(hideUi, sglangTest, modelRun, onSelChange, onActiveChange, onDocChange);\n}\nfunction deactivate() { }\nlet currentAction;\nasync function executeAction(action) {\n const editor = vscode.window.activeTextEditor;\n if (!editor) {\n return;\n }\n const doc = editor.document;\n const term = vscode.window.terminals[0] ?? vscode.window.createTerminal('Test');\n if (action.kind === 'showTextDocument') {\n await vscode.window.showTextDocument(doc);\n return;\n }\n if (action.kind === 'setSelections') {\n editor.selections = action.selections.map(s => new vscode.Selection(new vscode.Position(s.start[0], s.start[1]), new vscode.Position(s.end[0], s.end[1])));\n if (editor.selections.length > 0) {\n editor.revealRange(editor.selections[0], vscode.TextEditorRevealType.InCenterIfOutsideViewport);\n }\n return;\n }\n if (action.kind === 'editInsert') {\n await editor.edit((e) => e.insert(new vscode.Position(action.position[0], action.position[1]), action.text));\n return;\n }\n if (action.kind === 'editDelete') {\n const range = new vscode.Range(new vscode.Position(action.range.start[0], action.range.start[1]), new vscode.Position(action.range.end[0], action.range.end[1]));\n await editor.edit((e) => e.delete(range));\n return;\n }\n if (action.kind === 'editReplace') {\n const range = new vscode.Range(new vscode.Position(action.range.start[0], action.range.start[1]), new vscode.Position(action.range.end[0], action.range.end[1]));\n await editor.edit((e) => e.replace(range, action.text));\n return;\n }\n if (action.kind === 'terminalShow') {\n term.show();\n return;\n }\n if (action.kind === 'terminalSendText') {\n term.sendText(action.text);\n return;\n }\n}\n// -------------------- UI State & Helpers --------------------\nconst UI_CONTEXT_KEY = 'crowdPilot.uiVisible';\nlet previewVisible = false;\nlet decorationDeleteType;\nlet decorationReplaceType;\nlet decorationReplaceBlockType;\nlet mockStep = 0;\nlet suppressAutoPreview = false;\nfunction disposePreviewDecorations() {\n try {\n decorationDeleteType?.dispose();\n }\n catch { }\n try {\n decorationReplaceType?.dispose();\n }\n catch { }\n try {\n decorationReplaceBlockType?.dispose();\n }\n catch { }\n decorationDeleteType = undefined;\n decorationReplaceType = undefined;\n decorationReplaceBlockType = undefined;\n}\nfunction getDynamicMargin(editor, anchorLine, text) {\n // Count lines in the preview text\n const lines = text.split(/\r?\n/);\n const height = lines.length;\n // We need to check the document lines that will be covered by this panel.\n // The panel starts at 'anchorLine' and extends downwards by 'height' lines.\n // However, visually, since it's 'after', it sits to the right of 'anchorLine',\n // and then flows down.\n // So we check document lines from anchorLine to anchorLine + height - 1.\n const doc = editor.document;\n let maxLen = 0;\n const startLine = anchorLine;\n const endLine = Math.min(doc.lineCount - 1, anchorLine + height - 1);\n for (let i = startLine; i <= endLine; i++) {\n const lineText = doc.lineAt(i).text;\n // Simple approximation: assume tabs are 4 spaces if we can't get config easily, \n // or just treat them as 1 char (which might underestimate). \n // Better to overestimate: treat tab as 4 chars.\n const len = lineText.replace(/\t/g, ' ').length;\n if (len > maxLen) {\n maxLen = len;\n }\n }\n // Length of the anchor line itself\n const anchorLineText = doc.lineAt(anchorLine).text;\n const anchorLen = anchorLineText.replace(/\t/g, ' ').length;\n // The offset needed is maxLen - anchorLen.\n // If maxLen <= anchorLen, offset is 0 (margin is just base padding).\n // If maxLen > anchorLen, we need to push right by (maxLen - anchorLen).\n const diff = Math.max(0, maxLen - anchorLen);\n // Base margin 2rem is roughly 4ch. Let's use ch units for everything to be consistent.\n // 1ch is width of '0'. In monospace, mostly consistent.\n // Add 3ch extra padding for safety/visual gap.\n const margin = diff + 4;\n return `${margin}ch`;\n}\nfunction showPreviewUI(action) {\n const editor = vscode.window.activeTextEditor;\n if (!editor) {\n return;\n }\n disposePreviewDecorations();\n // FIXME (f.srambical): add file switch \n const next = (action.kind === 'editInsert' || action.kind === 'editDelete' || action.kind === 'editReplace' || action.kind === 'terminalSendText' || action.kind === 'setSelections') ? action : undefined;\n if (!next) {\n previewVisible = false;\n vscode.commands.executeCommand('setContext', UI_CONTEXT_KEY, false);\n currentAction = action;\n return;\n }\n const trimText = (t) => {\n const oneLine = t.replace(/\r?\n/g, '\\n');\n return oneLine.length > 80 ? oneLine.slice(0, 77) + '…' : oneLine;\n };\n if (next.kind === 'setSelections') {\n // For setSelections, we only preview the primary selection's start/active position\n const selection = next.selections[0];\n const targetPos = new vscode.Position(selection.start[0], selection.start[1]);\n // Check if the target position is visible\n const isVisible = editor.visibleRanges.some(r => r.contains(targetPos));\n let anchorPos = targetPos;\n let label = ""↳ Move Cursor Here"";\n if (!isVisible && editor.visibleRanges.length > 0) {\n const firstVisible = editor.visibleRanges[0].start;\n const lastVisible = editor.visibleRanges[editor.visibleRanges.length - 1].end;\n if (targetPos.isBefore(firstVisible)) {\n anchorPos = editor.document.lineAt(firstVisible.line).range.end;\n }\n else {\n anchorPos = editor.document.lineAt(lastVisible.line).range.end;\n }\n if (targetPos.line < anchorPos.line) {\n label = `↑ Move Cursor to Line ${targetPos.line + 1}`;\n }\n else {\n label = `↓ Move Cursor to Line ${targetPos.line + 1}`;\n }\n }\n const margin = getDynamicMargin(editor, anchorPos.line, label);\n decorationReplaceBlockType = vscode.window.createTextEditorDecorationType({\n after: {\n contentText: '',\n color: new vscode.ThemeColor('charts.purple'),\n backgroundColor: new vscode.ThemeColor('editor.background'),\n fontStyle: 'italic',\n fontWeight: '600',\n margin: `0 0 0 ${margin}`,\n textDecoration: `none; display: inline-block; white-space: pre; content: ""${label}""; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`\n }\n });\n editor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(anchorPos, anchorPos) }]);\n }\n else if (next.kind === 'terminalSendText') {\n const cursor = editor.selection.active;\n const lineEnd = editor.document.lineAt(cursor.line).range.end;\n const cmd = next.text.replace(/""/g, '\\""').replace(/\r?\n/g, '\\A ');\n const margin = getDynamicMargin(editor, cursor.line, ""↳ Execute in Terminal:\n"" + next.text);\n decorationReplaceBlockType = vscode.window.createTextEditorDecorationType({\n after: {\n contentText: '',\n color: new vscode.ThemeColor('charts.purple'),\n backgroundColor: new vscode.ThemeColor('editor.background'),\n fontStyle: 'italic',\n fontWeight: '600',\n margin: `0 0 0 ${margin}`,\n textDecoration: `none; display: inline-block; white-space: pre; content: ""↳ Execute in Terminal:\\A ${cmd}""; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`\n }\n });\n editor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(lineEnd, lineEnd) }]);\n }\n else if (next.kind === 'editInsert') {\n const posLine = next.position[0];\n const fullBlock = next.text;\n const cssContent = fullBlock\n .replace(/""/g, '\\""')\n .replace(/\r?\n/g, '\\A ');\n const docLineCount = editor.document.lineCount;\n // If inserting at EOF (or beyond), attach to the last line.\n // Otherwise, attach to the line AT the insertion point and shift visually UP into the gap.\n let anchorLine = posLine;\n let shiftUp = true;\n if (anchorLine >= docLineCount) {\n anchorLine = docLineCount - 1;\n shiftUp = false; // At EOF, we just append below or to the right\n }\n const anchorPos = new vscode.Position(anchorLine, Number.MAX_VALUE);\n // We attach to the line AT the insertion point.\n // The panel floats to the right of this line.\n // The dashed line connects the start of this line to the panel.\n // This indicates that the new text will be inserted at this line position (pushing the current line down).\n const marginCheckLine = anchorLine;\n const margin = getDynamicMargin(editor, marginCheckLine, fullBlock);\n const topOffset = '0';\n // Dashed line style\n // We use 'before' decoration for the line.\n // It needs to be absolute, full width (or enough to reach left), \n // and aligned with the panel top.\n const beforeDecoration = {\n contentText: '',\n textDecoration: `none; position: absolute; left: 0; width: 100vw; border-top: 1px dashed var(--vscode-charts-purple); top: 0; height: 0; z-index: 99; pointer-events: none;`\n };\n decorationReplaceBlockType = vscode.window.createTextEditorDecorationType({\n before: beforeDecoration,\n after: {\n contentText: '',\n color: new vscode.ThemeColor('charts.purple'),\n backgroundColor: new vscode.ThemeColor('editor.background'),\n fontStyle: 'italic',\n fontWeight: '600',\n margin: `0 0 0 ${margin}`,\n textDecoration: `none; display: inline-block; white-space: pre; content: ""${cssContent}""; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top; top: ${topOffset};`\n }\n });\n editor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(anchorPos, anchorPos) }]);\n }\n else if (next.kind === 'editDelete') {\n const range = new vscode.Range(new vscode.Position(next.range.start[0], next.range.start[1]), new vscode.Position(next.range.end[0], next.range.end[1]));\n decorationDeleteType = vscode.window.createTextEditorDecorationType({\n backgroundColor: 'rgba(255, 60, 60, 0.18)',\n border: '1px solid rgba(255, 60, 60, 0.35)',\n textDecoration: 'line-through'\n });\n editor.setDecorations(decorationDeleteType, [{ range }]);\n }\n else if (next.kind === 'editReplace') {\n const range = new vscode.Range(new vscode.Position(next.range.start[0], next.range.start[1]), new vscode.Position(next.range.end[0], next.range.end[1]));\n // Highlight original range (to be replaced)\n decorationReplaceType = vscode.window.createTextEditorDecorationType({\n backgroundColor: 'rgba(255,165,0,0.15)',\n border: '1px dashed rgba(255,165,0,0.45)',\n color: new vscode.ThemeColor('disabledForeground'),\n textDecoration: 'line-through'\n });\n editor.setDecorations(decorationReplaceType, [{ range }]);\n // Show replacement block to the right of the first replaced line\n const fullBlock = next.text;\n // CSS-escape the text for the 'content' property:\n // - Escape double quotes\n // - Replace newlines with \A (CSS newline)\n const cssContent = fullBlock\n .replace(/""/g, '\\""')\n .replace(/\r?\n/g, '\\A ');\n // Attach 'after' decoration to the start of the replacement range\n // (Actually, attaching to the end of the first line is safer for 'after')\n const anchorLine = range.start.line;\n const anchorPos = new vscode.Position(anchorLine, Number.MAX_VALUE);\n const margin = getDynamicMargin(editor, anchorLine, fullBlock);\n decorationReplaceBlockType = vscode.window.createTextEditorDecorationType({\n after: {\n contentText: '', // Handled by CSS content\n color: new vscode.ThemeColor('charts.purple'),\n backgroundColor: new vscode.ThemeColor('editor.background'),\n fontStyle: 'italic',\n fontWeight: '600',\n margin: `0 0 0 ${margin}`,\n textDecoration: `none; display: inline-block; white-space: pre; content: ""${cssContent}""; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`\n }\n });\n editor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(anchorPos, anchorPos) }]);\n }\n previewVisible = true;\n vscode.commands.executeCommand('setContext', UI_CONTEXT_KEY, true);\n currentAction = action;\n}\nfunction hidePreviewUI(suppress) {\n disposePreviewDecorations();\n previewVisible = false;\n vscode.commands.executeCommand('setContext', UI_CONTEXT_KEY, false);\n if (suppress) {\n suppressAutoPreview = true;\n }\n}\n// -------------------- Hardcoded single-step actions --------------------\nfunction getHardcodedNextAction(editor) {\n const cursor = editor.selection.active;\n const doc = editor.document;\n const lineCount = doc.lineCount;\n const clamp = (n, min, max) => Math.max(min, Math.min(max, n));\n // Step 0: Insert multiline content two lines below the cursor (start of target line)\n if (mockStep === 0) {\n const targetLine = clamp(cursor.line + 2, 0, Math.max(0, lineCount - 1));\n return {\n kind: 'editInsert',\n position: [targetLine, 0],\n text: '/* crowd-pilot: insert start */\nline A\nline B\n/* crowd-pilot: insert end */\n'\n };\n }\n // Step 1: Replace a two-line range three and four lines below the cursor\n if (mockStep === 1) {\n const startLine = clamp(cursor.line + 3, 0, Math.max(0, lineCount - 1));\n const endLine = clamp(startLine + 1, 0, Math.max(0, lineCount - 1));\n const endChar = doc.lineAt(endLine).range.end.character;\n const range = {\n start: [startLine, 0],\n end: [endLine, endChar]\n };\n const replacement = [\n '/* crowd-pilot: replacement */',\n 'REPLACED LINE 1',\n 'REPLACED LINE 2'\n ].join('\n');\n return { kind: 'editReplace', range, text: replacement };\n }\n // Step 2: Delete a three-line range six to eight lines below the cursor\n if (mockStep === 2) {\n const startLine = clamp(cursor.line + 6, 0, Math.max(0, lineCount - 1));\n const endLine = clamp(startLine + 2, 0, Math.max(0, lineCount - 1));\n // To fully delete the lines including the newline, we target the start of the next line.\n let endPosLine = endLine + 1;\n let endPosChar = 0;\n if (endPosLine >= lineCount) {\n // If deleting the last line(s), just go to the end of the document\n endPosLine = lineCount - 1;\n endPosChar = doc.lineAt(endPosLine).range.end.character;\n }\n const range = {\n start: [startLine, 0],\n end: [endPosLine, endPosChar]\n };\n return { kind: 'editDelete', range };\n }\n // Step 3: Execute in Terminal\n if (mockStep === 3) {\n return { kind: 'terminalSendText', text: 'echo ""Hello World""' };\n }\n // Step 4: Move Cursor to End of File\n if (mockStep === 4) {\n const lastLine = doc.lineCount - 1;\n const lastChar = doc.lineAt(lastLine).range.end.character;\n return {\n kind: 'setSelections',\n selections: [{ start: [lastLine, lastChar], end: [lastLine, lastChar] }]\n };\n }\n return undefined;\n}\nfunction advanceMockStep() {\n mockStep = (mockStep + 1) % 5;\n}\nasync function autoShowNextAction() {\n if (suppressAutoPreview) {\n return;\n }\n const editor = vscode.window.activeTextEditor;\n if (!editor) {\n return;\n }\n try {\n const next = await requestModelActions(editor);\n if (next) {\n showPreviewUI(next);\n }\n else {\n hidePreviewUI();\n }\n }\n catch (err) {\n hidePreviewUI();\n }\n}\n// -------------------- SGLang Client (simple test) --------------------\nasync function callSGLangChat() {\n const requestBody = {\n model: 'qwen/qwen2.5-0.5b-instruct',\n messages: [\n { role: 'user', content: 'What is the capital of France?' }\n ]\n };\n const postData = JSON.stringify(requestBody);\n const options = {\n hostname: HOSTNAME,\n port: PORT,\n path: '/v1/chat/completions',\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Content-Length': buffer_1.Buffer.byteLength(postData)\n }\n };\n try {\n const json = await new Promise((resolve, reject) => {\n const req = http.request(options, (res) => {\n let data = '';\n res.on('data', (chunk) => {\n data += chunk.toString();\n });\n res.on('end', () => {\n try {\n resolve(JSON.parse(data));\n }\n catch (err) {\n reject(new Error(`Failed to parse response: ${err instanceof Error ? err.message : String(err)}`));\n }\n });\n });\n req.on('error', (err) => {\n reject(err);\n });\n req.write(postData);\n req.end();\n });\n vscode.window.showInformationMessage(`SGLang response: ${JSON.stringify(json, null, 2)}`);\n }\n catch (err) {\n const errorMessage = err instanceof Error ? err.message : String(err);\n vscode.window.showErrorMessage(`SGLang request failed: ${errorMessage}`);\n }\n}\n// -------------------- Model-planned Actions --------------------\nasync function requestModelActions(editor) {\n const schemaDescription = [\n 'Role: You suggest the next VS Code editor/terminal action to progress the current task.',\n 'Output ONLY a JSON object (no prose, no code fences).',\n 'Coordinates are zero-based [line, column].',\n 'Allowed actions (JSON schema-like):',\n '{ kind: ""showTextDocument"" }',\n '{ kind: ""setSelections"", selections: Array<{ start: [number, number], end: [number, number] }> }',\n '{ kind: ""editInsert"", position: [number, number], text: string }',\n '{ kind: ""editDelete"", range: { start: [number, number], end: [number, number] } }',\n '{ kind: ""editReplace"", range: { start: [number, number], end: [number, number] }, text: string }',\n '{ kind: ""terminalShow"" }',\n '{ kind: ""terminalSendText"", text: string }',\n 'Guidelines:',\n '- If you you insert text, insert until the logical end of the current statement or block.',\n '- When inserting text, make sure to not repeat existing text (except when replacing existing text).',\n '- Use double-quoted JSON strings.'\n ].join('\n');\n const doc = editor.document;\n const cursor = editor.selection.active;\n const fullText = doc.getText();\n const numberedContext = fullText.split(/\r?\n/).map((line, i) => `${i}: ${line}`).join('\n');\n const tabbingPrompt = [\n 'Your role: Propose the single next action according to the schema to help the developer progress.',\n '',\n 'Available context:',\n `- File: ${doc.fileName}`,\n `- Language: ${doc.languageId}`,\n `- Cursor: (${cursor.line}, ${cursor.character})`,\n '',\n 'Full file content (zero-based line numbers):',\n '```',\n numberedContext,\n '```',\n '',\n 'Respond with ONLY a JSON object containing exactly one action.'\n ].join('\n');\n const requestBody = {\n model: 'qwen/qwen2.5-0.5b-instruct',\n messages: [\n { role: 'system', content: schemaDescription },\n { role: 'user', content: tabbingPrompt }\n ]\n };\n const postData = JSON.stringify(requestBody);\n const options = {\n hostname: HOSTNAME,\n port: PORT,\n path: '/v1/chat/completions',\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Content-Length': buffer_1.Buffer.byteLength(postData)\n }\n };\n const json = await new Promise((resolve, reject) => {\n const req = http.request(options, (res) => {\n let data = '';\n res.on('data', (chunk) => { data += chunk.toString(); });\n res.on('end', () => {\n try {\n resolve(JSON.parse(data));\n }\n catch (err) {\n reject(new Error(`Failed to parse response: ${err instanceof Error ? err.message : String(err)}`));\n }\n });\n });\n req.on('error', (err) => reject(err));\n req.write(postData);\n req.end();\n });\n const content = extractChatContent(json);\n if (typeof content !== 'string' || content.trim().length === 0) {\n throw new Error('Empty model content');\n }\n const action = parsePlannedAction(content);\n if (!action) {\n throw new Error('No valid action parsed from model output');\n }\n return action;\n}\nfunction extractChatContent(json) {\n try {\n if (json && Array.isArray(json.choices) && json.choices[0]) {\n const choice = json.choices[0];\n if (choice.message && typeof choice.message.content === 'string') {\n return choice.message.content;\n }\n if (typeof choice.text === 'string') {\n return choice.text;\n }\n }\n return undefined;\n }\n catch {\n return undefined;\n }\n}\nfunction parsePlannedAction(raw) {\n let text = raw.trim();\n text = text.replace(/^```(?:json)?\s*/i, '').replace(/```\s*$/i, '').trim();\n text = text.replace(/<think>[\s\S]*?<\/think>/gi, '').trim();\n let parsed;\n try {\n parsed = JSON.parse(text);\n }\n catch (err) {\n return undefined;\n }\n if (Array.isArray(parsed)) {\n console.error('Model should not return an array.');\n return undefined;\n }\n switch (parsed.kind) {\n case 'showTextDocument':\n return { kind: 'showTextDocument' };\n case 'setSelections': {\n const selections = Array.isArray(parsed.selections) ? parsed.selections : [];\n const norm = selections.map((s) => ({\n start: Array.isArray(s?.start) && s.start.length === 2 ? [Number(s.start[0]) || 0, Number(s.start[1]) || 0] : [0, 0],\n end: Array.isArray(s?.end) && s.end.length === 2 ? [Number(s.end[0]) || 0, Number(s.end[1]) || 0] : [0, 0]\n }));\n return { kind: 'setSelections', selections: norm };\n }\n case 'editInsert': {\n const pos = Array.isArray(parsed.position) && parsed.position.length === 2 ? [Number(parsed.position[0]) || 0, Number(parsed.position[1]) || 0] : [0, 0];\n const textVal = typeof parsed.text === 'string' ? parsed.text : '';\n return { kind: 'editInsert', position: pos, text: textVal };\n }\n case 'editDelete': {\n const start = Array.isArray(parsed.range?.start) && parsed.range.start.length === 2 ? [Number(parsed.range.start[0]) || 0, Number(parsed.range.start[1]) || 0] : [0, 0];\n const end = Array.isArray(parsed.range?.end) && parsed.range.end.length === 2 ? [Number(parsed.range.end[0]) || 0, Number(parsed.range.end[1]) || 0] : [0, 0];\n return { kind: 'editDelete', range: { start, end } };\n }\n case 'editReplace': {\n const start = Array.isArray(parsed.range?.start) && parsed.range.start.length === 2 ? [Number(parsed.range.start[0]) || 0, Number(parsed.range.start[1]) || 0] : [0, 0];\n const end = Array.isArray(parsed.range?.end) && parsed.range.end.length === 2 ? [Number(parsed.range.end[0]) || 0, Number(parsed.range.end[1]) || 0] : [0, 0];\n const textVal = typeof parsed.text === 'string' ? parsed.text : '';\n return { kind: 'editReplace', range: { start, end }, text: textVal };\n }\n case 'terminalShow':\n return { kind: 'terminalShow' };\n case 'terminalSendText': {\n const textVal = typeof parsed.text === 'string' ? parsed.text : '';\n return { kind: 'terminalSendText', text: textVal };\n }\n default:\n return undefined;\n }\n}\n//# sourceMappingURL=extension.js.map",javascript,tab
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-69b3ec1c-9de9-4a08-b72c-2106545215f31759658466061-2025_10_05-12.01.13.925/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-70e1b9a4-9447-4be7-85f9-ea3b825230fe1765227767400-2025_12_08-22.02.58.450/source.csv
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
2,558,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"10:02:58 PM [info] Activating crowd-code\n10:02:58 PM [info] Recording started\n10:02:58 PM [info] Initializing git provider using file system watchers...\n10:02:58 PM [info] No workspace folder found\n",Log,tab
|
| 3 |
+
3,2279,"extension-output-pdoom-org.crowd-code-#1-crowd-code",198,0,"10:03:00 PM [info] Retrying git provider initialization...\n10:03:00 PM [info] No workspace folder found\n",Log,content
|
| 4 |
+
4,419530,"Untitled-1",0,0,"",plaintext,tab
|
| 5 |
+
5,424918,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",0,0,"#!/usr/bin/env python3\nimport sys\nfrom pathlib import Path\nimport pandas as pd\n\ninput_dir = sys.argv[1]\nfor parquet_file in sorted(Path(input_dir).glob(""shard_*.parquet"")):\n df = pd.read_parquet(parquet_file)\n for text in df['text']:\n print(text)\n",python,tab
|
| 6 |
+
6,426336,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",260,0,"\n",python,content
|
| 7 |
+
7,452818,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",104,0,"import os\\nif not os.path.exists(input_dir):\\n print(f""Error: Input directory {input_dir} does not exist."")\\n sys.exit(1)\n",python,content
|
| 8 |
+
8,467833,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",388,0,"",python,selection_command
|
| 9 |
+
9,467989,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",368,0,"",python,selection_command
|
| 10 |
+
10,468134,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",340,0,"",python,selection_command
|
| 11 |
+
11,468281,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",301,0,"",python,selection_command
|
| 12 |
+
12,468429,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",232,0,"",python,selection_command
|
| 13 |
+
13,468617,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",216,0,"",python,selection_command
|
| 14 |
+
14,469181,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",216,15," sys.exit(1)",python,selection_command
|
| 15 |
+
15,469520,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",150,81," print(f""Error: Input directory {input_dir} does not exist."")\\n sys.exit(1)",python,selection_command
|
| 16 |
+
16,469692,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",115,116,"if not os.path.exists(input_dir):\\n print(f""Error: Input directory {input_dir} does not exist."")\\n sys.exit(1)",python,selection_command
|
| 17 |
+
17,469885,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",115,117,"",python,content
|
| 18 |
+
18,471492,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",104,0,"",python,selection_command
|
| 19 |
+
19,471841,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",104,11,"",python,content
|
| 20 |
+
20,472894,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",173,0,"",python,selection_command
|
| 21 |
+
21,473130,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",212,0,"",python,selection_command
|
| 22 |
+
22,473169,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",240,0,"",python,selection_command
|
| 23 |
+
23,473198,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",260,0,"",python,selection_command
|
| 24 |
+
24,473228,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",261,0,"",python,selection_command
|
| 25 |
+
25,476710,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",261,0,"d",python,content
|
| 26 |
+
26,476712,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",262,0,"",python,selection_keyboard
|
| 27 |
+
27,476815,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",262,0,"e",python,content
|
| 28 |
+
28,476818,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",263,0,"",python,selection_keyboard
|
| 29 |
+
29,477038,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",263,0,"f",python,content
|
| 30 |
+
30,477041,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",264,0,"",python,selection_keyboard
|
| 31 |
+
31,477144,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",264,0," ",python,content
|
| 32 |
+
32,477147,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",265,0,"",python,selection_keyboard
|
| 33 |
+
33,478878,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",264,1,"",python,content
|
| 34 |
+
34,479049,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",263,1,"",python,content
|
| 35 |
+
35,479205,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",262,1,"",python,content
|
| 36 |
+
36,479362,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",261,1,"",python,content
|
| 37 |
+
37,481961,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",261,0,"i",python,content
|
| 38 |
+
38,481963,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",262,0,"",python,selection_keyboard
|
| 39 |
+
39,482194,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",262,0,"f",python,content
|
| 40 |
+
40,482196,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",263,0,"",python,selection_keyboard
|
| 41 |
+
41,482236,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",263,0," ",python,content
|
| 42 |
+
42,482239,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",264,0,"",python,selection_keyboard
|
| 43 |
+
43,484322,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",264,0,"_",python,content
|
| 44 |
+
44,484325,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",265,0,"",python,selection_keyboard
|
| 45 |
+
45,484478,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",265,0,"_",python,content
|
| 46 |
+
46,484481,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",266,0,"",python,selection_keyboard
|
| 47 |
+
47,484810,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",266,0,"n",python,content
|
| 48 |
+
48,484813,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",267,0,"",python,selection_keyboard
|
| 49 |
+
49,484990,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",267,0,"a",python,content
|
| 50 |
+
50,484992,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",268,0,"",python,selection_keyboard
|
| 51 |
+
51,485114,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",268,0,"m",python,content
|
| 52 |
+
52,485116,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",269,0,"",python,selection_keyboard
|
| 53 |
+
53,485307,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",269,0,"e",python,content
|
| 54 |
+
54,485309,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",270,0,"",python,selection_keyboard
|
| 55 |
+
55,485725,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",270,0,"_",python,content
|
| 56 |
+
56,485728,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",271,0,"",python,selection_keyboard
|
| 57 |
+
57,485948,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",271,0,"_",python,content
|
| 58 |
+
58,485950,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",272,0,"",python,selection_keyboard
|
| 59 |
+
59,486643,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",272,0," ",python,content
|
| 60 |
+
60,486645,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",273,0,"",python,selection_keyboard
|
| 61 |
+
61,487699,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",273,0,"=",python,content
|
| 62 |
+
62,487702,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",274,0,"",python,selection_keyboard
|
| 63 |
+
63,487757,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",274,0,"=",python,content
|
| 64 |
+
64,487760,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",275,0,"",python,selection_keyboard
|
| 65 |
+
65,488589,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",275,0," ",python,content
|
| 66 |
+
66,488590,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",276,0,"",python,selection_keyboard
|
| 67 |
+
67,499039,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",261,15,"if __name__ == ""main"":\n",python,content
|
| 68 |
+
68,500269,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",261,0,"",python,selection_command
|
| 69 |
+
69,502924,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",262,0,"",python,selection_command
|
| 70 |
+
70,503166,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",263,0,"",python,selection_command
|
| 71 |
+
71,503200,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",264,0,"",python,selection_command
|
| 72 |
+
72,503237,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",265,0,"",python,selection_command
|
| 73 |
+
73,503268,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",266,0,"",python,selection_command
|
| 74 |
+
74,503296,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",267,0,"",python,selection_command
|
| 75 |
+
75,503328,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",268,0,"",python,selection_command
|
| 76 |
+
76,503362,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",269,0,"",python,selection_command
|
| 77 |
+
77,503396,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",270,0,"",python,selection_command
|
| 78 |
+
78,503431,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",271,0,"",python,selection_command
|
| 79 |
+
79,503465,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",272,0,"",python,selection_command
|
| 80 |
+
80,503498,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",273,0,"",python,selection_command
|
| 81 |
+
81,503544,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",274,0,"",python,selection_command
|
| 82 |
+
82,503571,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",275,0,"",python,selection_command
|
| 83 |
+
83,503605,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",276,0,"",python,selection_command
|
| 84 |
+
84,503777,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",277,0,"",python,selection_command
|
| 85 |
+
85,504312,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",277,0,"_",python,content
|
| 86 |
+
86,504314,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",278,0,"",python,selection_keyboard
|
| 87 |
+
87,504395,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",278,0,"_",python,content
|
| 88 |
+
88,504397,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",279,0,"",python,selection_keyboard
|
| 89 |
+
89,514849,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",278,0,"",python,selection_command
|
| 90 |
+
90,515894,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",279,0,"",python,selection_command
|
| 91 |
+
91,516074,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",280,0,"",python,selection_command
|
| 92 |
+
92,516350,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",281,0,"",python,selection_command
|
| 93 |
+
93,516729,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",282,0,"",python,selection_command
|
| 94 |
+
94,517069,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",283,0,"",python,selection_command
|
| 95 |
+
95,518545,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",283,0,"_",python,content
|
| 96 |
+
96,518547,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",284,0,"",python,selection_keyboard
|
| 97 |
+
97,527009,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",261,26,"if __name__ == ""__main__"":\n",python,content
|
| 98 |
+
98,529298,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",288,0,"",python,selection_command
|
| 99 |
+
99,552760,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",104,157,"",python,content
|
| 100 |
+
100,557923,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",131,0," for parquet_file in sorted(Path(input_dir).glob(""shard_*.parquet"")):\n df = pd.read_parquet(parquet_file)\n for text in df['text']:\n print(text)\n",python,content
|
| 101 |
+
101,579554,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",131,0,"",python,selection_command
|
| 102 |
+
102,581067,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",131,174," for parquet_file in sorted(Path(input_dir).glob(""shard_*.parquet"")):\n df = pd.read_parquet(parquet_file)\n for text in df['text']:\n print(text)",python,selection_command
|
| 103 |
+
103,581640,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",131,0,"",python,selection_command
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-76eea157-7b6f-494c-8c5d-4a51e6e2b49d1759266847108-2025_09_30-23.14.13.32/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-7bb39648-a065-4847-8b07-5024f699fc131758998987531-2025_09_27-20.49.55.850/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-81c2c0be-5633-4bef-b439-115d6aef8f341763318955037-2025_11_16-19.49.31.87/source.csv
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
1,3,"crowd-pilot/crowd-pilot/serialization_utils.py",0,0,"#!/usr/bin/env python3\n""""""\nCommon utilities for dataset serialization scripts.\n""""""\n\nfrom __future__ import annotations\n\nfrom dataclasses import dataclass\nfrom pathlib import Path\nfrom typing import List, Optional, Tuple, Dict\n\nimport difflib\nimport re\nimport pandas as pd\nfrom datasets import Dataset, load_dataset\n\n\n_ANSI_CSI_RE = re.compile(r""\x1b\[[0-9;?]*[ -/]*[@-~]"")\n_ANSI_OSC_TERMINATED_RE = re.compile(r""\x1b\][\s\S]*?(?:\x07|\x1b\\)"")\n_ANSI_OSC_LINE_FALLBACK_RE = re.compile(r""\x1b\][^\n]*$"")\n_BRACKETED_PASTE_ENABLE = ""\x1b[?2004h""\n_BRACKETED_PASTE_DISABLE = ""\x1b[?2004l""\n_OSC_633 = ""\x1b]633;""\n_OSC_0 = ""\x1b]0;""\n\n\n@dataclass\nclass SerializeConfig:\n output_dir: str\n shard_size: int\n target_chars: int\n overlap_chars: int\n min_session_chars: int\n max_docs: Optional[int]\n long_pause_threshold_ms: int\n csv_root: Optional[str]\n val_ratio: float\n arrayrecord_group_size: Optional[int] = None\n\n\ndef _clean_text(text: str) -> str:\n # Normalize line endings and strip trailing spaces; preserve tabs/newlines.\n return text.replace(""\r\n"", ""\n"").replace(""\r"", ""\n"").rstrip()\n\n\ndef _fenced_block(path: str, language: Optional[str], content: str) -> str:\n lang = (language or """").lower()\n return f""```{lang}\n{content}\n```\n""\n\n\ndef _apply_change(content: str, offset: int, length: int, new_text: str) -> str:\n # Mirrors crowd_code_player.replay_file.apply_change\n base = str(content)\n text = str(new_text) if pd.notna(new_text) else """"\n text = text.replace(""\\n"", ""\n"").replace(""\\r"", ""\r"")\n if offset > len(base):\n base = base + ("" "" * (offset - len(base)))\n return base[:offset] + text + base[offset + length:]\n\n\ndef _apply_backspaces(text: str) -> str:\n out: List[str] = []\n for ch in text:\n if ch == ""\b"": # \x08\n if out:\n out.pop()\n else:\n out.append(ch)\n return """".join(out)\n\n\ndef _normalize_terminal_output(raw: str) -> str:\n """"""\n Normalize PTY/terminal output for training:\n - Apply backspaces (\x08)\n - Strip OSC (window title/shell integration) first, keeping BEL/ST terminators intact\n - Resolve carriage returns (\r) by keeping the last rewrite per line\n - Strip CSI (coloring etc.)\n - Finally drop any remaining BEL (\x07)\n """"""\n if not raw:\n return raw\n s = _apply_backspaces(raw)\n # Remove OSC sequences that are properly terminated (BEL or ST)\n s = _ANSI_OSC_TERMINATED_RE.sub("""", s)\n # Fallback: drop any unterminated OSC up to end-of-line only\n s = ""\n"".join(_ANSI_OSC_LINE_FALLBACK_RE.sub("""", line) for line in s.split(""\n""))\n # Resolve carriage returns per line:\n # - If there are multiple rewrites, keep the last non-empty chunk\n # - If it's CRLF (ending with '\r' before '\n'), keep the content before '\r'\n resolved_lines: List[str] = []\n for seg in s.split(""\n""):\n parts = seg.split(""\r"")\n chosen = """"\n # pick last non-empty part if available; else last part\n for p in reversed(parts):\n if p != """":\n chosen = p\n break\n if chosen == """" and parts:\n chosen = parts[-1]\n resolved_lines.append(chosen)\n s = ""\n"".join(resolved_lines)\n # Strip ANSI escape sequences\n s = _ANSI_CSI_RE.sub("""", s)\n # Remove any remaining BEL beeps\n s = s.replace(""\x07"", """")\n return s\n\n\ndef _line_numbered_output(content: str, start_line: Optional[int] = None, end_line: Optional[int] = None) -> str:\n # FIXME (f.srambical): check whether this corresponds **exactly** to the output of cat -n {file_path} | sed -n '{vstart},{vend}p'\n lines = content.splitlines()\n total = len(lines)\n if total == 0:\n return """"\n s = 1 if start_line is None else max(1, min(start_line, total))\n e = total if end_line is None else max(1, min(end_line, total))\n assert e >= s, ""End line number cannot be less than start line number! Likely a bug in the line numbering computation.""\n buf: List[str] = []\n for idx in range(s, e + 1):\n buf.append(f""{idx:6}\t{lines[idx - 1]}"")\n return ""\n"".join(buf)\n\n\ndef _compute_viewport(total_lines: int, center_line: int, radius: int) -> Tuple[int, int]:\n if total_lines <= 0:\n return (1, 0)\n start = max(1, center_line - radius)\n end = min(total_lines, center_line + radius)\n assert end >= start, ""Viewport cannot have negative width! Likely a bug in the viewport computation.""\n return (start, end)\n\n\ndef _escape_single_quotes_for_sed(text: str) -> str:\n # Close quote, add an escaped single quote, reopen quote: '""'""'\n return text.replace(""'"", ""'\""'\""'"")\n\n\ndef _compute_changed_block_lines(\n before: str, after: str\n) -> Tuple[int, int, int, int, List[str]]:\n """"""\n Return 1-based start and end line numbers in 'before' that should be\n replaced, 1-based start and end line numbers in 'after' that contain\n the replacement, and the replacement lines from 'after'.\n\n For pure deletions, the replacement list may be empty.\n """"""\n before_lines = before.splitlines()\n after_lines = after.splitlines()\n sm = difflib.SequenceMatcher(a=before_lines, b=after_lines, autojunk=False)\n opcodes = [op for op in sm.get_opcodes() if op[0] != ""equal""]\n assert opcodes, ""Opcode list cannot be empty! Likely a bug in the diff computation.""\n\n first = opcodes[0]\n last = opcodes[-1]\n # i1/i2 refer to 'before' indices, j1/j2 to 'after'\n start_before = max(1, first[1] + 1)\n end_before = last[2] # no increment since we go from 'exclusive' to 'inclusive' indexing\n start_after = max(1, first[3] + 1)\n end_after = last[4]\n replacement_lines = after_lines[first[3] : last[4]]\n return (start_before, end_before, start_after, end_after, replacement_lines)\n\n\ndef _session_to_transcript(\n df: pd.DataFrame,\n long_pause_threshold_ms: int,\n) -> str:\n\n file_states: Dict[str, str] = {}\n terminal_state: str = """"\n per_file_event_counts: Dict[str, int] = {}\n per_file_cursor_positions: Dict[str, Tuple[int, int]] = {} # (offset, length) for each file\n last_time_ms: Optional[int] = None\n\n parts: List[str] = []\n\n for i in range(len(df)):\n row = df.iloc[i]\n file_path: str = row[""File""]\n event_time: int = row[""Time""]\n language: Optional[str] = row[""Language""]\n\n # Long pause detection\n if last_time_ms is not None:\n delta = event_time - last_time_ms\n if delta > long_pause_threshold_ms:\n # TODO (f.srambical): think about whether we want to emit this as an observation or not\n parts.append(f""<obs long_pause ms=\""{delta}\"" />"")\n last_time_ms = event_time\n\n event_type = row[""Type""]\n\n match event_type:\n case ""tab"":\n # File switch event\n parts.append(f""<act focus file=\""{file_path}\"" />"")\n \n # If Text is present, this is the first time opening the file\n # and the entire file content is captured\n text = row[""Text""]\n if pd.notna(text):\n file_content = str(text).replace(""\\n"", ""\n"").replace(""\\r"", ""\r"")\n file_states[file_path] = file_content\n parts.append(f""// observation: file={file_path}"")\n parts.append(_fenced_block(file_path, language, _clean_text(file_content)))\n\n case ""terminal_command"":\n # Terminal command execution\n command = row[""Text""]\n command_str = str(command).replace(""\\n"", ""\n"").replace(""\\r"", ""\r"")\n parts.append(f""<act terminal_command />"")\n parts.append(_fenced_block(file_path, ""bash"", _clean_text(command_str)))\n\n case ""terminal_output"":\n # Terminal output capture\n output = row[""Text""]\n output_str = str(output).replace(""\\n"", ""\n"").replace(""\\r"", ""\r"")\n parts.append(f""<obs terminal_output />"")\n parts.append(_fenced_block(file_path, None, _clean_text(output_str)))\n\n case ""terminal_focus"":\n # Terminal focus event\n parts.append(f""<act focus target=\""terminal\"" />"")\n\n case ""git_branch_checkout"":\n # Git branch checkout event\n branch_info = row[""Text""]\n branch_str = str(branch_info).replace(""\\n"", ""\n"").replace(""\\r"", ""\r"")\n parts.append(f""<act git_branch_checkout />"")\n parts.append(f""// git: {_clean_text(branch_str)}"")\n\n case ""selection_command"" | ""selection_mouse"" | ""selection_keyboard"":\n # Handle cursor movement\n offset = row[""RangeOffset""]\n length = row[""RangeLength""]\n old_cursor = per_file_cursor_positions.get(file_path, (0, 0))\n new_cursor = (offset, length)\n per_file_cursor_positions[file_path] = new_cursor\n \n # Emit cursor movement observation if position changed\n if old_cursor != new_cursor:\n parts.append(f""<act cursor file=\""{file_path}\"" offset=\""{offset}\"" len=\""{length}\"" />"")\n\n case ""content"":\n # Handle file edit events\n offset = row[""RangeOffset""]\n length = row[""RangeLength""]\n new_text = row[""Text""]\n new_text_str = str(new_text) if pd.notna(new_text) else """"\n\n operation = ""noop""\n if length == 0 and new_text_str:\n operation = ""insert""\n elif length > 0 and not new_text_str:\n operation = ""delete""\n elif length > 0 and new_text_str:\n operation = ""replace""\n\n parts.append(f""<act {operation} file=\""{file_path}\"" offset=\""{offset}\"" len=\""{length}\"" />"")\n\n if new_text_str and (operation == ""insert"" or operation == ""replace""):\n parts.append(_fenced_block(file_path, language, _clean_text(new_text_str)))\n\n before = file_states.get(file_path, """")\n after = _apply_change(before, offset, length, new_text)\n file_states[file_path] = after\n per_file_event_counts[file_path] = per_file_event_counts.get(file_path, 0) + 1\n\n # Update cursor position after edit (cursor moves to end of inserted/replaced text)\n per_file_cursor_positions[file_path] = (offset + len(new_text_str), 0)\n\n case _:\n raise ValueError(f""Unknown event type: {event_type}"")\n\n return ""\n"".join(parts).strip()\n\n\ndef session_to_bash_formatted_transcript(\n df: pd.DataFrame,\n viewport_radius: int = 10,\n normalize_terminal_output: bool = True,\n coalesce_radius: int = 5,\n) -> str:\n r""""""\n Serialize a session to a bash-like transcript comprised of:\n - Commands (bash fenced blocks): cat -n, sed -i 'S,Ec\...' && cat -n | sed -n 'VSTART,VENDp'\n - Outputs (<stdout>...</stdout>) that reflect the file state after each action\n Tracks per-file state and a per-file viewport. Viewport only shifts when selection moves out of bounds\n or when first initialized.\n """"""\n file_states: Dict[str, str] = {}\n per_file_viewport: Dict[str, Optional[Tuple[int, int]]] = {}\n\n parts: List[str] = []\n terminal_output_buffer: List[str] = []\n pending_edits_before: Dict[str, Optional[str]] = {}\n pending_edit_regions: Dict[str, Optional[Tuple[int, int]]] = {}\n\n def _flush_terminal_output_buffer() -> None:\n if not terminal_output_buffer:\n return\n aggregated = """".join(terminal_output_buffer)\n out = aggregated\n if normalize_terminal_output:\n out = _normalize_terminal_output(out)\n cleaned = _clean_text(out)\n if cleaned.strip():\n parts.append(f""<stdout>\n{cleaned}\n</stdout>"")\n terminal_output_buffer.clear()\n\n def _flush_pending_edit_for_file(target_file: str) -> None:\n before_snapshot = pending_edits_before.get(target_file)\n if before_snapshot is None:\n return\n after_state = file_states.get(target_file, """")\n if before_snapshot.rstrip(""\n"") == after_state.rstrip(""\n""):\n pending_edits_before[target_file] = None\n pending_edit_regions[target_file] = None\n return\n (\n start_before,\n end_before,\n start_after,\n end_after,\n repl_lines,\n ) = _compute_changed_block_lines(before_snapshot, after_state)\n before_total_lines = len(before_snapshot.splitlines())\n if end_before < start_before:\n escaped_lines = [_escape_single_quotes_for_sed(line) for line in repl_lines]\n sed_payload = ""\n"".join(escaped_lines)\n if start_before <= max(1, before_total_lines):\n sed_cmd = f""sed -i '{start_before}i\\\n{sed_payload}' {target_file}""\n else:\n sed_cmd = f""sed -i '$a\\\n{sed_payload}' {target_file}""\n elif not repl_lines:\n sed_cmd = f""sed -i '{start_before},{end_before}d' {target_file}""\n else:\n escaped_lines = [_escape_single_quotes_for_sed(line) for line in repl_lines]\n sed_payload = ""\n"".join(escaped_lines)\n sed_cmd = f""sed -i '{start_before},{end_before}c\\\n{sed_payload}' {target_file}""\n total_lines = len(after_state.splitlines())\n center = (start_after + end_after) // 2\n vp = _compute_viewport(total_lines, center, viewport_radius)\n per_file_viewport[target_file] = vp\n vstart, vend = vp\n chained_cmd = f""{sed_cmd} && cat -n {target_file} | sed -n '{vstart},{vend}p'""\n parts.append(_fenced_block(target_file, ""bash"", _clean_text(chained_cmd)))\n viewport_output = _line_numbered_output(after_state, vstart, vend)\n parts.append(f""<stdout>\n{viewport_output}\n</stdout>"")\n pending_edits_before[target_file] = None\n pending_edit_regions[target_file] = None\n\n def _flush_all_pending_edits() -> None:\n for fname in list(pending_edits_before.keys()):\n _flush_pending_edit_for_file(fname)\n\n for i in range(len(df)):\n row = df.iloc[i]\n file_path: str = row[""File""]\n event_type = row[""Type""]\n \n match event_type:\n case ""tab"":\n _flush_all_pending_edits()\n _flush_terminal_output_buffer()\n text = row[""Text""]\n if pd.notna(text):\n content = str(text).replace(""\\n"", ""\n"").replace(""\\r"", ""\r"")\n file_states[file_path] = content\n # First open with full file capture\n cmd = f""cat -n {file_path}""\n parts.append(_fenced_block(file_path, ""bash"", _clean_text(cmd)))\n output = _line_numbered_output(content)\n parts.append(f""<stdout>\n{output}\n</stdout>"")\n else:\n # File switch without content snapshot: show current viewport only\n content = file_states.get(file_path, """")\n total_lines = len(content.splitlines())\n vp = per_file_viewport.get(file_path)\n if not vp or vp[1] == 0:\n vp = _compute_viewport(total_lines, 1, viewport_radius)\n per_file_viewport[file_path] = vp\n if vp:\n vstart, vend = vp\n cmd = f""cat -n {file_path} | sed -n '{vstart},{vend}p'""\n parts.append(_fenced_block(file_path, ""bash"", _clean_text(cmd)))\n viewport_output = _line_numbered_output(content, vstart, vend)\n parts.append(f""<stdout>\n{viewport_output}\n</stdout>"")\n\n case ""content"":\n _flush_terminal_output_buffer()\n offset = int(row[""RangeOffset""])\n length = int(row[""RangeLength""])\n new_text = row[""Text""]\n before = file_states.get(file_path, """")\n # Approximate current edit region in line space\n new_text_str = str(new_text) if pd.notna(new_text) else """"\n start_line_current = before[:offset].count(""\n"") + 1\n deleted_chunk = before[offset:offset + length]\n lines_added = new_text_str.count(""\n"")\n lines_deleted = deleted_chunk.count(""\n"")\n region_start = start_line_current\n region_end = start_line_current + max(lines_added, lines_deleted, 0)\n # Flush pending edits if this edit is far from the pending region\n current_region = pending_edit_regions.get(file_path)\n if current_region is not None:\n rstart, rend = current_region\n if region_start < (rstart - coalesce_radius) or region_start > (rend + coalesce_radius):\n _flush_pending_edit_for_file(file_path)\n current_region = None\n after = _apply_change(before, offset, length, new_text)\n if pending_edits_before.get(file_path) is None:\n pending_edits_before[file_path] = before\n # Update/initialize region union\n if current_region is None:\n pending_edit_regions[file_path] = (region_start, max(region_start, region_end))\n else:\n rstart, rend = current_region\n pending_edit_regions[file_path] = (min(rstart, region_start), max(rend, region_end))\n file_states[file_path] = after\n\n case ""selection_command"" | ""selection_mouse"" | ""selection_keyboard"":\n # During an edit burst (pending edits), suppress flush and viewport emissions\n if pending_edits_before.get(file_path) is None:\n _flush_terminal_output_buffer()\n else:\n # Skip emitting viewport while edits are pending to avoid per-keystroke sed/cat spam\n continue\n offset = int(row[""RangeOffset""])\n content = file_states.get(file_path, """")\n total_lines = len(content.splitlines())\n target_line = content[:offset].count(""\n"") + 1\n vp = per_file_viewport.get(file_path)\n should_emit = False\n if not vp or vp[1] == 0:\n vp = _compute_viewport(total_lines, target_line, viewport_radius)\n per_file_viewport[file_path] = vp\n should_emit = True\n else:\n vstart, vend = vp\n if target_line < vstart or target_line > vend:\n vp = _compute_viewport(total_lines, target_line, viewport_radius)\n per_file_viewport[file_path] = vp\n should_emit = True\n if should_emit and vp:\n vstart, vend = vp\n cmd = f""cat -n {file_path} | sed -n '{vstart},{vend}p'""\n parts.append(_fenced_block(file_path, ""bash"", _clean_text(cmd)))\n viewport_output = _line_numbered_output(content, vstart, vend)\n parts.append(f""<stdout>\n{viewport_output}\n</stdout>"")\n\n case ""terminal_command"":\n _flush_all_pending_edits()\n _flush_terminal_output_buffer()\n command = row[""Text""]\n command_str = str(command).replace(""\\n"", ""\n"").replace(""\\r"", ""\r"")\n parts.append(_fenced_block(file_path, ""bash"", _clean_text(command_str)))\n\n case ""terminal_output"":\n output = row[""Text""]\n raw_output = str(output).replace(""\\n"", ""\n"").replace(""\\r"", ""\r"")\n terminal_output_buffer.append(raw_output)\n\n case ""terminal_focus"":\n _flush_all_pending_edits()\n _flush_terminal_output_buffer()\n # No-op for bash transcript; focus changes don't emit commands/output\n pass\n\n case ""git_branch_checkout"":\n _flush_all_pending_edits()\n _flush_terminal_output_buffer()\n branch_info = row[""Text""]\n branch_str = str(branch_info).replace(""\\n"", ""\n"").replace(""\\r"", ""\r"")\n cleaned = _clean_text(branch_str)\n m = re.search(r""to '([^']+)'"", cleaned)\n if not m:\n raise ValueError(f""Could not extract branch name from git checkout message: {cleaned}"")\n branch_name = m.group(1).strip()\n # Safe-quote branch if it contains special characters\n if re.search(r""[^A-Za-z0-9._/\\-]"", branch_name):\n branch_name = ""'"" + branch_name.replace(""'"", ""'\""'\""'"") + ""'""\n cmd = f""git checkout {branch_name}""\n parts.append(_fenced_block(file_path, ""bash"", _clean_text(cmd)))\n\n case _:\n raise ValueError(f""Unknown event type: {event_type}"")\n\n _flush_all_pending_edits()\n _flush_terminal_output_buffer()\n return ""\n"".join(parts).strip()\n\ndef load_hf_csv(hf_path: str, split: str) -> Dataset:\n loaded = load_dataset(hf_path, split=split)\n\n assert isinstance(loaded, Dataset), ""Expected a Dataset from load_dataset""\n return loaded\n\n\ndef _discover_local_sessions(root: Path) -> List[Path]:\n # Recursively find all CSV files\n paths: List[Path] = []\n for p in root.rglob(""*.csv""):\n if p.is_file():\n paths.append(p)\n paths.sort()\n return paths\n\n\ndef _chunk_text(text: str, target_chars: int, overlap_chars: int) -> List[str]:\n """"""Split a long text into overlapping chunks near target length.""""""\n if target_chars <= 0:\n return [text]\n n = len(text)\n if n <= target_chars:\n return [text]\n\n chunks: List[str] = []\n start = 0\n # Ensure sane overlap\n overlap = max(0, min(overlap_chars, target_chars // 2))\n while start < n:\n end_target = min(start + target_chars, n)\n if end_target < n:\n end = end_target\n else:\n end = n\n chunk = text[start:end].strip()\n chunks.append(chunk)\n if end == n:\n break\n # advance with overlap\n start = max(0, end - overlap)\n if start >= n:\n break\n return chunks\n\n\n",python,tab
|
| 3 |
+
2,1748,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"7:49:31 PM [info] Activating crowd-code\n7:49:31 PM [info] Recording started\n7:49:31 PM [info] Initializing git provider using file system watchers...\n7:49:32 PM [info] Git repository found\n",Log,tab
|
| 4 |
+
3,1981,"extension-output-pdoom-org.crowd-code-#1-crowd-code",189,0,"7:49:32 PM [info] Git provider initialized successfully\n7:49:32 PM [info] Initial git state: [object Object]\n",Log,content
|
| 5 |
+
4,163843,"crowd-pilot/crowd-pilot/serialization_utils.py",0,0,"",python,tab
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-89e32a43-dc9e-46d6-874e-f60a6cb0b3071767607509804-2026_01_05-11.05.16.288/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-8c6fe2f6-5c87-474b-8190-b29853bcc7151755414648501-2025_08_17-09.10.53.985/source.csv
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
1,2,"big_vision/train.py",0,0,"# Copyright 2024 Big Vision Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the ""License"");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an ""AS IS"" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n""""""Training loop example.\n\nThis is a basic variant of a training loop, good starting point for fancy ones.\n""""""\n# pylint: disable=consider-using-from-import\n# pylint: disable=logging-fstring-interpolation\n\nimport functools\nimport importlib\nimport multiprocessing.pool\nimport os\n\nfrom absl import app\nfrom absl import flags\nfrom absl import logging\nimport big_vision.evaluators.common as eval_common\nimport big_vision.input_pipeline as input_pipeline\nimport big_vision.optax as bv_optax\nimport big_vision.sharding as bv_sharding\nimport big_vision.utils as u\nfrom clu import parameter_overview\nimport flax.linen as nn\nimport jax\nfrom jax.experimental import multihost_utils\nfrom jax.experimental.array_serialization import serialization as array_serial\nfrom jax.experimental.shard_map import shard_map\nimport jax.numpy as jnp\nfrom ml_collections import config_flags\nimport numpy as np\nimport optax\nimport tensorflow as tf\n\nfrom tensorflow.io import gfile\n\n\nconfig_flags.DEFINE_config_file(\n ""config"", None, ""Training configuration."", lock_config=True)\n\nflags.DEFINE_string(""workdir"", default=None, help=""Work unit directory."")\nflags.DEFINE_boolean(""cleanup"", default=False,\n help=""Delete workdir (only) after successful completion."")\n\n# Adds jax flags to the program.\njax.config.parse_flags_with_absl()\n# Transfer guard will fail the program whenever that data between a host and\n# a device is transferred implicitly. This often catches subtle bugs that\n# cause slowdowns and memory fragmentation. Explicit transfers are done\n# with jax.device_put and jax.device_get.\njax.config.update(""jax_transfer_guard"", ""disallow"")\n# Fixes design flaw in jax.random that may cause unnecessary d2d comms.\njax.config.update(""jax_threefry_partitionable"", True)\n\n\nNamedSharding = jax.sharding.NamedSharding\nP = jax.sharding.PartitionSpec\n\n\ndef main(argv):\n del argv\n\n # This is needed on multihost systems, but crashes on non-TPU single-host.\n if os.environ.get(""BV_JAX_INIT""):\n jax.distributed.initialize()\n\n # Make sure TF does not touch GPUs.\n tf.config.set_visible_devices([], ""GPU"")\n\n config = flags.FLAGS.config\n\n################################################################################\n# #\n# Set up logging #\n# #\n################################################################################\n\n # Set up work directory and print welcome message.\n workdir = flags.FLAGS.workdir\n logging.info(\n f""\u001b[33mHello from process {jax.process_index()} holding ""\n f""{jax.local_device_count()}/{jax.device_count()} devices and ""\n f""writing to workdir {workdir}.\u001b[0m"")\n logging.info(f""The config:\n{config}"")\n\n save_ckpt_path = None\n if workdir: # Always create if requested, even if we may not write into it.\n gfile.makedirs(workdir)\n save_ckpt_path = os.path.join(workdir, ""checkpoint.bv"")\n\n # The pool is used to perform misc operations such as logging in async way.\n pool = multiprocessing.pool.ThreadPool(1)\n\n # Here we register preprocessing ops from modules listed on `pp_modules`.\n for m in config.get(""pp_modules"", [""ops_general"", ""ops_image"", ""ops_text""]):\n importlib.import_module(f""big_vision.pp.{m}"")\n\n # Setup up logging and experiment manager.\n xid, wid = -1, -1\n fillin = lambda s: s\n def info(s, *a):\n logging.info(""\u001b[33mNOTE\u001b[0m: "" + s, *a)\n def write_note(note):\n if jax.process_index() == 0:\n info(""%s"", note)\n\n mw = u.BigVisionMetricWriter(xid, wid, workdir, config)\n\n # Allow for things like timings as early as possible!\n u.chrono.inform(measure=mw.measure, write_note=write_note)\n\n################################################################################\n# #\n# Set up Mesh #\n# #\n################################################################################\n\n # We rely on jax mesh_utils to organize devices, such that communication\n # speed is the fastest for the last dimension, second fastest for the\n # penultimate dimension, etc.\n config_mesh = config.get(""mesh"", [(""data"", jax.device_count())])\n\n # Sharding rules with default\n sharding_rules = config.get(""sharding_rules"", [(""act_batch"", ""data"")])\n\n write_note(""Creating device mesh..."")\n mesh = u.create_device_mesh(\n config_mesh,\n allow_split_physical_axes=config.get(""mesh_allow_split_physical_axes"",\n False))\n repl_sharding = jax.sharding.NamedSharding(mesh, P())\n\n # Consistent device order is important to ensure correctness of various train\n # loop components, such as input pipeline, update step, evaluators. The\n # order presribed by the `devices_flat` variable should be used throughout\n # the program.\n devices_flat = mesh.devices.flatten()\n\n################################################################################\n# #\n# Input Pipeline #\n# #\n################################################################################\n\n write_note(""Initializing train dataset..."")\n batch_size = config.input.batch_size\n if batch_size % jax.device_count() != 0:\n raise ValueError(f""Batch size ({batch_size}) must ""\n f""be divisible by device number ({jax.device_count()})"")\n info(""Global batch size %d on %d hosts results in %d local batch size. With ""\n ""%d dev per host (%d dev total), that's a %d per-device batch size."",\n batch_size, jax.process_count(), batch_size // jax.process_count(),\n jax.local_device_count(), jax.device_count(),\n batch_size // jax.device_count())\n\n train_ds, ntrain_img = input_pipeline.training(config.input)\n\n total_steps = u.steps(""total"", config, ntrain_img, batch_size)\n def get_steps(name, default=ValueError, cfg=config):\n return u.steps(name, cfg, ntrain_img, batch_size, total_steps, default)\n\n u.chrono.inform(total_steps=total_steps, global_bs=batch_size,\n steps_per_epoch=ntrain_img / batch_size)\n\n info(""Running for %d steps, that means %f epochs"",\n total_steps, total_steps * batch_size / ntrain_img)\n\n # Start input pipeline as early as possible.\n n_prefetch = config.get(""prefetch_to_device"", 1)\n train_iter = input_pipeline.start_global(train_ds, devices_flat, n_prefetch)\n\n################################################################################\n# #\n# Create Model & Optimizer #\n# #\n################################################################################\n\n write_note(""Creating model..."")\n model_mod = importlib.import_module(f""big_vision.models.{config.model_name}"")\n model = model_mod.Model(\n num_classes=config.num_classes, **config.get(""model"", {}))\n\n def init(rng):\n batch = jax.tree.map(lambda x: jnp.zeros(x.shape, x.dtype.as_numpy_dtype),\n train_ds.element_spec)\n params = model.init(rng, batch[""image""])[""params""]\n\n # Set bias in the head to a low value, such that loss is small initially.\n if ""init_head_bias"" in config:\n params[""head""][""bias""] = jnp.full_like(params[""head""][""bias""],\n config[""init_head_bias""])\n\n return params\n\n # This seed makes the Jax part of things (like model init) deterministic.\n # However, full training still won't be deterministic, for example due to the\n # tf.data pipeline not being deterministic even if we would set TF seed.\n # See (internal link) for a fun read on what it takes.\n rng = jax.random.PRNGKey(u.put_cpu(config.get(""seed"", 0)))\n\n write_note(""Inferring parameter shapes..."")\n rng, rng_init = jax.random.split(rng)\n params_shape = jax.eval_shape(init, rng_init)\n\n write_note(""Inferring optimizer state shapes..."")\n tx, sched_fns = bv_optax.make(config, nn.unbox(params_shape), sched_kw=dict(\n total_steps=total_steps, batch_size=batch_size, data_size=ntrain_img))\n opt_shape = jax.eval_shape(tx.init, params_shape)\n # We jit this, such that the arrays are created on the CPU, not device[0].\n sched_fns_cpu = [u.jit_cpu()(sched_fn) for sched_fn in sched_fns]\n\n if jax.process_index() == 0:\n num_params = sum(np.prod(p.shape) for p in jax.tree.leaves(params_shape))\n mw.measure(""num_params"", num_params)\n\n################################################################################\n# #\n# Shard & Transfer #\n# #\n################################################################################\n\n write_note(""Inferring shardings..."")\n train_state_shape = {""params"": params_shape, ""opt"": opt_shape}\n\n strategy = config.get(""sharding_strategy"", [("".*"", ""replicate"")])\n with nn.logical_axis_rules(sharding_rules):\n train_state_sharding = bv_sharding.infer_sharding(\n train_state_shape, strategy=strategy, mesh=mesh)\n\n write_note(""Transferring train_state to devices..."")\n # RNG is always replicated\n rng_init = u.reshard(rng_init, repl_sharding)\n\n # Parameters and the optimizer are now global (distributed) jax arrays.\n params = jax.jit(init, out_shardings=train_state_sharding[""params""])(rng_init)\n opt = jax.jit(tx.init, out_shardings=train_state_sharding[""opt""])(params)\n\n rng, rng_loop = jax.random.split(rng, 2)\n rng_loop = u.reshard(rng_loop, repl_sharding)\n del rng # not used anymore, so delete it.\n\n # At this point we have everything we need to form a train state. It contains\n # all the parameters that are passed and updated by the main training step.\n # From here on, we have no need for Flax AxisMetadata (such as partitioning).\n train_state = nn.unbox({""params"": params, ""opt"": opt})\n del params, opt # Delete to avoid memory leak or accidental reuse.\n\n write_note(""Logging parameter overview..."")\n parameter_overview.log_parameter_overview(\n train_state[""params""], msg=""Init params"",\n include_stats=""global"", jax_logging_process=0)\n\n################################################################################\n# #\n# Update Step #\n# #\n################################################################################\n\n @functools.partial(\n jax.jit,\n donate_argnums=(0,),\n out_shardings=(train_state_sharding, repl_sharding))\n def update_fn(train_state, rng, batch):\n """"""Update step.""""""\n\n images, labels = batch[""image""], batch[""labels""]\n\n step_count = bv_optax.get_count(train_state[""opt""], jittable=True)\n rng = jax.random.fold_in(rng, step_count)\n\n if config.get(""mixup"") and config.mixup.p:\n # The shard_map below makes mixup run on every device independently and\n # thus avoids unnecessary communication.\n sharded_mixup_fn = shard_map(\n u.get_mixup(rng, config.mixup.p),\n mesh=jax.sharding.Mesh(devices_flat, (""data"",)),\n in_specs=P(""data""), out_specs=(P(), P(""data""), P(""data"")))\n rng, (images, labels), _ = sharded_mixup_fn(images, labels)\n\n # Get device-specific loss rng.\n rng, rng_model = jax.random.split(rng, 2)\n\n def loss_fn(params):\n logits, _ = model.apply(\n {""params"": params}, images,\n train=True, rngs={""dropout"": rng_model})\n return getattr(u, config.get(""loss"", ""sigmoid_xent""))(\n logits=logits, labels=labels)\n\n params, opt = train_state[""params""], train_state[""opt""]\n loss, grads = jax.value_and_grad(loss_fn)(params)\n updates, opt = tx.update(grads, opt, params)\n params = optax.apply_updates(params, updates)\n\n measurements = {""training_loss"": loss}\n gs = jax.tree.leaves(bv_optax.replace_frozen(config.schedule, grads, 0.))\n measurements[""l2_grads""] = jnp.sqrt(sum([jnp.sum(g * g) for g in gs]))\n ps = jax.tree.leaves(params)\n measurements[""l2_params""] = jnp.sqrt(sum([jnp.sum(p * p) for p in ps]))\n us = jax.tree.leaves(updates)\n measurements[""l2_updates""] = jnp.sqrt(sum([jnp.sum(u * u) for u in us]))\n\n return {""params"": params, ""opt"": opt}, measurements\n\n################################################################################\n# #\n# Load Checkpoint #\n# #\n################################################################################\n\n # Decide how to initialize training. The order is important.\n # 1. Always resumes from the existing checkpoint, e.g. resumes a finetune job.\n # 2. Resume from a previous checkpoint, e.g. start a cooldown training job.\n # 3. Initialize model from something, e,g, start a fine-tuning job.\n # 4. Train from scratch.\n resume_ckpt_path = None\n if save_ckpt_path and gfile.exists(f""{save_ckpt_path}-LAST""):\n resume_ckpt_path = save_ckpt_path\n elif config.get(""resume""):\n resume_ckpt_path = fillin(config.resume)\n\n ckpt_mngr = None\n if save_ckpt_path or resume_ckpt_path:\n ckpt_mngr = array_serial.GlobalAsyncCheckpointManager()\n\n if resume_ckpt_path:\n write_note(f""Resuming training from checkpoint {resume_ckpt_path}..."")\n jax.tree.map(lambda x: x.delete(), train_state)\n del train_state\n shardings = {\n **train_state_sharding,\n ""chrono"": jax.tree.map(lambda _: repl_sharding,\n u.chrono.save()),\n }\n loaded = u.load_checkpoint_ts(\n resume_ckpt_path, tree=shardings, shardings=shardings)\n train_state = {key: loaded[key] for key in train_state_sharding.keys()}\n\n u.chrono.load(jax.device_get(loaded[""chrono""]))\n del loaded\n elif config.get(""model_init""):\n write_note(f""Initialize model from {config.model_init}..."")\n # TODO: when updating the `load` API soon, do pass and request the\n # full `train_state` from it. Examples where useful: VQVAE, BN.\n train_state[""params""] = model_mod.load(\n train_state[""params""], config.model_init, config.get(""model""),\n **config.get(""model_load"", {}))\n\n # load has the freedom to return params not correctly sharded. Think of for\n # example ViT resampling position embedings on CPU as numpy arrays.\n train_state[""params""] = u.reshard(\n train_state[""params""], train_state_sharding[""params""])\n\n parameter_overview.log_parameter_overview(\n train_state[""params""], msg=""restored params"",\n include_stats=""global"", jax_logging_process=0)\n\n\n################################################################################\n# #\n# Setup Evals #\n# #\n################################################################################\n\n # We do not jit/pmap this function, because it is passed to evaluator that\n # does it later. We output as many intermediate tensors as possible for\n # maximal flexibility. Later `jit` will prune out things that are not needed.\n def eval_logits_fn(train_state, batch):\n logits, out = model.apply({""params"": train_state[""params""]}, batch[""image""])\n return logits, out\n\n def eval_loss_fn(train_state, batch):\n logits, _ = model.apply({""params"": train_state[""params""]}, batch[""image""])\n loss_fn = getattr(u, config.get(""loss"", ""sigmoid_xent""))\n return {\n ""loss"": loss_fn(logits=logits, labels=batch[""labels""], reduction=False)\n }\n\n eval_fns = {\n ""predict"": eval_logits_fn,\n ""loss"": eval_loss_fn,\n }\n\n # Only initialize evaluators when they are first needed.\n @functools.lru_cache(maxsize=None)\n def evaluators():\n return eval_common.from_config(\n config, eval_fns,\n lambda s: write_note(f""Init evaluator: {s}…\n{u.chrono.note}""),\n lambda key, cfg: get_steps(key, default=None, cfg=cfg),\n devices_flat,\n )\n\n # At this point we need to know the current step to see whether to run evals.\n write_note(""Inferring the first step number..."")\n first_step_device = bv_optax.get_count(train_state[""opt""], jittable=True)\n first_step = int(jax.device_get(first_step_device))\n u.chrono.inform(first_step=first_step)\n\n # Note that training can be pre-empted during the final evaluation (i.e.\n # just after the final checkpoint has been written to disc), in which case we\n # want to run the evals.\n if first_step in (total_steps, 0):\n write_note(""Running initial or final evals..."")\n mw.step_start(first_step)\n for (name, evaluator, _, prefix) in evaluators():\n if config.evals[name].get(""skip_first"") and first_step != total_steps:\n continue\n write_note(f""{name} evaluation...\n{u.chrono.note}"")\n with u.chrono.log_timing(f""z/secs/eval/{name}""):\n with mesh, nn.logical_axis_rules(sharding_rules):\n for key, value in evaluator.run(train_state):\n mw.measure(f""{prefix}{key}"", value)\n\n################################################################################\n# #\n# Train Loop #\n# #\n################################################################################\n\n prof = None # Keeps track of start/stop of profiler state.\n\n write_note(""Starting training loop, compiling the first step..."")\n for step, batch in zip(range(first_step + 1, total_steps + 1), train_iter):\n mw.step_start(step)\n\n with jax.profiler.StepTraceAnnotation(""train_step"", step_num=step):\n with u.chrono.log_timing(""z/secs/update0"", noop=step > first_step + 1):\n with mesh, nn.logical_axis_rules(sharding_rules):\n train_state, measurements = update_fn(train_state, rng_loop, batch)\n\n # On the first host, let's always profile a handful of early steps.\n if jax.process_index() == 0:\n prof = u.startstop_prof(prof, step, first_step, get_steps(""log_training""))\n\n # Report training progress\n if (u.itstime(step, get_steps(""log_training""), total_steps, host=0)\n or u.chrono.warmup and jax.process_index() == 0):\n for i, sched_fn_cpu in enumerate(sched_fns_cpu):\n mw.measure(f""global_schedule{i if i else ''}"",\n sched_fn_cpu(u.put_cpu(step - 1)))\n measurements = jax.device_get(measurements)\n for name, value in measurements.items():\n mw.measure(name, value)\n u.chrono.tick(step)\n for k in (""training_loss"", ""l2_grads"", ""l2_updates"", ""l2_params""):\n if not np.isfinite(measurements.get(k, 0.0)):\n raise RuntimeError(f""{k} became nan or inf somewhere within steps ""\n f""[{step - get_steps('log_training')}, {step}]"")\n\n # Checkpoint saving\n keep_last = total_steps if get_steps(""ckpt"", None) else None\n keep_ckpt_steps = get_steps(""keep_ckpt"", None) or keep_last\n if save_ckpt_path and (\n (keep := u.itstime(step, keep_ckpt_steps, total_steps, first=False))\n or u.itstime(step, get_steps(""ckpt"", None), total_steps, first=True)\n ):\n u.chrono.pause(wait_for=train_state)\n\n # Copy because we add extra stuff to the checkpoint.\n ckpt = {**train_state}\n\n # To save chrono state correctly and safely in a multihost setup, we\n # broadcast the state to all hosts and convert it to a global array.\n with jax.transfer_guard(""allow""):\n chrono_ckpt = multihost_utils.broadcast_one_to_all(u.chrono.save())\n chrono_shardings = jax.tree.map(lambda _: repl_sharding, chrono_ckpt)\n ckpt = ckpt | {""chrono"": u.reshard(chrono_ckpt, chrono_shardings)}\n\n u.save_checkpoint_ts(ckpt_mngr, ckpt, save_ckpt_path, step, keep)\n u.chrono.resume()\n\n for (name, evaluator, log_steps, prefix) in evaluators():\n if u.itstime(step, log_steps, total_steps, first=False, last=True):\n u.chrono.pause(wait_for=train_state)\n u.chrono.tick(step) # Record things like epoch number, core hours etc.\n write_note(f""{name} evaluation...\n{u.chrono.note}"")\n with u.chrono.log_timing(f""z/secs/eval/{name}""):\n with mesh, nn.logical_axis_rules(sharding_rules):\n for key, value in evaluator.run(train_state):\n mw.measure(f""{prefix}{key}"", jax.device_get(value))\n u.chrono.resume()\n mw.step_end()\n\n # Always give a chance to stop the profiler, no matter how things ended.\n # TODO: can we also do this when dying of an exception like OOM?\n if jax.process_index() == 0 and prof is not None:\n u.startstop_prof(prof)\n\n # Last note needs to happen before the pool's closed =)\n write_note(f""Done!\n{u.chrono.note}"")\n\n pool.close()\n pool.join()\n mw.close()\n if ckpt_mngr:\n ckpt_mngr.wait_until_finished()\n\n # Make sure all hosts stay up until the end of main.\n u.sync()\n\n u.maybe_cleanup_workdir(workdir, flags.FLAGS.cleanup, info)\n\n\nif __name__ == ""__main__"":\n app.run(main)\n",python,tab
|
| 3 |
+
2,96,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"9:10:53 AM [info] Activating crowd-code\n9:10:53 AM [info] Recording started\n9:10:53 AM [info] Initializing git provider using file system watchers...\n9:10:54 AM [info] Git repository found\n9:10:54 AM [info] Git provider initialized successfully\n",Log,tab
|
| 4 |
+
3,196,"extension-output-pdoom-org.crowd-code-#1-crowd-code",245,0,"9:10:54 AM [info] Initial git state: [object Object]\n",Log,content
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-971339fb-c463-429e-a956-f7bb98fdea341755623101217-2025_08_19-19.05.03.822/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-9f142d59-1199-4718-91b8-9c661493a1b51763125195520-2025_11_14-14.00.04.00/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-ac6664bd-508f-405e-9f34-c2691ea9a56e1761555883090-2025_10_27-10.04.54.408/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-beadbbc6-30c2-409e-bd4b-c1b78eed0f3c1755872503826-2025_08_22-16.21.51.549/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-d5c0f30b-efff-4cba-9421-06a8c78914011759343086476-2025_10_01-20.24.54.587/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-dea29b8c-1428-44de-be76-3b6707ae1c481762331529047-2025_11_05-09.32.27.633/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-e5295f7c-e65d-4455-aaa4-44e96e5467f81765288393722-2025_12_09-14.53.21.307/source.csv
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
2,537,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"2:53:21 PM [info] Activating crowd-code\n2:53:21 PM [info] Recording started\n2:53:21 PM [info] Initializing git provider using file system watchers...\n2:53:21 PM [info] No workspace folder found\n",Log,tab
|
| 3 |
+
3,2797,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",0,0,"#!/usr/bin/env python3\nimport sys\nfrom pathlib import Path\nimport pandas as pd\n\ninput_dir = sys.argv[1]\nfor parquet_file in sorted(Path(input_dir).glob(""shard_*.parquet"")):\n df = pd.read_parquet(parquet_file)\n for text in df['text']:\n print(text)\n",python,tab
|
| 4 |
+
4,6424,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",240,0,"",python,selection_command
|
| 5 |
+
5,6630,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",260,0,"",python,selection_command
|
| 6 |
+
6,6886,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",240,0,"",python,selection_command
|
| 7 |
+
7,7089,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",260,0,"",python,selection_command
|
| 8 |
+
8,7515,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",260,0,"\n",python,content
|
| 9 |
+
9,10888,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",261,0,"i",python,content
|
| 10 |
+
10,10891,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",262,0,"",python,selection_keyboard
|
| 11 |
+
11,11118,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",262,0,"f",python,content
|
| 12 |
+
12,11120,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",263,0,"",python,selection_keyboard
|
| 13 |
+
13,11129,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",263,0," ",python,content
|
| 14 |
+
14,11133,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",264,0,"",python,selection_keyboard
|
| 15 |
+
15,14382,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",264,0,"_",python,content
|
| 16 |
+
16,14385,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",265,0,"",python,selection_keyboard
|
| 17 |
+
17,16160,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",261,4,"if __name__ == ""__main__"":\n",python,content
|
| 18 |
+
18,18110,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",288,0," main()\n",python,content
|
| 19 |
+
19,30407,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",288,0,"",python,selection_command
|
| 20 |
+
20,30562,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",261,0,"",python,selection_command
|
| 21 |
+
21,30809,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",260,0,"",python,selection_command
|
| 22 |
+
22,30841,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",240,0,"",python,selection_command
|
| 23 |
+
23,30877,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",212,0,"",python,selection_command
|
| 24 |
+
24,30910,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",173,0,"",python,selection_command
|
| 25 |
+
25,30943,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",104,0,"",python,selection_command
|
| 26 |
+
26,30971,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",80,0,"",python,selection_command
|
| 27 |
+
27,31005,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",79,0,"",python,selection_command
|
| 28 |
+
28,31145,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",59,0,"",python,selection_command
|
| 29 |
+
29,31383,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",79,0,"",python,selection_command
|
| 30 |
+
30,35054,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",79,0,"\n",python,content
|
| 31 |
+
31,38264,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",80,0,"d",python,content
|
| 32 |
+
32,38266,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",81,0,"",python,selection_keyboard
|
| 33 |
+
33,40019,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",80,2,"def main():\n",python,content
|
| 34 |
+
34,41614,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",80,0,"",python,selection_command
|
| 35 |
+
35,42532,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",91,0,"\n ",python,content
|
| 36 |
+
36,45322,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",92,4,"",python,content
|
| 37 |
+
37,226426,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",93,0,"",python,selection_command
|
| 38 |
+
38,227609,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",92,0,"",python,selection_command
|
| 39 |
+
39,227801,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",80,0,"",python,selection_command
|
| 40 |
+
40,231987,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",92,0,"",python,selection_command
|
| 41 |
+
41,233629,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",93,0,"",python,selection_command
|
| 42 |
+
42,233634,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",117,0,"",python,selection_command
|
| 43 |
+
43,235362,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",186,0,"",python,selection_command
|
| 44 |
+
44,236390,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",190,0,"",python,selection_command
|
| 45 |
+
45,237568,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",229,0,"",python,selection_command
|
| 46 |
+
46,238498,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",257,0,"",python,selection_command
|
| 47 |
+
47,238609,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",261,0,"",python,selection_command
|
| 48 |
+
48,241015,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",273,0,"",python,selection_command
|
| 49 |
+
49,241191,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",282,0,"",python,selection_command
|
| 50 |
+
50,241313,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",273,0,"",python,selection_command
|
| 51 |
+
51,241541,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",261,0,"",python,selection_command
|
| 52 |
+
52,241670,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",233,0,"",python,selection_command
|
| 53 |
+
53,241849,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",194,0,"",python,selection_command
|
| 54 |
+
54,275561,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",125,0,"",python,selection_command
|
| 55 |
+
55,275724,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",101,0,"",python,selection_command
|
| 56 |
+
56,275887,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",92,0,"",python,selection_command
|
| 57 |
+
57,276025,"/home/franz.srambical/crowd-pilot/crowd_pilot/read_dataset.py",88,0,"",python,selection_command
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-e6fd64e1-70f6-461f-bc3d-ac75f6654a311756111953368-2025_08_25-10.52.42.401/source.csv
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
1,3,"/fast/home/franz.srambical/jafar/train_tokenizer.py",0,0,"import os\n\n# os.environ['XLA_FLAGS'] = (\n# '--xla_python_client_mem_fraction=.98 '\n# )\n# FIXME (f.srambical): test whether this increases throughput\nos.environ['XLA_FLAGS'] = (\n '--xla_gpu_enable_latency_hiding_scheduler=true '\n '--xla_gpu_enable_async_collectives=true '\n)\n\nfrom dataclasses import dataclass, field\nfrom typing import cast, Optional\n\nimport einops\nimport itertools\nfrom jax.sharding import Mesh, PartitionSpec, NamedSharding\nfrom jax.experimental.mesh_utils import create_device_mesh\nimport optax\nimport orbax.checkpoint as ocp\nimport numpy as np\nimport dm_pix as pix\nimport jax\nimport jax.numpy as jnp\nimport tyro\nimport wandb\nimport grain\nimport flax.nnx as nnx\n\nfrom models.tokenizer import TokenizerVQVAE\nfrom utils.dataloader import get_dataloader\nfrom utils.train_utils import (\n get_lr_schedule,\n count_parameters_by_component,\n print_mem_stats,\n print_compiled_memory_stats,\n print_compiled_cost_analysis,\n)\n\n\n@dataclass\nclass Args:\n # Experiment\n num_steps: int = 300_000\n seed: int = 0\n seq_len: int = 16\n image_channels: int = 3\n image_height: int = 90\n image_width: int = 160\n data_dir: str = """"\n save_ckpt: bool = False\n restore_ckpt: bool = False\n # Optimization\n vq_beta: float = 0.25\n batch_size: int = 48\n init_lr: float = 0.0\n max_lr: float = 3e-4\n decay_end: float = 0.0\n wsd_decay_steps: int = (\n 20000 # NOTE: wsd_decay_steps will only be used when using a wsd-schedule\n )\n lr_schedule: str = ""wsd"" # supported options: wsd, cos\n warmup_steps: int = 10000\n # Tokenizer\n model_dim: int = 512\n ffn_dim: int = 2048\n latent_dim: int = 32\n num_latents: int = 1024\n patch_size: int = 4\n num_blocks: int = 4\n num_heads: int = 8\n dropout: float = 0.0\n codebook_dropout: float = 0.01\n param_dtype = jnp.float32\n dtype = jnp.bfloat16\n # Logging\n log: bool = False\n entity: str = """"\n project: str = """"\n name: str = ""train_tokenizer""\n tags: list[str] = field(default_factory=lambda: [""tokenizer""])\n log_interval: int = 5\n log_image_interval: int = 250\n ckpt_dir: str = """"\n log_checkpoint_interval: int = 10000\n log_checkpoint_keep_period: int = 20000\n log_gradients: bool = False\n wandb_id: str = """"\n use_flash_attention: bool = True\n\n\ndef build_model(args: Args, rng: jax.Array) -> tuple[TokenizerVQVAE, jax.Array]:\n rng, _rng = jax.random.split(rng)\n rngs = nnx.Rngs(_rng)\n return (\n TokenizerVQVAE(\n in_dim=args.image_channels,\n model_dim=args.model_dim,\n ffn_dim=args.ffn_dim,\n latent_dim=args.latent_dim,\n num_latents=args.num_latents,\n patch_size=args.patch_size,\n num_blocks=args.num_blocks,\n num_heads=args.num_heads,\n dropout=args.dropout,\n codebook_dropout=args.codebook_dropout,\n param_dtype=args.param_dtype,\n dtype=args.dtype,\n use_flash_attention=args.use_flash_attention,\n rngs=rngs,\n ),\n rng,\n )\n\n\ndef build_optimizer(\n model: TokenizerVQVAE, args: Args\n) -> tuple[nnx.Optimizer, optax.Schedule]:\n lr_schedule = get_lr_schedule(\n args.lr_schedule,\n args.init_lr,\n args.max_lr,\n args.decay_end,\n args.num_steps,\n args.warmup_steps,\n args.wsd_decay_steps,\n )\n tx = optax.adamw(\n learning_rate=lr_schedule,\n b1=0.9,\n b2=0.9,\n weight_decay=1e-4,\n mu_dtype=args.param_dtype, # moments in full precision\n )\n optimizer = nnx.Optimizer(model, tx)\n return optimizer, lr_schedule\n\n\ndef build_mesh_and_sharding(\n num_devices: int,\n) -> tuple[Mesh, NamedSharding, NamedSharding]:\n device_mesh_arr = create_device_mesh((num_devices,))\n mesh = Mesh(devices=device_mesh_arr, axis_names=(""data"",))\n replicated_sharding = NamedSharding(mesh, PartitionSpec())\n videos_sharding = NamedSharding(mesh, PartitionSpec(""data"", None, None, None, None))\n return mesh, replicated_sharding, videos_sharding\n\n\ndef shard_optimizer_states(\n optimizer: nnx.Optimizer, replicated_sharding: NamedSharding\n) -> None:\n model_state = nnx.state(optimizer.model)\n model_sharded_state = jax.lax.with_sharding_constraint(\n model_state, replicated_sharding\n )\n nnx.update(optimizer.model, model_sharded_state)\n optimizer_state = nnx.state(optimizer, nnx.optimizer.OptState)\n optimizer_sharded_state = jax.lax.with_sharding_constraint(\n optimizer_state, replicated_sharding\n )\n nnx.update(optimizer, optimizer_sharded_state)\n\n\ndef build_dataloader(args: Args) -> grain.DataLoaderIterator:\n image_shape = (args.image_height, args.image_width, args.image_channels)\n array_record_files = [\n os.path.join(args.data_dir, x)\n for x in os.listdir(args.data_dir)\n if x.endswith("".array_record"")\n ]\n grain_dataloader = get_dataloader(\n array_record_files,\n args.seq_len,\n # NOTE: We deliberately pass the global batch size\n # The dataloader shards the dataset across all processes\n args.batch_size,\n *image_shape,\n num_workers=8,\n prefetch_buffer_size=1,\n seed=args.seed,\n )\n initial_state = grain_dataloader._create_initial_state()\n grain_iterator = grain.DataLoaderIterator(grain_dataloader, initial_state)\n return grain_iterator\n\n\ndef build_checkpoint_manager(args: Args) -> ocp.CheckpointManager:\n handler_registry = ocp.handlers.DefaultCheckpointHandlerRegistry()\n handler_registry.add(\n ""model_state"", ocp.args.PyTreeSave, ocp.handlers.PyTreeCheckpointHandler\n )\n handler_registry.add(\n ""model_state"", ocp.args.PyTreeRestore, ocp.handlers.PyTreeCheckpointHandler\n )\n handler_registry.add(\n ""dataloader_state"",\n grain.checkpoint.CheckpointSave,\n cast(ocp.handlers.CheckpointHandler, grain.checkpoint.CheckpointHandler),\n )\n handler_registry.add(\n ""dataloader_state"",\n grain.checkpoint.CheckpointRestore,\n cast(ocp.handlers.CheckpointHandler, grain.checkpoint.CheckpointHandler),\n )\n checkpoint_options = ocp.CheckpointManagerOptions(\n save_interval_steps=args.log_checkpoint_interval,\n max_to_keep=3,\n keep_period=args.log_checkpoint_keep_period,\n step_format_fixed_length=6,\n cleanup_tmp_directories=True,\n )\n checkpoint_manager = ocp.CheckpointManager(\n args.ckpt_dir,\n options=checkpoint_options,\n handler_registry=handler_registry,\n )\n return checkpoint_manager\n\n\ndef restore_checkpoint_if_needed(\n args: Args,\n checkpoint_manager: ocp.CheckpointManager,\n optimizer: nnx.Optimizer,\n grain_iterator: grain.DataLoaderIterator,\n restore_step: Optional[int] = None,\n) -> tuple[int, nnx.Optimizer, grain.DataLoaderIterator]:\n step = 0\n if restore_step is None:\n restore_step = checkpoint_manager.latest_step()\n if args.restore_ckpt:\n abstract_optimizer = nnx.eval_shape(lambda: optimizer)\n abstract_optimizer_state = nnx.state(abstract_optimizer)\n restored = checkpoint_manager.restore(\n restore_step,\n args=ocp.args.Composite(\n model_state=ocp.args.PyTreeRestore(abstract_optimizer_state), # type: ignore\n dataloader_state=grain.checkpoint.CheckpointRestore(grain_iterator), # type: ignore\n ),\n )\n restored_optimizer_state = restored[""model_state""]\n nnx.update(optimizer, restored_optimizer_state)\n grain_iterator = restored[""dataloader_state""]\n step = restore_step or 0\n print(f""Restored dataloader and model state from step {step}"")\n return step, optimizer, grain_iterator\n\n\ndef main(args: Args) -> None:\n jax.distributed.initialize()\n num_devices = jax.device_count()\n if num_devices == 0:\n raise ValueError(""No JAX devices found."")\n print(f""Running on {num_devices} devices."")\n\n if args.batch_size % num_devices != 0:\n raise ValueError(\n f""Global batch size {args.batch_size} must be divisible by ""\n f""number of devices {num_devices}.""\n )\n\n rng = jax.random.key(args.seed)\n\n # --- Initialize model ---\n tokenizer, rng = build_model(args, rng)\n\n _, params, _ = nnx.split(tokenizer, nnx.Param, ...)\n param_counts = count_parameters_by_component(params)\n\n if args.log and jax.process_index() == 0:\n wandb_init_kwargs = {\n ""entity"": args.entity,\n ""project"": args.project,\n ""name"": args.name,\n ""tags"": args.tags,\n ""group"": ""debug"",\n ""config"": args,\n }\n\n if args.wandb_id:\n wandb_init_kwargs.update(\n {\n ""id"": args.wandb_id,\n ""resume"": ""allow"",\n }\n )\n wandb.init(**wandb_init_kwargs)\n\n wandb.config.update({""model_param_count"": param_counts})\n\n print(""Parameter counts:"")\n print(param_counts)\n\n # --- Initialize optimizer ---\n optimizer, lr_schedule = build_optimizer(tokenizer, args)\n del tokenizer\n\n # FIXME: switch to create_hybrid_device_mesh for runs spanning multiple nodes\n mesh, replicated_sharding, videos_sharding = build_mesh_and_sharding(num_devices)\n\n shard_optimizer_states(optimizer, replicated_sharding)\n\n # --- Initialize checkpoint manager ---\n checkpoint_manager = build_checkpoint_manager(args)\n\n # --- Create DataLoaderIterator from dataloader ---\n grain_iterator = build_dataloader(args)\n\n # --- Restore checkpoint ---\n step, optimizer, grain_iterator = restore_checkpoint_if_needed(\n args, checkpoint_manager, optimizer, grain_iterator\n )\n\n # --- Define loss and train step (close over args) ---\n def tokenizer_loss_fn(\n model: TokenizerVQVAE, inputs: dict\n ) -> tuple[jax.Array, tuple[jax.Array, dict]]:\n gt = jnp.asarray(inputs[""videos""], dtype=jnp.float32) / 255.0\n inputs[""videos""] = gt.astype(args.dtype)\n model.train()\n outputs = model(inputs, training=True)\n outputs[""recon""] = outputs[""recon""].astype(jnp.float32)\n mse = jnp.square(gt - outputs[""recon""]).mean()\n q_loss = jnp.square(jax.lax.stop_gradient(outputs[""emb""]) - outputs[""z""]).mean()\n commitment_loss = jnp.square(\n outputs[""emb""] - jax.lax.stop_gradient(outputs[""z""])\n ).mean()\n loss = mse + q_loss + args.vq_beta * commitment_loss\n\n gt_clipped = gt.clip(0, 1).reshape(-1, *gt.shape[2:])\n recon = outputs[""recon""].clip(0, 1).reshape(-1, *outputs[""recon""].shape[2:])\n psnr = jnp.asarray(pix.psnr(gt_clipped, recon)).mean()\n ssim = jnp.asarray(pix.ssim(gt_clipped, recon)).mean()\n _, index_counts = jnp.unique_counts(\n jnp.ravel(outputs[""indices""]), size=args.num_latents, fill_value=0\n )\n codebook_usage = (index_counts != 0).mean()\n metrics = dict(\n loss=loss,\n mse=mse,\n q_loss=q_loss,\n commitment_loss=commitment_loss,\n psnr=psnr,\n ssim=ssim,\n codebook_usage=codebook_usage,\n )\n return loss, (outputs[""recon""], metrics)\n\n @nnx.jit(donate_argnums=0)\n def train_step(\n optimizer: nnx.Optimizer, inputs: dict\n ) -> tuple[jax.Array, jax.Array, dict]:\n def loss_fn(model: TokenizerVQVAE) -> tuple[jax.Array, tuple[jax.Array, dict]]:\n return tokenizer_loss_fn(model, inputs)\n\n (loss, (recon, metrics)), grads = nnx.value_and_grad(loss_fn, has_aux=True)(\n optimizer.model\n )\n optimizer.update(grads)\n if args.log_gradients:\n metrics[""encoder_gradients_std/""] = jax.tree.map(\n lambda x: x.std(), grads[""params""][""encoder""]\n )\n metrics[""vq_gradients_std/""] = jax.tree.map(\n lambda x: x.std(), grads[""params""][""vq""]\n )\n metrics[""decoder_gradients_std/""] = jax.tree.map(\n lambda x: x.std(), grads[""params""][""decoder""]\n )\n return loss, recon, metrics\n\n # --- TRAIN LOOP ---\n dataloader = (\n jax.make_array_from_process_local_data(videos_sharding, elem)\n for elem in grain_iterator\n )\n if jax.process_index() == 0:\n first_videos = next(dataloader)\n sample_inputs = dict(videos=first_videos)\n compiled = train_step.lower(optimizer, sample_inputs).compile()\n print_compiled_memory_stats(compiled.memory_analysis())\n print_compiled_cost_analysis(compiled.cost_analysis())\n # Do not skip the first batch during training\n dataloader = itertools.chain([first_videos], dataloader)\n print(f""Starting training from step {step}..."")\n first_step = step\n while step < args.num_steps:\n for videos in dataloader:\n # --- Train step ---\n inputs = dict(videos=videos)\n loss, recon, metrics = train_step(optimizer, inputs)\n if step == first_step:\n print_mem_stats(""After params initialized"")\n metrics[""lr""] = lr_schedule(step)\n print(f""Step {step}, loss: {loss}"")\n step += 1\n\n # --- Logging ---\n if args.log:\n if step % args.log_interval == 0 and jax.process_index() == 0:\n wandb.log(\n {\n ""loss"": loss,\n ""step"": step,\n **metrics,\n }\n )\n if step % args.log_image_interval == 0:\n gt_seq = inputs[""videos""][0].astype(jnp.float32) / 255.0\n recon_seq = recon[0].clip(0, 1)\n comparison_seq = jnp.concatenate((gt_seq, recon_seq), axis=1)\n comparison_seq = einops.rearrange(\n comparison_seq * 255, ""t h w c -> h (t w) c""\n )\n # NOTE: Process-dependent control flow deliberately happens\n # after indexing operation since it must not contain code\n # sections that lead to cross-accelerator communication.\n if jax.process_index() == 0:\n log_images = dict(\n image=wandb.Image(np.asarray(gt_seq[0])),\n recon=wandb.Image(np.asarray(recon_seq[0])),\n true_vs_recon=wandb.Image(\n np.asarray(comparison_seq.astype(np.uint8))\n ),\n )\n wandb.log(log_images)\n # --- Checkpointing ---\n if args.save_ckpt and step % args.log_checkpoint_interval == 0:\n optimizer_state = nnx.state(optimizer)\n checkpoint_manager.save(\n step,\n args=ocp.args.Composite(\n model_state=ocp.args.PyTreeSave(optimizer_state), # type: ignore\n dataloader_state=grain.checkpoint.CheckpointSave( # type: ignore\n grain_iterator # type: ignore\n ),\n ),\n )\n print(f""Saved checkpoint at step {step}"")\n if step >= args.num_steps:\n break\n\n checkpoint_manager.close()\n\n\nif __name__ == ""__main__"":\n args = tyro.cli(Args)\n main(args)\n",python,tab
|
| 3 |
+
2,302,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"10:52:42 AM [info] Activating crowd-code\n10:52:42 AM [info] Recording started\n10:52:42 AM [info] Initializing git provider using file system watchers...\n",Log,tab
|
| 4 |
+
3,811,"extension-output-pdoom-org.crowd-code-#1-crowd-code",153,0,"10:52:42 AM [info] Git repository found\n10:52:42 AM [info] Git provider initialized successfully\n10:52:42 AM [info] Initial git state: [object Object]\n",Log,content
|
| 5 |
+
4,4248,"/fast/home/franz.srambical/jafar/train_tokenizer.py",0,0,"",python,tab
|
| 6 |
+
5,8874,"/fast/home/franz.srambical/jafar/train_tokenizer.py",392,0,"",python,selection_command
|
| 7 |
+
6,9119,"/fast/home/franz.srambical/jafar/train_tokenizer.py",375,0,"",python,selection_command
|
| 8 |
+
7,9169,"/fast/home/franz.srambical/jafar/train_tokenizer.py",361,0,"",python,selection_command
|
| 9 |
+
8,9186,"/fast/home/franz.srambical/jafar/train_tokenizer.py",360,0,"",python,selection_command
|
| 10 |
+
9,9234,"/fast/home/franz.srambical/jafar/train_tokenizer.py",326,0,"",python,selection_command
|
| 11 |
+
10,9302,"/fast/home/franz.srambical/jafar/train_tokenizer.py",285,0,"",python,selection_command
|
| 12 |
+
11,9302,"/fast/home/franz.srambical/jafar/train_tokenizer.py",284,0,"",python,selection_command
|
| 13 |
+
12,9314,"/fast/home/franz.srambical/jafar/train_tokenizer.py",282,0,"",python,selection_command
|
| 14 |
+
13,9366,"/fast/home/franz.srambical/jafar/train_tokenizer.py",235,0,"",python,selection_command
|
| 15 |
+
14,9401,"/fast/home/franz.srambical/jafar/train_tokenizer.py",181,0,"",python,selection_command
|
| 16 |
+
15,9415,"/fast/home/franz.srambical/jafar/train_tokenizer.py",153,0,"",python,selection_command
|
| 17 |
+
16,9612,"/fast/home/franz.srambical/jafar/train_tokenizer.py",91,0,"",python,selection_command
|
| 18 |
+
17,9746,"/fast/home/franz.srambical/jafar/train_tokenizer.py",87,0,"",python,selection_command
|
| 19 |
+
18,10176,"/fast/home/franz.srambical/jafar/train_tokenizer.py",91,0,"",python,selection_command
|
| 20 |
+
19,14048,"utils/train_utils.py",0,0,"import jax\nimport optax\nfrom jax.tree_util import tree_map, tree_reduce\n\n\ndef get_lr_schedule(\n lr_schedule: str,\n init_lr: float,\n max_lr: float,\n decay_end: float,\n total_steps: int,\n warmup_steps: int,\n wsd_decay_steps: int,\n) -> optax.Schedule:\n supported_schedules = [""wsd"", ""cos""]\n if lr_schedule == ""cos"":\n assert (\n warmup_steps <= total_steps\n ), ""Warmup steps can't be greater than total steps.""\n return optax.warmup_cosine_decay_schedule(\n init_value=init_lr,\n peak_value=max_lr,\n warmup_steps=warmup_steps,\n decay_steps=total_steps, # Note: decay_steps includes the warmup steps, so we need to pass total value\n end_value=decay_end,\n )\n elif lr_schedule == ""wsd"":\n assert (\n warmup_steps + wsd_decay_steps <= total_steps\n ), ""Warmup and decay period is longer than total steps.""\n schedules = [\n optax.linear_schedule(\n init_value=init_lr, end_value=max_lr, transition_steps=warmup_steps\n ),\n optax.constant_schedule(value=max_lr),\n optax.linear_schedule(\n init_value=max_lr, end_value=decay_end, transition_steps=wsd_decay_steps\n ),\n ]\n boundaries = [warmup_steps, total_steps - wsd_decay_steps]\n return optax.join_schedules(schedules, boundaries)\n else:\n raise ValueError(\n f""Learning rate schedule not supported. Please use one of {supported_schedules}""\n )\n\n\ndef _count_leaf(x):\n """"""Count parameters in a single leaf node.""""""\n if hasattr(x, ""size""):\n return x.size\n return 0\n\n\ndef _count_component(component_params):\n """"""Count total parameters in a component.""""""\n return tree_reduce(\n lambda x, y: x + y, tree_map(_count_leaf, component_params), initializer=0\n )\n\n\ndef count_parameters_by_component(params):\n """"""Count parameters for each component of the model.\n\n Args:\n params: Model parameters from nnx.split(model, nnx.Param, ...)\n\n Returns:\n Dictionary with parameter counts for each component\n """"""\n component_names = list(params.keys())\n print(f""Counting all components: {component_names}"")\n\n counts = {}\n total_params = 0\n\n for name in component_names:\n component_params = params[name]\n count = _count_component(component_params)\n counts[name] = count\n total_params += count\n\n counts[""total""] = total_params\n return counts\n\n\ndef bytes_to_gb(num_bytes):\n return num_bytes / (1024**3)\n\n\ndef print_compiled_memory_stats(compiled_stats):\n """"""from: https://github.com/AI-Hypercomputer/maxtext/blob/b18829fbaa48aec7ac350a03e62248e24c6a76b2/MaxText/max_utils.py#L739""""""\n output_gb = bytes_to_gb(compiled_stats.output_size_in_bytes)\n temp_gb = bytes_to_gb(compiled_stats.temp_size_in_bytes)\n argument_gb = bytes_to_gb(compiled_stats.argument_size_in_bytes)\n alias_gb = bytes_to_gb(compiled_stats.alias_size_in_bytes)\n host_temp_gb = bytes_to_gb(compiled_stats.host_temp_size_in_bytes)\n total_gb = output_gb + temp_gb + argument_gb - alias_gb\n print(\n f""Total memory size: {total_gb:.1f} GB, Output size: {output_gb:.1f} GB, Temp size: {temp_gb:.1f} GB, ""\n f""Argument size: {argument_gb:.1f} GB, Host temp size: {host_temp_gb:.1f} GB.""\n )\n\n\ndef print_compiled_cost_analysis(cost_stats):\n flops = float(cost_stats.get(""flops"", 0.0))\n bytes_accessed = float(cost_stats.get(""bytes accessed"", 0.0))\n gb = bytes_to_gb(bytes_accessed) if bytes_accessed else 0.0\n intensity = (flops / bytes_accessed) if bytes_accessed else float(""nan"")\n print(\n f""FLOPs: {flops:.3e}, Bytes: {bytes_accessed:.3e} ({gb:.1f} GB), ""\n f""Intensity: {intensity:.1f} FLOPs/byte""\n )\n\n\ndef print_mem_stats(label: str):\n """"""from: https://github.com/AI-Hypercomputer/maxtext/blob/7898576359bacde81be25cb3038e348aac1f943b/MaxText/max_utils.py#L713""""""\n print(f""\nMemstats: {label}:"")\n try:\n for d in jax.local_devices():\n stats = d.memory_stats()\n used = round(stats[""bytes_in_use""] / 2**30, 2)\n limit = round(stats[""bytes_limit""] / 2**30, 2)\n print(f""\tUsing (GB) {used} / {limit} ({used/limit:%}) on {d}"")\n except (RuntimeError, KeyError, TypeError) as ex:\n print(f""\tMemstats unavailable, error: {ex}"")\n",python,tab
|
| 21 |
+
20,15843,"train_tokenizer.py",0,0,"import os\n\n# os.environ['XLA_FLAGS'] = (\n# '--xla_python_client_mem_fraction=.98 '\n# )\n# FIXME (f.srambical): test whether this increases throughput\nos.environ['XLA_FLAGS'] = (\n '--xla_gpu_enable_latency_hiding_scheduler=true '\n '--xla_gpu_enable_async_collectives=true '\n)\n\nfrom dataclasses import dataclass, field\nfrom typing import cast, Optional\n\nimport einops\nimport itertools\nfrom jax.sharding import Mesh, PartitionSpec, NamedSharding\nfrom jax.experimental.mesh_utils import create_device_mesh\nimport optax\nimport orbax.checkpoint as ocp\nimport numpy as np\nimport dm_pix as pix\nimport jax\nimport jax.numpy as jnp\nimport tyro\nimport wandb\nimport grain\nimport flax.nnx as nnx\n\nfrom models.tokenizer import TokenizerVQVAE\nfrom utils.dataloader import get_dataloader\nfrom utils.train_utils import (\n get_lr_schedule,\n count_parameters_by_component,\n print_mem_stats,\n print_compiled_memory_stats,\n print_compiled_cost_analysis,\n)\n\n\n@dataclass\nclass Args:\n # Experiment\n num_steps: int = 300_000\n seed: int = 0\n seq_len: int = 16\n image_channels: int = 3\n image_height: int = 90\n image_width: int = 160\n data_dir: str = """"\n save_ckpt: bool = False\n restore_ckpt: bool = False\n # Optimization\n vq_beta: float = 0.25\n batch_size: int = 48\n init_lr: float = 0.0\n max_lr: float = 3e-4\n decay_end: float = 0.0\n wsd_decay_steps: int = (\n 20000 # NOTE: wsd_decay_steps will only be used when using a wsd-schedule\n )\n lr_schedule: str = ""wsd"" # supported options: wsd, cos\n warmup_steps: int = 10000\n # Tokenizer\n model_dim: int = 512\n ffn_dim: int = 2048\n latent_dim: int = 32\n num_latents: int = 1024\n patch_size: int = 4\n num_blocks: int = 4\n num_heads: int = 8\n dropout: float = 0.0\n codebook_dropout: float = 0.01\n param_dtype = jnp.float32\n dtype = jnp.bfloat16\n # Logging\n log: bool = False\n entity: str = """"\n project: str = """"\n name: str = ""train_tokenizer""\n tags: list[str] = field(default_factory=lambda: [""tokenizer""])\n log_interval: int = 5\n log_image_interval: int = 250\n ckpt_dir: str = """"\n log_checkpoint_interval: int = 10000\n log_checkpoint_keep_period: int = 20000\n log_gradients: bool = False\n wandb_id: str = """"\n use_flash_attention: bool = True\n\n\ndef build_model(args: Args, rng: jax.Array) -> tuple[TokenizerVQVAE, jax.Array]:\n rng, _rng = jax.random.split(rng)\n rngs = nnx.Rngs(_rng)\n return (\n TokenizerVQVAE(\n in_dim=args.image_channels,\n model_dim=args.model_dim,\n ffn_dim=args.ffn_dim,\n latent_dim=args.latent_dim,\n num_latents=args.num_latents,\n patch_size=args.patch_size,\n num_blocks=args.num_blocks,\n num_heads=args.num_heads,\n dropout=args.dropout,\n codebook_dropout=args.codebook_dropout,\n param_dtype=args.param_dtype,\n dtype=args.dtype,\n use_flash_attention=args.use_flash_attention,\n rngs=rngs,\n ),\n rng,\n )\n\n\ndef build_optimizer(\n model: TokenizerVQVAE, args: Args\n) -> tuple[nnx.Optimizer, optax.Schedule]:\n lr_schedule = get_lr_schedule(\n args.lr_schedule,\n args.init_lr,\n args.max_lr,\n args.decay_end,\n args.num_steps,\n args.warmup_steps,\n args.wsd_decay_steps,\n )\n tx = optax.adamw(\n learning_rate=lr_schedule,\n b1=0.9,\n b2=0.9,\n weight_decay=1e-4,\n mu_dtype=args.param_dtype, # moments in full precision\n )\n optimizer = nnx.Optimizer(model, tx)\n return optimizer, lr_schedule\n\n\ndef build_mesh_and_sharding(\n num_devices: int,\n) -> tuple[Mesh, NamedSharding, NamedSharding]:\n device_mesh_arr = create_device_mesh((num_devices,))\n mesh = Mesh(devices=device_mesh_arr, axis_names=(""data"",))\n replicated_sharding = NamedSharding(mesh, PartitionSpec())\n videos_sharding = NamedSharding(mesh, PartitionSpec(""data"", None, None, None, None))\n return mesh, replicated_sharding, videos_sharding\n\n\ndef shard_optimizer_states(\n optimizer: nnx.Optimizer, replicated_sharding: NamedSharding\n) -> None:\n model_state = nnx.state(optimizer.model)\n model_sharded_state = jax.lax.with_sharding_constraint(\n model_state, replicated_sharding\n )\n nnx.update(optimizer.model, model_sharded_state)\n optimizer_state = nnx.state(optimizer, nnx.optimizer.OptState)\n optimizer_sharded_state = jax.lax.with_sharding_constraint(\n optimizer_state, replicated_sharding\n )\n nnx.update(optimizer, optimizer_sharded_state)\n\n\ndef build_dataloader(args: Args) -> grain.DataLoaderIterator:\n image_shape = (args.image_height, args.image_width, args.image_channels)\n array_record_files = [\n os.path.join(args.data_dir, x)\n for x in os.listdir(args.data_dir)\n if x.endswith("".array_record"")\n ]\n grain_dataloader = get_dataloader(\n array_record_files,\n args.seq_len,\n # NOTE: We deliberately pass the global batch size\n # The dataloader shards the dataset across all processes\n args.batch_size,\n *image_shape,\n num_workers=8,\n prefetch_buffer_size=1,\n seed=args.seed,\n )\n initial_state = grain_dataloader._create_initial_state()\n grain_iterator = grain.DataLoaderIterator(grain_dataloader, initial_state)\n return grain_iterator\n\n\ndef build_checkpoint_manager(args: Args) -> ocp.CheckpointManager:\n handler_registry = ocp.handlers.DefaultCheckpointHandlerRegistry()\n handler_registry.add(\n ""model_state"", ocp.args.PyTreeSave, ocp.handlers.PyTreeCheckpointHandler\n )\n handler_registry.add(\n ""model_state"", ocp.args.PyTreeRestore, ocp.handlers.PyTreeCheckpointHandler\n )\n handler_registry.add(\n ""dataloader_state"",\n grain.checkpoint.CheckpointSave,\n cast(ocp.handlers.CheckpointHandler, grain.checkpoint.CheckpointHandler),\n )\n handler_registry.add(\n ""dataloader_state"",\n grain.checkpoint.CheckpointRestore,\n cast(ocp.handlers.CheckpointHandler, grain.checkpoint.CheckpointHandler),\n )\n checkpoint_options = ocp.CheckpointManagerOptions(\n save_interval_steps=args.log_checkpoint_interval,\n max_to_keep=3,\n keep_period=args.log_checkpoint_keep_period,\n step_format_fixed_length=6,\n cleanup_tmp_directories=True,\n )\n checkpoint_manager = ocp.CheckpointManager(\n args.ckpt_dir,\n options=checkpoint_options,\n handler_registry=handler_registry,\n )\n return checkpoint_manager\n\n\ndef restore_checkpoint_if_needed(\n args: Args,\n checkpoint_manager: ocp.CheckpointManager,\n optimizer: nnx.Optimizer,\n grain_iterator: grain.DataLoaderIterator,\n restore_step: Optional[int] = None,\n) -> tuple[int, nnx.Optimizer, grain.DataLoaderIterator]:\n step = 0\n if restore_step is None:\n restore_step = checkpoint_manager.latest_step()\n if args.restore_ckpt:\n abstract_optimizer = nnx.eval_shape(lambda: optimizer)\n abstract_optimizer_state = nnx.state(abstract_optimizer)\n restored = checkpoint_manager.restore(\n restore_step,\n args=ocp.args.Composite(\n model_state=ocp.args.PyTreeRestore(abstract_optimizer_state), # type: ignore\n dataloader_state=grain.checkpoint.CheckpointRestore(grain_iterator), # type: ignore\n ),\n )\n restored_optimizer_state = restored[""model_state""]\n nnx.update(optimizer, restored_optimizer_state)\n grain_iterator = restored[""dataloader_state""]\n step = restore_step or 0\n print(f""Restored dataloader and model state from step {step}"")\n return step, optimizer, grain_iterator\n\n\ndef main(args: Args) -> None:\n jax.distributed.initialize()\n num_devices = jax.device_count()\n if num_devices == 0:\n raise ValueError(""No JAX devices found."")\n print(f""Running on {num_devices} devices."")\n\n if args.batch_size % num_devices != 0:\n raise ValueError(\n f""Global batch size {args.batch_size} must be divisible by ""\n f""number of devices {num_devices}.""\n )\n\n rng = jax.random.key(args.seed)\n\n # --- Initialize model ---\n tokenizer, rng = build_model(args, rng)\n\n _, params, _ = nnx.split(tokenizer, nnx.Param, ...)\n param_counts = count_parameters_by_component(params)\n\n if args.log and jax.process_index() == 0:\n wandb_init_kwargs = {\n ""entity"": args.entity,\n ""project"": args.project,\n ""name"": args.name,\n ""tags"": args.tags,\n ""group"": ""debug"",\n ""config"": args,\n }\n\n if args.wandb_id:\n wandb_init_kwargs.update(\n {\n ""id"": args.wandb_id,\n ""resume"": ""allow"",\n }\n )\n wandb.init(**wandb_init_kwargs)\n\n wandb.config.update({""model_param_count"": param_counts})\n\n print(""Parameter counts:"")\n print(param_counts)\n\n # --- Initialize optimizer ---\n optimizer, lr_schedule = build_optimizer(tokenizer, args)\n del tokenizer\n\n # FIXME: switch to create_hybrid_device_mesh for runs spanning multiple nodes\n mesh, replicated_sharding, videos_sharding = build_mesh_and_sharding(num_devices)\n\n shard_optimizer_states(optimizer, replicated_sharding)\n\n # --- Initialize checkpoint manager ---\n checkpoint_manager = build_checkpoint_manager(args)\n\n # --- Create DataLoaderIterator from dataloader ---\n grain_iterator = build_dataloader(args)\n\n # --- Restore checkpoint ---\n step, optimizer, grain_iterator = restore_checkpoint_if_needed(\n args, checkpoint_manager, optimizer, grain_iterator\n )\n\n # --- Define loss and train step (close over args) ---\n def tokenizer_loss_fn(\n model: TokenizerVQVAE, inputs: dict\n ) -> tuple[jax.Array, tuple[jax.Array, dict]]:\n gt = jnp.asarray(inputs[""videos""], dtype=jnp.float32) / 255.0\n inputs[""videos""] = gt.astype(args.dtype)\n model.train()\n outputs = model(inputs, training=True)\n outputs[""recon""] = outputs[""recon""].astype(jnp.float32)\n mse = jnp.square(gt - outputs[""recon""]).mean()\n q_loss = jnp.square(jax.lax.stop_gradient(outputs[""emb""]) - outputs[""z""]).mean()\n commitment_loss = jnp.square(\n outputs[""emb""] - jax.lax.stop_gradient(outputs[""z""])\n ).mean()\n loss = mse + q_loss + args.vq_beta * commitment_loss\n\n gt_clipped = gt.clip(0, 1).reshape(-1, *gt.shape[2:])\n recon = outputs[""recon""].clip(0, 1).reshape(-1, *outputs[""recon""].shape[2:])\n psnr = jnp.asarray(pix.psnr(gt_clipped, recon)).mean()\n ssim = jnp.asarray(pix.ssim(gt_clipped, recon)).mean()\n _, index_counts = jnp.unique_counts(\n jnp.ravel(outputs[""indices""]), size=args.num_latents, fill_value=0\n )\n codebook_usage = (index_counts != 0).mean()\n metrics = dict(\n loss=loss,\n mse=mse,\n q_loss=q_loss,\n commitment_loss=commitment_loss,\n psnr=psnr,\n ssim=ssim,\n codebook_usage=codebook_usage,\n )\n return loss, (outputs[""recon""], metrics)\n\n @nnx.jit(donate_argnums=0)\n def train_step(\n optimizer: nnx.Optimizer, inputs: dict\n ) -> tuple[jax.Array, jax.Array, dict]:\n def loss_fn(model: TokenizerVQVAE) -> tuple[jax.Array, tuple[jax.Array, dict]]:\n return tokenizer_loss_fn(model, inputs)\n\n (loss, (recon, metrics)), grads = nnx.value_and_grad(loss_fn, has_aux=True)(\n optimizer.model\n )\n optimizer.update(grads)\n if args.log_gradients:\n metrics[""encoder_gradients_std/""] = jax.tree.map(\n lambda x: x.std(), grads[""params""][""encoder""]\n )\n metrics[""vq_gradients_std/""] = jax.tree.map(\n lambda x: x.std(), grads[""params""][""vq""]\n )\n metrics[""decoder_gradients_std/""] = jax.tree.map(\n lambda x: x.std(), grads[""params""][""decoder""]\n )\n return loss, recon, metrics\n\n # --- TRAIN LOOP ---\n dataloader = (\n jax.make_array_from_process_local_data(videos_sharding, elem)\n for elem in grain_iterator\n )\n if jax.process_index() == 0:\n first_videos = next(dataloader)\n sample_inputs = dict(videos=first_videos)\n compiled = train_step.lower(optimizer, sample_inputs).compile()\n print_compiled_memory_stats(compiled.memory_analysis())\n print_compiled_cost_analysis(compiled.cost_analysis())\n # Do not skip the first batch during training\n dataloader = itertools.chain([first_videos], dataloader)\n print(f""Starting training from step {step}..."")\n first_step = step\n while step < args.num_steps:\n for videos in dataloader:\n # --- Train step ---\n inputs = dict(videos=videos)\n loss, recon, metrics = train_step(optimizer, inputs)\n if step == first_step:\n print_mem_stats(""After params initialized"")\n metrics[""lr""] = lr_schedule(step)\n print(f""Step {step}, loss: {loss}"")\n step += 1\n\n # --- Logging ---\n if args.log:\n if step % args.log_interval == 0 and jax.process_index() == 0:\n wandb.log(\n {\n ""loss"": loss,\n ""step"": step,\n **metrics,\n }\n )\n if step % args.log_image_interval == 0:\n gt_seq = inputs[""videos""][0].astype(jnp.float32) / 255.0\n recon_seq = recon[0].clip(0, 1)\n comparison_seq = jnp.concatenate((gt_seq, recon_seq), axis=1)\n comparison_seq = einops.rearrange(\n comparison_seq * 255, ""t h w c -> h (t w) c""\n )\n # NOTE: Process-dependent control flow deliberately happens\n # after indexing operation since it must not contain code\n # sections that lead to cross-accelerator communication.\n if jax.process_index() == 0:\n log_images = dict(\n image=wandb.Image(np.asarray(gt_seq[0])),\n recon=wandb.Image(np.asarray(recon_seq[0])),\n true_vs_recon=wandb.Image(\n np.asarray(comparison_seq.astype(np.uint8))\n ),\n )\n wandb.log(log_images)\n # --- Checkpointing ---\n if args.save_ckpt and step % args.log_checkpoint_interval == 0:\n optimizer_state = nnx.state(optimizer)\n checkpoint_manager.save(\n step,\n args=ocp.args.Composite(\n model_state=ocp.args.PyTreeSave(optimizer_state), # type: ignore\n dataloader_state=grain.checkpoint.CheckpointSave( # type: ignore\n grain_iterator # type: ignore\n ),\n ),\n )\n print(f""Saved checkpoint at step {step}"")\n if step >= args.num_steps:\n break\n\n checkpoint_manager.close()\n\n\nif __name__ == ""__main__"":\n args = tyro.cli(Args)\n main(args)\n",python,tab
|
| 22 |
+
21,17040,"train_tokenizer.py",10,0,"",python,selection_command
|
| 23 |
+
22,17279,"train_tokenizer.py",11,0,"",python,selection_command
|
| 24 |
+
23,17319,"train_tokenizer.py",41,0,"",python,selection_command
|
| 25 |
+
24,17369,"train_tokenizer.py",87,0,"",python,selection_command
|
| 26 |
+
25,17389,"train_tokenizer.py",91,0,"",python,selection_command
|
| 27 |
+
26,17406,"train_tokenizer.py",153,0,"",python,selection_command
|
| 28 |
+
27,17436,"train_tokenizer.py",181,0,"",python,selection_command
|
| 29 |
+
28,17491,"train_tokenizer.py",235,0,"",python,selection_command
|
| 30 |
+
29,17521,"train_tokenizer.py",282,0,"",python,selection_command
|
| 31 |
+
30,17569,"train_tokenizer.py",284,0,"",python,selection_command
|
| 32 |
+
31,17591,"train_tokenizer.py",285,0,"",python,selection_command
|
| 33 |
+
32,17884,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"",Log,tab
|
| 34 |
+
33,22761,"train_tokenizer.py",0,0,"",python,tab
|
| 35 |
+
34,22763,"TERMINAL",0,0,"",,terminal_focus
|
| 36 |
+
35,23941,"TERMINAL",0,0,"source /home/franz.srambical/jafar/.venv/bin/activate",,terminal_command
|
| 37 |
+
36,26286,"TERMINAL",0,0,"squeue",,terminal_command
|
| 38 |
+
37,26302,"TERMINAL",0,0,"]633;C JOBID USER PARTITION NODES CPUS ST SUBMIT_TIME START_TIME TIME TIME_LIMIT NODELIST(REASON)\r\n]0;franz.srambical@hai-login2:~/jafar",,terminal_output
|
| 39 |
+
38,28574,"TERMINAL",0,0,"salloc --gpus=1 --ntasks-per-node=1 --cpus-per-task=1 --mem=100G",,terminal_command
|
| 40 |
+
39,28659,"TERMINAL",0,0,"]633;Csalloc: Granted job allocation 23456\r\nsalloc: Nodes hai001 are ready for job\r\n",,terminal_output
|
| 41 |
+
40,29034,"TERMINAL",0,0,"Running inside SLURM, Job ID 23456.\r\n",,terminal_output
|
| 42 |
+
41,29121,"TERMINAL",0,0,"]0;franz.srambical@hai-login2:~/jafar[?2004h[franz.srambical@hai001.haicore.berlin:~/jafar] $ ",,terminal_output
|
| 43 |
+
42,33463,"TERMINAL",0,0,"\r(reverse-i-search)`': [K",,terminal_output
|
| 44 |
+
43,33751,"TERMINAL",0,0,"t': salloc --gpus=1 --ntasks-per-node=1 --cpus-per-[7mt[27mask=1 --mem=100G",,terminal_output
|
| 45 |
+
44,33926,"TERMINAL",0,0,"\r[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Co': python3 -m MaxText.train MaxText/configs/base.yml run_name=h100_mfu_340m hardware=gpu dataset_type=synthetic steps=60 log_period=1 enable_checkpointing=False gcs_metrics=False metrics_file=/tmp/h100_mfu_metrics.jsonl base_output_directory=/tmp/maxtext attention=au[7mto[27mselected per_device_batch_size=4 base_emb_dim=1536 base_num_query_heads=12 base_num_kv_heads=12 base_mlp_dim=4096 base_num_decoder_layers=10 head_dim=128 logits_via_embedding=True[A[A[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[A\r[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[96Pk': bash experiments/dynamics_grain_[7mtok[27m_restore.sh \r\n\r[K\r\n\r[K\r\n\r[K[A[A[A[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C",,terminal_output
|
| 46 |
+
45,34009,"TERMINAL",0,0,"\r[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[4@e': bash experiments/[7mtoke[27mnizer_grain_checkpointing",,terminal_output
|
| 47 |
+
46,34619,"TERMINAL",0,0,"\r[24@[franz.srambical@hai001.haicore.berlin:~/jafar] $ bash experiments/toke[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C",,terminal_output
|
| 48 |
+
47,34841,"TERMINAL",0,0,"\r\n[?2004l\r",,terminal_output
|
| 49 |
+
48,36266,"TERMINAL",0,0,"^Csrun: interrupt (one more within 1 sec to abort)\r\nsrun: StepId=23456.0 task 0: running\r\n",,terminal_output
|
| 50 |
+
49,36411,"TERMINAL",0,0,"^Csrun: sending Ctrl-C to StepId=23456.0\r\nsrun: forcing job termination\r\nTraceback (most recent call last):\r\n File ""/fast/home/franz.srambical/jafar/train_tokenizer.py"", line 19, in <module>\r\n import optax\r\n File ""/fast/home/franz.srambical/jafar/.venv/lib/python3.10/site-packages/optax/__init__.py"", line 23, in <module>\r\nsrun: Job step aborted: Waiting up to 32 seconds for job step to finish.\r\n from optax import contrib\r\n File ""/fast/home/franz.srambical/jafar/.venv/lib/python3.10/site-packages/optax/contrib/__init__.py"", line 19, in <module>\r\n[2025-08-25T10:53:18.671] error: *** STEP 23456.0 ON hai001 CANCELLED AT 2025-08-25T10:53:18 DUE to SIGNAL Killed ***\r\n from optax.contrib._acprop import acprop\r\n]0;franz.srambical@hai-login2:~/jafar[?2004h[franz.srambical@hai001.haicore.berlin:~/jafar] $ ",,terminal_output
|
| 51 |
+
50,55421,"train_tokenizer.py",0,0,"Switched from branch 'tokenizer-fwd-half-precision' to 'simplified-param-calculation'",python,git_branch_checkout
|
| 52 |
+
51,60005,"TERMINAL",0,0,"bash experiments/tokenizer_grain_checkpointing.sh ",,terminal_output
|
| 53 |
+
52,60162,"TERMINAL",0,0,"\r\n[?2004l\r",,terminal_output
|
| 54 |
+
53,65422,"TERMINAL",0,0,"2025-08-25 10:53:47.689852: F external/xla/xla/parse_flags_from_env.cc:234] Unknown flag in XLA_FLAGS: --xla_gpu_enable_async_collectives=true\r\n",,terminal_output
|
| 55 |
+
54,70894,"TERMINAL",0,0,"srun: error: hai001: task 0: Aborted (core dumped)\r\n]0;franz.srambical@hai-login2:~/jafar[?2004h[franz.srambical@hai001.haicore.berlin:~/jafar] $ ",,terminal_output
|
| 56 |
+
55,71219,"TERMINAL",0,0,"^C[?2004l\r[?2004h[?2004l\r\r\n]0;franz.srambical@hai-login2:~/jafar[?2004h[franz.srambical@hai001.haicore.berlin:~/jafar] $ ",,terminal_output
|
| 57 |
+
56,72219,"train_tokenizer.py",284,0,"",python,selection_command
|
| 58 |
+
57,72346,"train_tokenizer.py",282,0,"",python,selection_command
|
| 59 |
+
58,72499,"train_tokenizer.py",235,0,"",python,selection_command
|
| 60 |
+
59,72659,"train_tokenizer.py",181,0,"",python,selection_command
|
| 61 |
+
60,72799,"train_tokenizer.py",153,0,"",python,selection_command
|
| 62 |
+
61,73289,"train_tokenizer.py",153,27,"os.environ['XLA_FLAGS'] = (",python,selection_command
|
| 63 |
+
62,73379,"train_tokenizer.py",153,0,"",python,selection_command
|
| 64 |
+
63,73554,"train_tokenizer.py",181,0,"",python,selection_command
|
| 65 |
+
64,74004,"train_tokenizer.py",153,0,"",python,selection_command
|
| 66 |
+
65,74219,"train_tokenizer.py",153,27,"os.environ['XLA_FLAGS'] = (",python,selection_command
|
| 67 |
+
66,74299,"train_tokenizer.py",153,81,"os.environ['XLA_FLAGS'] = (\n '--xla_gpu_enable_latency_hiding_scheduler=true '",python,selection_command
|
| 68 |
+
67,74444,"train_tokenizer.py",153,128,"os.environ['XLA_FLAGS'] = (\n '--xla_gpu_enable_latency_hiding_scheduler=true '\n '--xla_gpu_enable_async_collectives=true '",python,selection_command
|
| 69 |
+
68,74599,"train_tokenizer.py",153,130,"os.environ['XLA_FLAGS'] = (\n '--xla_gpu_enable_latency_hiding_scheduler=true '\n '--xla_gpu_enable_async_collectives=true '\n)",python,selection_command
|
| 70 |
+
69,76005,"train_tokenizer.py",282,0,"# ",python,content
|
| 71 |
+
70,76005,"train_tokenizer.py",235,0,"# ",python,content
|
| 72 |
+
71,76005,"train_tokenizer.py",181,0,"# ",python,content
|
| 73 |
+
72,76005,"train_tokenizer.py",153,0,"# ",python,content
|
| 74 |
+
73,76272,"train_tokenizer.py",288,0,"",python,selection_command
|
| 75 |
+
74,77492,"TERMINAL",0,0,"bash experiments/tokenizer_grain_checkpointing.sh ",,terminal_output
|
| 76 |
+
75,77831,"TERMINAL",0,0,"\r\n[?2004l\r",,terminal_output
|
| 77 |
+
76,82227,"TERMINAL",0,0,"Running on 1 devices.\r\n",,terminal_output
|
| 78 |
+
77,86097,"TERMINAL",0,0,"Counting all components: ['decoder', 'encoder', 'vq']\r\nParameter counts:\r\n{'decoder': 16858736, 'encoder': 16858752, 'vq': 32768, 'total': 33750256}\r\n",,terminal_output
|
| 79 |
+
78,117375,"TERMINAL",0,0,"^Csrun: interrupt (one more within 1 sec to abort)\r\nsrun: StepId=23456.2 task 0: running\r\n",,terminal_output
|
| 80 |
+
79,126879,"TERMINAL",0,0,"2025-08-25 10:54:48.958239: E external/xla/xla/stream_executor/cuda/cuda_timer.cc:86] Delay kernel timed out: measured time has sub-optimal accuracy. There may be a missing warmup execution, please investigate in Nsight Systems.\r\n",,terminal_output
|
| 81 |
+
80,126979,"TERMINAL",0,0,"2025-08-25 10:54:49.236371: E external/xla/xla/stream_executor/cuda/cuda_timer.cc:86] Delay kernel timed out: measured time has sub-optimal accuracy. There may be a missing warmup execution, please investigate in Nsight Systems.\r\n",,terminal_output
|
| 82 |
+
81,136850,"TERMINAL",0,0,"Total memory size: 9.5 GB, Output size: 0.4 GB, Temp size: 9.0 GB, Argument size: 0.4 GB, Host temp size: 0.0 GB.\r\nFLOPs: 3.306e+11, Bytes: 2.483e+11 (231.2 GB), Intensity: 1.3 FLOPs/byte\r\nStarting training from step 0...\r\n",,terminal_output
|
| 83 |
+
82,137039,"TERMINAL",0,0,"\r\nMemstats: After params initialized:\r\n\tUsing (GB) 0.44 / 59.39 (0.740865%) on cuda:0\r\n",,terminal_output
|
| 84 |
+
83,137484,"TERMINAL",0,0,"Step 0, loss: 0.25431719422340393\r\n",,terminal_output
|
| 85 |
+
84,152028,"TERMINAL",0,0,"Step 1, loss: 0.2657988965511322\r\n",,terminal_output
|
| 86 |
+
85,152324,"TERMINAL",0,0,"Step 2, loss: 0.27664220333099365\r\n",,terminal_output
|
| 87 |
+
86,154001,"TERMINAL",0,0,"Step 3, loss: 0.2549745738506317\r\n",,terminal_output
|
| 88 |
+
87,154002,"TERMINAL",0,0,"Step 4, loss: 0.23929359018802643\r\nSaved checkpoint at step 5\r\n",,terminal_output
|
| 89 |
+
88,154058,"TERMINAL",0,0,"Step 5, loss: 0.22147467732429504\r\n",,terminal_output
|
| 90 |
+
89,154576,"TERMINAL",0,0,"Step 6, loss: 0.21243974566459656\r\n",,terminal_output
|
| 91 |
+
90,155068,"TERMINAL",0,0,"Step 7, loss: 0.20390529930591583\r\n",,terminal_output
|
| 92 |
+
91,155888,"TERMINAL",0,0,"Step 8, loss: 0.2014799565076828\r\n",,terminal_output
|
| 93 |
+
92,156305,"TERMINAL",0,0,"Step 9, loss: 0.19134578108787537\r\nSaved checkpoint at step 10\r\n",,terminal_output
|
| 94 |
+
93,156697,"TERMINAL",0,0,"Step 10, loss: 0.1849638819694519\r\n",,terminal_output
|
| 95 |
+
94,157169,"TERMINAL",0,0,"Step 11, loss: 0.18320240080356598\r\n",,terminal_output
|
| 96 |
+
95,157528,"TERMINAL",0,0,"Step 12, loss: 0.17448516190052032\r\n",,terminal_output
|
| 97 |
+
96,157928,"TERMINAL",0,0,"Step 13, loss: 0.1701081246137619\r\n",,terminal_output
|
| 98 |
+
97,158527,"TERMINAL",0,0,"Step 14, loss: 0.16334110498428345\r\nSaved checkpoint at step 15\r\n",,terminal_output
|
| 99 |
+
98,159169,"TERMINAL",0,0,"Step 15, loss: 0.1604066789150238\r\n",,terminal_output
|
| 100 |
+
99,159681,"TERMINAL",0,0,"Step 16, loss: 0.15722087025642395\r\n",,terminal_output
|
| 101 |
+
100,160269,"TERMINAL",0,0,"Step 17, loss: 0.15154121816158295\r\n",,terminal_output
|
| 102 |
+
101,160769,"TERMINAL",0,0,"Step 18, loss: 0.14370152354240417\r\n",,terminal_output
|
| 103 |
+
102,161329,"TERMINAL",0,0,"Step 19, loss: 0.13980640470981598\r\nSaved checkpoint at step 20\r\n",,terminal_output
|
| 104 |
+
103,162026,"TERMINAL",0,0,"Step 20, loss: 0.13828369975090027\r\n",,terminal_output
|
| 105 |
+
104,162689,"TERMINAL",0,0,"Step 21, loss: 0.13768532872200012\r\n",,terminal_output
|
| 106 |
+
105,163123,"TERMINAL",0,0,"Step 22, loss: 0.13598142564296722\r\n",,terminal_output
|
| 107 |
+
106,163964,"TERMINAL",0,0,"Step 23, loss: 0.13169215619564056\r\n",,terminal_output
|
| 108 |
+
107,164595,"TERMINAL",0,0,"Step 24, loss: 0.12741072475910187\r\nSaved checkpoint at step 25\r\n",,terminal_output
|
| 109 |
+
108,165523,"TERMINAL",0,0,"Step 25, loss: 0.12643606960773468\r\n",,terminal_output
|
| 110 |
+
109,166271,"TERMINAL",0,0,"Step 26, loss: 0.1263691782951355\r\n",,terminal_output
|
| 111 |
+
110,166866,"TERMINAL",0,0,"Step 27, loss: 0.12507067620754242\r\n",,terminal_output
|
| 112 |
+
111,167584,"TERMINAL",0,0,"Step 28, loss: 0.1210612878203392\r\n",,terminal_output
|
| 113 |
+
112,168160,"TERMINAL",0,0,"Step 29, loss: 0.11947143077850342\r\nSaved checkpoint at step 30\r\n",,terminal_output
|
| 114 |
+
113,168656,"TERMINAL",0,0,"Step 30, loss: 0.11961992084980011\r\n",,terminal_output
|
| 115 |
+
114,169241,"TERMINAL",0,0,"Step 31, loss: 0.11844073981046677\r\n",,terminal_output
|
| 116 |
+
115,170428,"TERMINAL",0,0,"Step 32, loss: 0.11614794284105301\r\n",,terminal_output
|
| 117 |
+
116,170429,"TERMINAL",0,0,"Step 33, loss: 0.11374820023775101\r\n",,terminal_output
|
| 118 |
+
117,171149,"TERMINAL",0,0,"^Csrun: interrupt (one more within 1 sec to abort)\r\nsrun: StepId=23456.2 task 0: running\r\n^Csrun: sending Ctrl-C to StepId=23456.2\r\nsrun: forcing job termination\r\nsrun: Job step aborted: Waiting up to 32 seconds for job step to finish.\r\n[2025-08-25T10:55:33.214] error: *** STEP 23456.2 ON hai001 CANCELLED AT 2025-08-25T10:55:33 DUE to SIGNAL Killed ***\r\n",,terminal_output
|
| 119 |
+
118,171645,"TERMINAL",0,0,"]0;franz.srambical@hai-login2:~/jafar[?2004h[franz.srambical@hai001.haicore.berlin:~/jafar] $ ^C[?2004l\r[?2004h[?2004l\r\r\n]0;franz.srambical@hai-login2:~/jafar[?2004h[franz.srambical@hai001.haicore.berlin:~/jafar] $ ",,terminal_output
|
1f15334ab7e6820c9fda17c961659882ef9853cc80f7356b9a9b22f286fd7389/crowd-code-eb393a0e-6aef-412a-bef0-408ff847ad2c1764928526101-2025_12_05-10.55.35.367/source.csv
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
2,503,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"10:55:35 AM [info] Activating crowd-code\n10:55:35 AM [info] Recording started\n10:55:35 AM [info] Initializing git provider using file system watchers...\n10:55:35 AM [info] Git repository found\n10:55:35 AM [info] Git provider initialized successfully\n10:55:35 AM [info] Initial git state: [object Object]\n",Log,tab
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-02f1e1f4-094a-4d7b-957e-88354d5de1001754231283463-2025_08_03-16.28.12.317/source.csv
ADDED
|
@@ -0,0 +1,515 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
2,690,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"4:28:12 PM [info] Activating crowd-code\n4:28:12 PM [info] Recording started\n4:28:12 PM [info] Initializing git provider using file system watchers...\n4:28:12 PM [info] Git repository found\n4:28:12 PM [info] Git provider initialized successfully\n",Log,tab
|
| 3 |
+
3,853,"extension-output-pdoom-org.crowd-code-#1-crowd-code",245,0,"4:28:13 PM [info] Initial git state: [object Object]\n",Log,content
|
| 4 |
+
4,4654,"TERMINAL",0,0,"queue",,terminal_command
|
| 5 |
+
5,4724,"TERMINAL",0,0,"]633;E;2025-08-03 16:28:16 queue;1fa2723a-e415-422b-a7e2-4358520da61a]633;C[?1049h[22;0;0t[1;31r(B[m[4l[?7h[H[2JEvery 1.0s: squeue --me[1;101Hhkn1991.localdomain: Sun Aug 3 16:28:16 2025[3;14HJOBID PARTITION NAME USER ST\tTIME NODES NODELIST(REASON)[4;12H3388151 accelerat train_to tum_cte0 R 7:25:27\t 2 hkn[0533-0534][5;12H3388153 accelerat train_to tum_cte0 R 7:25:27\t 2 hkn[0717-0718][6;12H3393066 accelerat train_dy tum_cte0 R 4:10:10 12 hkn[0701-0712][7;12H3393065 accelerat train_dy tum_cte0 R 4:12:20\t 3 hkn[0808-0810][31;145H",,terminal_output
|
| 6 |
+
6,5767,"TERMINAL",0,0,"bash",,terminal_focus
|
| 7 |
+
7,5768,"TERMINAL",0,0,"[1;140H7[4;60H8[5d8[6d1[7d1[31;145H",,terminal_output
|
| 8 |
+
8,6238,"TERMINAL",0,0,"watch",,terminal_focus
|
| 9 |
+
9,6804,"TERMINAL",0,0,"[1;140H8[4;59H30[5d30[6d3[7d3[31;145H",,terminal_output
|
| 10 |
+
10,7849,"TERMINAL",0,0,"[1;139H20[4;60H1[5d1[6d4[7d4[31;145H",,terminal_output
|
| 11 |
+
11,8886,"TERMINAL",0,0,"[1;140H1[4;60H2[5d2[6d5[7d5[31;145H",,terminal_output
|
| 12 |
+
12,9718,"TERMINAL",0,0,"[31;1H[?1049l[23;0;0t\r[?1l>]0;tum_cte0515@hkn1991:~/Projects/tmp/jafar]633;D;0",,terminal_output
|
| 13 |
+
13,39964,"TERMINAL",0,0,"source ../../jafar/.venv/bin/activate",,terminal_command
|
| 14 |
+
14,40007,"TERMINAL",0,0,"]633;E;2025-08-03 16:28:52 source ../../jafar/.venv/bin/activate;1fa2723a-e415-422b-a7e2-4358520da61a]633;C]0;tum_cte0515@hkn1991:~/Projects/tmp/jafar]633;D;0",,terminal_output
|
| 15 |
+
15,45211,"TERMINAL",0,0,"bash",,terminal_focus
|
| 16 |
+
16,46116,"TERMINAL",0,0,"../../jafar/.venv/bin/activate",,terminal_command
|
| 17 |
+
17,50378,"TERMINAL",0,0,"source ../../jafar/.venv/bin/activate",,terminal_command
|
| 18 |
+
18,51001,"TERMINAL",0,0,"bash",,terminal_focus
|
| 19 |
+
19,53162,"sample.py",0,0,"from dataclasses import dataclass\nimport time\n\nimport dm_pix as pix\nimport einops\nimport jax\nimport jax.numpy as jnp\nimport flax.linen as nn\nimport numpy as np\nfrom orbax.checkpoint import PyTreeCheckpointer\nfrom PIL import Image, ImageDraw\nimport tyro\n\nfrom genie import Genie\nfrom utils.dataloader import get_dataloader\n\n\n@dataclass\nclass Args:\n # Experiment\n seed: int = 0\n seq_len: int = 16\n image_channels: int = 3\n image_resolution: int = 64\n data_dir: str = ""data/coinrun_episodes""\n checkpoint: str = """"\n # Sampling\n batch_size: int = 1\n maskgit_steps: int = 25\n temperature: float = 1.0\n sample_argmax: bool = True\n start_frame: int = 0\n # Tokenizer checkpoint\n tokenizer_dim: int = 512\n latent_patch_dim: int = 32\n num_patch_latents: int = 1024\n patch_size: int = 4\n tokenizer_num_blocks: int = 8\n tokenizer_num_heads: int = 8\n # LAM checkpoint\n lam_dim: int = 512\n latent_action_dim: int = 32\n num_latent_actions: int = 6\n lam_patch_size: int = 16\n lam_num_blocks: int = 8\n lam_num_heads: int = 8\n # Dynamics checkpoint\n dyna_dim: int = 512\n dyna_num_blocks: int = 12\n dyna_num_heads: int = 8\n\n\nargs = tyro.cli(Args)\nrng = jax.random.PRNGKey(args.seed)\n\n# --- Load Genie checkpoint ---\ngenie = Genie(\n # Tokenizer\n in_dim=args.image_channels,\n tokenizer_dim=args.tokenizer_dim,\n latent_patch_dim=args.latent_patch_dim,\n num_patch_latents=args.num_patch_latents,\n patch_size=args.patch_size,\n tokenizer_num_blocks=args.tokenizer_num_blocks,\n tokenizer_num_heads=args.tokenizer_num_heads,\n # LAM\n lam_dim=args.lam_dim,\n latent_action_dim=args.latent_action_dim,\n num_latent_actions=args.num_latent_actions,\n lam_patch_size=args.lam_patch_size,\n lam_num_blocks=args.lam_num_blocks,\n lam_num_heads=args.lam_num_heads,\n # Dynamics\n dyna_dim=args.dyna_dim,\n dyna_num_blocks=args.dyna_num_blocks,\n dyna_num_heads=args.dyna_num_heads,\n)\nrng, _rng = jax.random.split(rng)\nimage_shape = (args.image_resolution, args.image_resolution, args.image_channels)\ndummy_inputs = dict(\n videos=jnp.zeros((args.batch_size, args.seq_len, *image_shape), dtype=jnp.float32),\n mask_rng=_rng,\n)\nrng, _rng = jax.random.split(rng)\nparams = genie.init(_rng, dummy_inputs)\nckpt = PyTreeCheckpointer().restore(args.checkpoint)[""model""][""params""][""params""]\nparams[""params""].update(ckpt)\n\n\ndef _sampling_wrapper(module, batch):\n return module.sample(batch, args.seq_len, args.maskgit_steps, args.temperature, args.sample_argmax)\n\n# --- Define autoregressive sampling loop ---\ndef _autoreg_sample(rng, video_batch, action_batch):\n vid = video_batch[:, : args.start_frame + 1]\n sampling_fn = jax.jit(nn.apply(_sampling_wrapper, genie)) \n rng, _rng = jax.random.split(rng)\n batch = dict(videos=vid, latent_actions=action_batch, rng=_rng)\n generated_vid = sampling_fn(\n params,\n batch\n )\n return generated_vid\n\n\n# --- Get video + latent actions ---\ndataloader = get_dataloader(args.data_dir, args.seq_len, args.batch_size)\nvideo_batch = next(iter(dataloader))\n# Get latent actions from first video only\nfirst_video = video_batch[:1]\nbatch = dict(videos=first_video)\naction_batch = genie.apply(params, batch, False, method=Genie.vq_encode)\naction_batch = action_batch.reshape(1, args.seq_len - 1, 1)\n# Use actions from first video for all videos\naction_batch = jnp.repeat(action_batch, video_batch.shape[0], axis=0)\n\n# --- Sample + evaluate video ---\nvid = _autoreg_sample(rng, video_batch, action_batch)\ngt = video_batch[:, : vid.shape[1]].clip(0, 1).reshape(-1, *video_batch.shape[2:])\nrecon = vid.clip(0, 1).reshape(-1, *vid.shape[2:])\nssim = pix.ssim(gt[:, args.start_frame + 1 :], recon[:, args.start_frame + 1 :]).mean()\nprint(f""SSIM: {ssim}"")\n\n# --- Construct video ---\nfirst_true = (video_batch[0:1] * 255).astype(np.uint8)\nfirst_pred = (vid[0:1] * 255).astype(np.uint8)\nfirst_video_comparison = np.zeros((2, *vid.shape[1:5]), dtype=np.uint8)\nfirst_video_comparison[0] = first_true[:, : vid.shape[1]]\nfirst_video_comparison[1] = first_pred\n# For other videos, only show generated video\nother_preds = (vid[1:] * 255).astype(np.uint8)\nall_frames = np.concatenate([first_video_comparison, other_preds], axis=0)\nflat_vid = einops.rearrange(all_frames, ""n t h w c -> t h (n w) c"")\n\n# --- Save video ---\nimgs = [Image.fromarray(img) for img in flat_vid]\n# Write actions on each frame\nfor img, action in zip(imgs[1:], action_batch[0, :, 0]):\n d = ImageDraw.Draw(img)\n d.text((2, 2), f""{action}"", fill=255)\nimgs[0].save(\n f""generation_{time.time()}.gif"",\n save_all=True,\n append_images=imgs[1:],\n duration=250,\n loop=0,\n)\n",python,tab
|
| 20 |
+
20,57765,"genie.py",0,0,"from typing import Dict, Any\n\nfrom orbax.checkpoint import PyTreeCheckpointer\nimport jax\nimport jax.numpy as jnp\nimport flax.linen as nn\n\nfrom models.dynamics import DynamicsMaskGIT\nfrom models.lam import LatentActionModel\nfrom models.tokenizer import TokenizerVQVAE\n\n\nclass Genie(nn.Module):\n """"""Genie model""""""\n\n # --- Tokenizer ---\n in_dim: int\n tokenizer_dim: int\n latent_patch_dim: int\n num_patch_latents: int\n patch_size: int\n tokenizer_num_blocks: int\n tokenizer_num_heads: int\n # --- LAM ---\n lam_dim: int\n latent_action_dim: int\n num_latent_actions: int\n lam_patch_size: int\n lam_num_blocks: int\n lam_num_heads: int\n # --- Dynamics ---\n dyna_dim: int\n dyna_num_blocks: int\n dyna_num_heads: int\n dropout: float = 0.0\n mask_limit: float = 0.0\n\n def setup(self):\n self.tokenizer = TokenizerVQVAE(\n in_dim=self.in_dim,\n model_dim=self.tokenizer_dim,\n latent_dim=self.latent_patch_dim,\n num_latents=self.num_patch_latents,\n patch_size=self.patch_size,\n num_blocks=self.tokenizer_num_blocks,\n num_heads=self.tokenizer_num_heads,\n dropout=0.0,\n codebook_dropout=0.0,\n )\n self.lam = LatentActionModel(\n in_dim=self.in_dim,\n model_dim=self.lam_dim,\n latent_dim=self.latent_patch_dim,\n num_latents=self.num_latent_actions,\n patch_size=self.lam_patch_size,\n num_blocks=self.lam_num_blocks,\n num_heads=self.lam_num_heads,\n dropout=0.0,\n codebook_dropout=0.0,\n )\n self.dynamics = DynamicsMaskGIT(\n model_dim=self.dyna_dim,\n num_latents=self.num_patch_latents,\n num_blocks=self.dyna_num_blocks,\n num_heads=self.dyna_num_heads,\n dropout=self.dropout,\n mask_limit=self.mask_limit,\n )\n\n def __call__(self, batch: Dict[str, Any], training: bool = True) -> Dict[str, Any]:\n tokenizer_outputs = self.tokenizer.vq_encode(batch[""videos""], training=False)\n lam_outputs = self.lam.vq_encode(batch[""videos""], training=False)\n outputs = dict(\n video_tokens=jax.lax.stop_gradient(tokenizer_outputs[""indices""]),\n latent_actions=jax.lax.stop_gradient(lam_outputs[""z_q""]),\n )\n outputs[""mask_rng""] = batch[""mask_rng""]\n dyna_outputs = self.dynamics(outputs, training)\n outputs.update(dyna_outputs)\n mle_indices = jnp.argmax(outputs[""token_logits""], axis=-1)\n outputs[""recon""] = self.tokenizer.decode(\n mle_indices, batch[""videos""].shape[2:4]\n )\n return outputs\n \n\n @nn.compact\n def sample(\n self,\n batch: Dict[str, Any],\n steps: int = 25,\n temperature: int = 1,\n sample_argmax: bool = False,\n ) -> Any:\n # --- Encode videos and actions ---\n tokenizer_out = self.tokenizer.vq_encode(batch[""videos""], training=False)\n token_idxs = tokenizer_out[""indices""]\n new_frame_idxs = jnp.zeros_like(token_idxs)[:, 0]\n action_tokens = self.lam.vq.get_codes(batch[""latent_actions""])\n\n # --- Initialize MaskGIT ---\n init_mask = jnp.ones_like(token_idxs, dtype=bool)[:, 0]\n init_carry = (\n batch[""rng""],\n new_frame_idxs,\n init_mask,\n token_idxs,\n action_tokens,\n )\n MaskGITLoop = nn.scan(\n MaskGITStep,\n variable_broadcast=""params"",\n split_rngs={""params"": False},\n in_axes=0,\n out_axes=0,\n length=steps,\n )\n\n # --- Run MaskGIT loop ---\n loop_fn = MaskGITLoop(\n dynamics=self.dynamics,\n tokenizer=self.tokenizer,\n temperature=temperature,\n sample_argmax=sample_argmax,\n steps=steps,\n )\n final_carry, _ = loop_fn(init_carry, jnp.arange(steps))\n new_frame_idxs = final_carry[1]\n new_frame_pixels = self.tokenizer.decode(\n jnp.expand_dims(new_frame_idxs, 1),\n video_hw=batch[""videos""].shape[2:4],\n )\n return new_frame_pixels\n\n def vq_encode(self, batch, training) -> Dict[str, Any]:\n # --- Preprocess videos ---\n lam_output = self.lam.vq_encode(batch[""videos""], training=training)\n return lam_output[""indices""]\n\nclass MaskGITStep(nn.Module):\n dynamics: nn.Module\n tokenizer: nn.Module\n temperature: float\n sample_argmax: bool\n steps: int\n\n @nn.compact\n def __call__(self, carry, x):\n rng, token_idxs, mask, action_tokens = carry\n step = x\n N = token_idxs.shape[2]\n\n # --- Construct + encode video ---\n vid_embed = self.dynamics.patch_embed(token_idxs) # (B, S, N, D)\n mask_token = self.dynamics.mask_token # (1, 1, 1, D,)\n mask_expanded = mask[..., None] # (B, S, N, 1) \n vid_embed = jnp.where(mask_expanded, mask_token, vid_embed)\n\n # --- Predict transition ---\n act_embed = self.dynamics.action_up(action_tokens)\n vid_embed += jnp.pad(act_embed, ((0, 0), (1, 0), (0, 0), (0, 0)))\n unmasked_ratio = jnp.cos(jnp.pi * (step + 1) / (self.steps * 2))\n step_temp = self.temperature * (1.0 - unmasked_ratio)\n final_logits = self.dynamics.dynamics(vid_embed) / step_temp\n\n # --- Sample new tokens for final frame ---\n if self.sample_argmax:\n sampled_token_idxs = jnp.argmax(final_logits, axis=-1)\n else:\n rng, _rng = jax.random.split(rng)\n sampled_token_idxs = jnp.where(\n step == self.steps - 1,\n jnp.argmax(final_logits, axis=-1),\n jax.random.categorical(_rng, final_logits),\n )\n gather_fn = jax.vmap(jax.vmap(jax.vmap(lambda x, y: x[y])))\n final_token_probs = gather_fn(jax.nn.softmax(final_logits), sampled_token_idxs)\n final_token_probs += ~mask\n # Update masked tokens only\n token_idxs = jnp.where(mask, sampled_token_idxs, token_idxs)\n\n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n idx_mask = jnp.arange(final_token_probs.shape[-1]) > num_unmasked_tokens\n sorted_idxs = jnp.argsort(final_token_probs, axis=-1, descending=True)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask))\n new_mask = mask_update_fn(mask, sorted_idxs)\n\n new_carry = (rng, token_idxs, new_mask, action_tokens)\n return new_carry, None\n\ndef restore_genie_components(params: Dict[str, Any], tokenizer: str, lam: str):\n """"""Restore pre-trained Genie components""""""\n params[""params""][""tokenizer""].update(\n PyTreeCheckpointer().restore(tokenizer)[""model""][""params""][""params""]\n )\n params[""params""][""lam""].update(\n PyTreeCheckpointer().restore(lam)[""model""][""params""][""params""]\n )\n return params\n",python,tab
|
| 21 |
+
21,60432,"genie.py",545,0,"",python,selection_mouse
|
| 22 |
+
22,60433,"genie.py",544,0,"",python,selection_command
|
| 23 |
+
23,93412,"genie.py",431,0,"",python,selection_mouse
|
| 24 |
+
24,93414,"genie.py",430,0,"",python,selection_command
|
| 25 |
+
25,96478,"TERMINAL",0,0,"bash",,terminal_focus
|
| 26 |
+
26,123732,"genie.py",315,0,"",python,selection_mouse
|
| 27 |
+
27,128367,"genie.py",136,0,"",python,selection_mouse
|
| 28 |
+
28,128373,"genie.py",135,0,"",python,selection_command
|
| 29 |
+
29,132808,"genie.py",136,0,"\n",python,content
|
| 30 |
+
30,132976,"genie.py",137,0,"i",python,content
|
| 31 |
+
31,132977,"genie.py",138,0,"",python,selection_keyboard
|
| 32 |
+
32,133069,"genie.py",138,0,"m",python,content
|
| 33 |
+
33,133071,"genie.py",139,0,"",python,selection_keyboard
|
| 34 |
+
34,133288,"genie.py",139,0,"p",python,content
|
| 35 |
+
35,133290,"genie.py",140,0,"",python,selection_keyboard
|
| 36 |
+
36,133346,"genie.py",140,0,"o",python,content
|
| 37 |
+
37,133347,"genie.py",141,0,"",python,selection_keyboard
|
| 38 |
+
38,133590,"genie.py",141,0,"r",python,content
|
| 39 |
+
39,133592,"genie.py",142,0,"",python,selection_keyboard
|
| 40 |
+
40,133785,"genie.py",142,0,"t",python,content
|
| 41 |
+
41,133787,"genie.py",143,0,"",python,selection_keyboard
|
| 42 |
+
42,133882,"genie.py",143,0," ",python,content
|
| 43 |
+
43,133885,"genie.py",144,0,"",python,selection_keyboard
|
| 44 |
+
44,134211,"genie.py",144,0,"e",python,content
|
| 45 |
+
45,134212,"genie.py",145,0,"",python,selection_keyboard
|
| 46 |
+
46,134282,"genie.py",145,0,"i",python,content
|
| 47 |
+
47,134283,"genie.py",146,0,"",python,selection_keyboard
|
| 48 |
+
48,134352,"genie.py",146,0,"n",python,content
|
| 49 |
+
49,134355,"genie.py",147,0,"",python,selection_keyboard
|
| 50 |
+
50,134746,"genie.py",147,0,"o",python,content
|
| 51 |
+
51,134748,"genie.py",148,0,"",python,selection_keyboard
|
| 52 |
+
52,134896,"genie.py",148,0,"p",python,content
|
| 53 |
+
53,134898,"genie.py",149,0,"",python,selection_keyboard
|
| 54 |
+
54,134990,"genie.py",149,0,"s",python,content
|
| 55 |
+
55,134992,"genie.py",150,0,"",python,selection_keyboard
|
| 56 |
+
56,135753,"genie.py",149,0,"",python,selection_command
|
| 57 |
+
57,153495,"genie.py",6055,0,"",python,selection_mouse
|
| 58 |
+
58,153498,"genie.py",6054,0,"",python,selection_command
|
| 59 |
+
59,165459,"genie.py",6331,1,">",python,selection_command
|
| 60 |
+
60,169297,"genie.py",6331,0,"",python,selection_command
|
| 61 |
+
61,179994,"TERMINAL",0,0,"git branch",,terminal_command
|
| 62 |
+
62,180037,"TERMINAL",0,0,"]633;E;2025-08-03 16:31:12 git branch;d4f80100-2225-40b3-b029-72e571a8ef11]633;C[?1h=\r* [32mgenie-sampling[m[m\r\n main[m[m\r\n\r[K[?1l>]0;tum_cte0515@hkn1991:~/Projects/tmp/jafar]633;D;0",,terminal_output
|
| 63 |
+
63,180789,"genie.py",3132,0,"",python,selection_mouse
|
| 64 |
+
64,182029,"genie.py",3099,0,"",python,selection_mouse
|
| 65 |
+
65,182080,"genie.py",3098,0,"",python,selection_command
|
| 66 |
+
66,182911,"genie.py",3109,0,"",python,selection_mouse
|
| 67 |
+
67,183049,"genie.py",3108,14,"new_frame_idxs",python,selection_mouse
|
| 68 |
+
68,186845,"genie.py",3356,0,"",python,selection_mouse
|
| 69 |
+
69,193102,"TERMINAL",0,0,"bash",,terminal_focus
|
| 70 |
+
70,194098,"genie.py",0,0,"",python,tab
|
| 71 |
+
71,194801,"TERMINAL",0,0,"bash",,terminal_focus
|
| 72 |
+
72,196629,"TERMINAL",0,0,"git diff",,terminal_command
|
| 73 |
+
73,196687,"TERMINAL",0,0,"]633;E;2025-08-03 16:31:28 git diff;d4f80100-2225-40b3-b029-72e571a8ef11]633;C[?1h=\r[1mdiff --git a/genie.py b/genie.py[m[m\r\n[1mindex 50729ab..7314771 100644[m[m\r\n[1m--- a/genie.py[m[m\r\n[1m+++ b/genie.py[m[m\r\n[36m@@ -4,6 +4,7 @@[m [mfrom orbax.checkpoint import PyTreeCheckpointer[m[m\r\n import jax[m[m\r\n import jax.numpy as jnp[m[m\r\n import flax.linen as nn[m[m\r\n[32m+[m[32mimport einops[m[m\r\n [m[m\r\n from models.dynamics import DynamicsMaskGIT[m[m\r\n from models.lam import LatentActionModel[m[m\r\n:[K",,terminal_output
|
| 74 |
+
74,198810,"genie.py",5699,0,"",python,selection_mouse
|
| 75 |
+
75,198812,"genie.py",5698,0,"",python,selection_command
|
| 76 |
+
76,200328,"genie.py",5769,0,"",python,selection_mouse
|
| 77 |
+
77,213897,"genie.py",3703,0,"",python,selection_mouse
|
| 78 |
+
78,213900,"genie.py",3702,0,"",python,selection_command
|
| 79 |
+
79,215629,"genie.py",3739,1,"T",python,selection_command
|
| 80 |
+
80,215683,"genie.py",3829,2,"to",python,selection_command
|
| 81 |
+
81,215757,"genie.py",3829,3,"tok",python,selection_command
|
| 82 |
+
82,215913,"genie.py",3829,4,"toke",python,selection_command
|
| 83 |
+
83,215999,"genie.py",3829,5,"token",python,selection_command
|
| 84 |
+
84,216606,"genie.py",4677,6,"token_",python,selection_command
|
| 85 |
+
85,217072,"genie.py",4677,7,"token_i",python,selection_command
|
| 86 |
+
86,217219,"genie.py",4677,8,"token_id",python,selection_command
|
| 87 |
+
87,217663,"genie.py",4677,9,"token_idx",python,selection_command
|
| 88 |
+
88,218218,"genie.py",4677,10,"token_idxs",python,selection_command
|
| 89 |
+
89,237629,"genie.py",3116,0,"",python,selection_mouse
|
| 90 |
+
90,237773,"genie.py",3108,14,"new_frame_idxs",python,selection_mouse
|
| 91 |
+
91,356558,"genie.py",6658,0,"",python,selection_mouse
|
| 92 |
+
92,364385,"genie.py",4471,2187,"\nclass MaskGITStep(nn.Module):\n dynamics: nn.Module\n tokenizer: nn.Module\n temperature: float\n sample_argmax: bool\n steps: int\n\n @nn.compact\n def __call__(self, carry, x):\n rng, token_idxs, mask, action_tokens = carry\n step = x\n N = token_idxs.shape[2]\n\n # --- Construct + encode video ---\n vid_embed = self.dynamics.patch_embed(token_idxs) # (B, S, N, D)\n mask_token = self.dynamics.mask_token # (1, 1, 1, D,)\n mask_expanded = mask[..., None] # (B, S, N, 1) \n vid_embed = jnp.where(mask_expanded, mask_token, vid_embed)\n\n # --- Predict transition ---\n act_embed = self.dynamics.action_up(action_tokens)\n vid_embed += jnp.pad(act_embed, ((0, 0), (1, 0), (0, 0), (0, 0)))\n unmasked_ratio = jnp.cos(jnp.pi * (step + 1) / (self.steps * 2))\n step_temp = self.temperature * (1.0 - unmasked_ratio)\n final_logits = self.dynamics.dynamics(vid_embed) / step_temp\n\n # --- Sample new tokens for final frame ---\n if self.sample_argmax:\n sampled_token_idxs = jnp.argmax(final_logits, axis=-1)\n else:\n rng, _rng = jax.random.split(rng)\n sampled_token_idxs = jnp.where(\n step == self.steps - 1,\n jnp.argmax(final_logits, axis=-1),\n jax.random.categorical(_rng, final_logits),\n )\n gather_fn = jax.vmap(jax.vmap(jax.vmap(lambda x, y: x[y])))\n final_token_probs = gather_fn(jax.nn.softmax(final_logits), sampled_token_idxs)\n final_token_probs += ~mask\n # Update masked tokens only\n token_idxs = jnp.where(mask, sampled_token_idxs, token_idxs)\n\n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n idx_mask = jnp.arange(final_token_probs.shape[-1]) > num_unmasked_tokens\n sorted_idxs = jnp.argsort(final_token_probs, axis=-1, descending=True)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask))\n new_mask = mask_update_fn(mask, sorted_idxs)\n\n new_carry = (rng, token_idxs, new_mask, action_tokens)\n return new_carry, None\n",python,selection_mouse
|
| 93 |
+
93,364399,"genie.py",4360,2298," lam_output = self.lam.vq_encode(batch[""videos""], training=training)\n return lam_output[""indices""]\n\nclass MaskGITStep(nn.Module):\n dynamics: nn.Module\n tokenizer: nn.Module\n temperature: float\n sample_argmax: bool\n steps: int\n\n @nn.compact\n def __call__(self, carry, x):\n rng, token_idxs, mask, action_tokens = carry\n step = x\n N = token_idxs.shape[2]\n\n # --- Construct + encode video ---\n vid_embed = self.dynamics.patch_embed(token_idxs) # (B, S, N, D)\n mask_token = self.dynamics.mask_token # (1, 1, 1, D,)\n mask_expanded = mask[..., None] # (B, S, N, 1) \n vid_embed = jnp.where(mask_expanded, mask_token, vid_embed)\n\n # --- Predict transition ---\n act_embed = self.dynamics.action_up(action_tokens)\n vid_embed += jnp.pad(act_embed, ((0, 0), (1, 0), (0, 0), (0, 0)))\n unmasked_ratio = jnp.cos(jnp.pi * (step + 1) / (self.steps * 2))\n step_temp = self.temperature * (1.0 - unmasked_ratio)\n final_logits = self.dynamics.dynamics(vid_embed) / step_temp\n\n # --- Sample new tokens for final frame ---\n if self.sample_argmax:\n sampled_token_idxs = jnp.argmax(final_logits, axis=-1)\n else:\n rng, _rng = jax.random.split(rng)\n sampled_token_idxs = jnp.where(\n step == self.steps - 1,\n jnp.argmax(final_logits, axis=-1),\n jax.random.categorical(_rng, final_logits),\n )\n gather_fn = jax.vmap(jax.vmap(jax.vmap(lambda x, y: x[y])))\n final_token_probs = gather_fn(jax.nn.softmax(final_logits), sampled_token_idxs)\n final_token_probs += ~mask\n # Update masked tokens only\n token_idxs = jnp.where(mask, sampled_token_idxs, token_idxs)\n\n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n idx_mask = jnp.arange(final_token_probs.shape[-1]) > num_unmasked_tokens\n sorted_idxs = jnp.argsort(final_token_probs, axis=-1, descending=True)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask))\n new_mask = mask_update_fn(mask, sorted_idxs)\n\n new_carry = (rng, token_idxs, new_mask, action_tokens)\n return new_carry, None\n",python,selection_mouse
|
| 94 |
+
94,364414,"genie.py",4323,2335," # --- Preprocess videos ---\n lam_output = self.lam.vq_encode(batch[""videos""], training=training)\n return lam_output[""indices""]\n\nclass MaskGITStep(nn.Module):\n dynamics: nn.Module\n tokenizer: nn.Module\n temperature: float\n sample_argmax: bool\n steps: int\n\n @nn.compact\n def __call__(self, carry, x):\n rng, token_idxs, mask, action_tokens = carry\n step = x\n N = token_idxs.shape[2]\n\n # --- Construct + encode video ---\n vid_embed = self.dynamics.patch_embed(token_idxs) # (B, S, N, D)\n mask_token = self.dynamics.mask_token # (1, 1, 1, D,)\n mask_expanded = mask[..., None] # (B, S, N, 1) \n vid_embed = jnp.where(mask_expanded, mask_token, vid_embed)\n\n # --- Predict transition ---\n act_embed = self.dynamics.action_up(action_tokens)\n vid_embed += jnp.pad(act_embed, ((0, 0), (1, 0), (0, 0), (0, 0)))\n unmasked_ratio = jnp.cos(jnp.pi * (step + 1) / (self.steps * 2))\n step_temp = self.temperature * (1.0 - unmasked_ratio)\n final_logits = self.dynamics.dynamics(vid_embed) / step_temp\n\n # --- Sample new tokens for final frame ---\n if self.sample_argmax:\n sampled_token_idxs = jnp.argmax(final_logits, axis=-1)\n else:\n rng, _rng = jax.random.split(rng)\n sampled_token_idxs = jnp.where(\n step == self.steps - 1,\n jnp.argmax(final_logits, axis=-1),\n jax.random.categorical(_rng, final_logits),\n )\n gather_fn = jax.vmap(jax.vmap(jax.vmap(lambda x, y: x[y])))\n final_token_probs = gather_fn(jax.nn.softmax(final_logits), sampled_token_idxs)\n final_token_probs += ~mask\n # Update masked tokens only\n token_idxs = jnp.where(mask, sampled_token_idxs, token_idxs)\n\n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n idx_mask = jnp.arange(final_token_probs.shape[-1]) > num_unmasked_tokens\n sorted_idxs = jnp.argsort(final_token_probs, axis=-1, descending=True)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask))\n new_mask = mask_update_fn(mask, sorted_idxs)\n\n new_carry = (rng, token_idxs, new_mask, action_tokens)\n return new_carry, None\n",python,selection_mouse
|
| 95 |
+
95,364440,"genie.py",4262,2396," def vq_encode(self, batch, training) -> Dict[str, Any]:\n # --- Preprocess videos ---\n lam_output = self.lam.vq_encode(batch[""videos""], training=training)\n return lam_output[""indices""]\n\nclass MaskGITStep(nn.Module):\n dynamics: nn.Module\n tokenizer: nn.Module\n temperature: float\n sample_argmax: bool\n steps: int\n\n @nn.compact\n def __call__(self, carry, x):\n rng, token_idxs, mask, action_tokens = carry\n step = x\n N = token_idxs.shape[2]\n\n # --- Construct + encode video ---\n vid_embed = self.dynamics.patch_embed(token_idxs) # (B, S, N, D)\n mask_token = self.dynamics.mask_token # (1, 1, 1, D,)\n mask_expanded = mask[..., None] # (B, S, N, 1) \n vid_embed = jnp.where(mask_expanded, mask_token, vid_embed)\n\n # --- Predict transition ---\n act_embed = self.dynamics.action_up(action_tokens)\n vid_embed += jnp.pad(act_embed, ((0, 0), (1, 0), (0, 0), (0, 0)))\n unmasked_ratio = jnp.cos(jnp.pi * (step + 1) / (self.steps * 2))\n step_temp = self.temperature * (1.0 - unmasked_ratio)\n final_logits = self.dynamics.dynamics(vid_embed) / step_temp\n\n # --- Sample new tokens for final frame ---\n if self.sample_argmax:\n sampled_token_idxs = jnp.argmax(final_logits, axis=-1)\n else:\n rng, _rng = jax.random.split(rng)\n sampled_token_idxs = jnp.where(\n step == self.steps - 1,\n jnp.argmax(final_logits, axis=-1),\n jax.random.categorical(_rng, final_logits),\n )\n gather_fn = jax.vmap(jax.vmap(jax.vmap(lambda x, y: x[y])))\n final_token_probs = gather_fn(jax.nn.softmax(final_logits), sampled_token_idxs)\n final_token_probs += ~mask\n # Update masked tokens only\n token_idxs = jnp.where(mask, sampled_token_idxs, token_idxs)\n\n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n idx_mask = jnp.arange(final_token_probs.shape[-1]) > num_unmasked_tokens\n sorted_idxs = jnp.argsort(final_token_probs, axis=-1, descending=True)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask))\n new_mask = mask_update_fn(mask, sorted_idxs)\n\n new_carry = (rng, token_idxs, new_mask, action_tokens)\n return new_carry, None\n",python,selection_mouse
|
| 96 |
+
96,364530,"genie.py",4261,2397,"\n def vq_encode(self, batch, training) -> Dict[str, Any]:\n # --- Preprocess videos ---\n lam_output = self.lam.vq_encode(batch[""videos""], training=training)\n return lam_output[""indices""]\n\nclass MaskGITStep(nn.Module):\n dynamics: nn.Module\n tokenizer: nn.Module\n temperature: float\n sample_argmax: bool\n steps: int\n\n @nn.compact\n def __call__(self, carry, x):\n rng, token_idxs, mask, action_tokens = carry\n step = x\n N = token_idxs.shape[2]\n\n # --- Construct + encode video ---\n vid_embed = self.dynamics.patch_embed(token_idxs) # (B, S, N, D)\n mask_token = self.dynamics.mask_token # (1, 1, 1, D,)\n mask_expanded = mask[..., None] # (B, S, N, 1) \n vid_embed = jnp.where(mask_expanded, mask_token, vid_embed)\n\n # --- Predict transition ---\n act_embed = self.dynamics.action_up(action_tokens)\n vid_embed += jnp.pad(act_embed, ((0, 0), (1, 0), (0, 0), (0, 0)))\n unmasked_ratio = jnp.cos(jnp.pi * (step + 1) / (self.steps * 2))\n step_temp = self.temperature * (1.0 - unmasked_ratio)\n final_logits = self.dynamics.dynamics(vid_embed) / step_temp\n\n # --- Sample new tokens for final frame ---\n if self.sample_argmax:\n sampled_token_idxs = jnp.argmax(final_logits, axis=-1)\n else:\n rng, _rng = jax.random.split(rng)\n sampled_token_idxs = jnp.where(\n step == self.steps - 1,\n jnp.argmax(final_logits, axis=-1),\n jax.random.categorical(_rng, final_logits),\n )\n gather_fn = jax.vmap(jax.vmap(jax.vmap(lambda x, y: x[y])))\n final_token_probs = gather_fn(jax.nn.softmax(final_logits), sampled_token_idxs)\n final_token_probs += ~mask\n # Update masked tokens only\n token_idxs = jnp.where(mask, sampled_token_idxs, token_idxs)\n\n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n idx_mask = jnp.arange(final_token_probs.shape[-1]) > num_unmasked_tokens\n sorted_idxs = jnp.argsort(final_token_probs, axis=-1, descending=True)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask))\n new_mask = mask_update_fn(mask, sorted_idxs)\n\n new_carry = (rng, token_idxs, new_mask, action_tokens)\n return new_carry, None\n",python,selection_mouse
|
| 97 |
+
97,364607,"genie.py",2761,3897," def sample(\n self,\n batch: Dict[str, Any],\n steps: int = 25,\n temperature: int = 1,\n sample_argmax: bool = False,\n ) -> Any:\n # --- Encode videos and actions ---\n tokenizer_out = self.tokenizer.vq_encode(batch[""videos""], training=False)\n token_idxs = tokenizer_out[""indices""]\n new_frame_idxs = jnp.zeros_like(token_idxs)[:, 0]\n action_tokens = self.lam.vq.get_codes(batch[""latent_actions""])\n\n # --- Initialize MaskGIT ---\n init_mask = jnp.ones_like(token_idxs, dtype=bool)[:, 0]\n init_carry = (\n batch[""rng""],\n new_frame_idxs,\n init_mask,\n token_idxs,\n action_tokens,\n )\n MaskGITLoop = nn.scan(\n MaskGITStep,\n variable_broadcast=""params"",\n split_rngs={""params"": False},\n in_axes=0,\n out_axes=0,\n length=steps,\n )\n\n # --- Run MaskGIT loop ---\n loop_fn = MaskGITLoop(\n dynamics=self.dynamics,\n tokenizer=self.tokenizer,\n temperature=temperature,\n sample_argmax=sample_argmax,\n steps=steps,\n )\n final_carry, _ = loop_fn(init_carry, jnp.arange(steps))\n new_frame_idxs = final_carry[1]\n new_frame_pixels = self.tokenizer.decode(\n jnp.expand_dims(new_frame_idxs, 1),\n video_hw=batch[""videos""].shape[2:4],\n )\n return new_frame_pixels\n\n def vq_encode(self, batch, training) -> Dict[str, Any]:\n # --- Preprocess videos ---\n lam_output = self.lam.vq_encode(batch[""videos""], training=training)\n return lam_output[""indices""]\n\nclass MaskGITStep(nn.Module):\n dynamics: nn.Module\n tokenizer: nn.Module\n temperature: float\n sample_argmax: bool\n steps: int\n\n @nn.compact\n def __call__(self, carry, x):\n rng, token_idxs, mask, action_tokens = carry\n step = x\n N = token_idxs.shape[2]\n\n # --- Construct + encode video ---\n vid_embed = self.dynamics.patch_embed(token_idxs) # (B, S, N, D)\n mask_token = self.dynamics.mask_token # (1, 1, 1, D,)\n mask_expanded = mask[..., None] # (B, S, N, 1) \n vid_embed = jnp.where(mask_expanded, mask_token, vid_embed)\n\n # --- Predict transition ---\n act_embed = self.dynamics.action_up(action_tokens)\n vid_embed += jnp.pad(act_embed, ((0, 0), (1, 0), (0, 0), (0, 0)))\n unmasked_ratio = jnp.cos(jnp.pi * (step + 1) / (self.steps * 2))\n step_temp = self.temperature * (1.0 - unmasked_ratio)\n final_logits = self.dynamics.dynamics(vid_embed) / step_temp\n\n # --- Sample new tokens for final frame ---\n if self.sample_argmax:\n sampled_token_idxs = jnp.argmax(final_logits, axis=-1)\n else:\n rng, _rng = jax.random.split(rng)\n sampled_token_idxs = jnp.where(\n step == self.steps - 1,\n jnp.argmax(final_logits, axis=-1),\n jax.random.categorical(_rng, final_logits),\n )\n gather_fn = jax.vmap(jax.vmap(jax.vmap(lambda x, y: x[y])))\n final_token_probs = gather_fn(jax.nn.softmax(final_logits), sampled_token_idxs)\n final_token_probs += ~mask\n # Update masked tokens only\n token_idxs = jnp.where(mask, sampled_token_idxs, token_idxs)\n\n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n idx_mask = jnp.arange(final_token_probs.shape[-1]) > num_unmasked_tokens\n sorted_idxs = jnp.argsort(final_token_probs, axis=-1, descending=True)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask))\n new_mask = mask_update_fn(mask, sorted_idxs)\n\n new_carry = (rng, token_idxs, new_mask, action_tokens)\n return new_carry, None\n",python,selection_mouse
|
| 98 |
+
98,364700,"genie.py",2745,3913," @nn.compact\n def sample(\n self,\n batch: Dict[str, Any],\n steps: int = 25,\n temperature: int = 1,\n sample_argmax: bool = False,\n ) -> Any:\n # --- Encode videos and actions ---\n tokenizer_out = self.tokenizer.vq_encode(batch[""videos""], training=False)\n token_idxs = tokenizer_out[""indices""]\n new_frame_idxs = jnp.zeros_like(token_idxs)[:, 0]\n action_tokens = self.lam.vq.get_codes(batch[""latent_actions""])\n\n # --- Initialize MaskGIT ---\n init_mask = jnp.ones_like(token_idxs, dtype=bool)[:, 0]\n init_carry = (\n batch[""rng""],\n new_frame_idxs,\n init_mask,\n token_idxs,\n action_tokens,\n )\n MaskGITLoop = nn.scan(\n MaskGITStep,\n variable_broadcast=""params"",\n split_rngs={""params"": False},\n in_axes=0,\n out_axes=0,\n length=steps,\n )\n\n # --- Run MaskGIT loop ---\n loop_fn = MaskGITLoop(\n dynamics=self.dynamics,\n tokenizer=self.tokenizer,\n temperature=temperature,\n sample_argmax=sample_argmax,\n steps=steps,\n )\n final_carry, _ = loop_fn(init_carry, jnp.arange(steps))\n new_frame_idxs = final_carry[1]\n new_frame_pixels = self.tokenizer.decode(\n jnp.expand_dims(new_frame_idxs, 1),\n video_hw=batch[""videos""].shape[2:4],\n )\n return new_frame_pixels\n\n def vq_encode(self, batch, training) -> Dict[str, Any]:\n # --- Preprocess videos ---\n lam_output = self.lam.vq_encode(batch[""videos""], training=training)\n return lam_output[""indices""]\n\nclass MaskGITStep(nn.Module):\n dynamics: nn.Module\n tokenizer: nn.Module\n temperature: float\n sample_argmax: bool\n steps: int\n\n @nn.compact\n def __call__(self, carry, x):\n rng, token_idxs, mask, action_tokens = carry\n step = x\n N = token_idxs.shape[2]\n\n # --- Construct + encode video ---\n vid_embed = self.dynamics.patch_embed(token_idxs) # (B, S, N, D)\n mask_token = self.dynamics.mask_token # (1, 1, 1, D,)\n mask_expanded = mask[..., None] # (B, S, N, 1) \n vid_embed = jnp.where(mask_expanded, mask_token, vid_embed)\n\n # --- Predict transition ---\n act_embed = self.dynamics.action_up(action_tokens)\n vid_embed += jnp.pad(act_embed, ((0, 0), (1, 0), (0, 0), (0, 0)))\n unmasked_ratio = jnp.cos(jnp.pi * (step + 1) / (self.steps * 2))\n step_temp = self.temperature * (1.0 - unmasked_ratio)\n final_logits = self.dynamics.dynamics(vid_embed) / step_temp\n\n # --- Sample new tokens for final frame ---\n if self.sample_argmax:\n sampled_token_idxs = jnp.argmax(final_logits, axis=-1)\n else:\n rng, _rng = jax.random.split(rng)\n sampled_token_idxs = jnp.where(\n step == self.steps - 1,\n jnp.argmax(final_logits, axis=-1),\n jax.random.categorical(_rng, final_logits),\n )\n gather_fn = jax.vmap(jax.vmap(jax.vmap(lambda x, y: x[y])))\n final_token_probs = gather_fn(jax.nn.softmax(final_logits), sampled_token_idxs)\n final_token_probs += ~mask\n # Update masked tokens only\n token_idxs = jnp.where(mask, sampled_token_idxs, token_idxs)\n\n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n idx_mask = jnp.arange(final_token_probs.shape[-1]) > num_unmasked_tokens\n sorted_idxs = jnp.argsort(final_token_probs, axis=-1, descending=True)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask))\n new_mask = mask_update_fn(mask, sorted_idxs)\n\n new_carry = (rng, token_idxs, new_mask, action_tokens)\n return new_carry, None\n",python,selection_mouse
|
| 99 |
+
99,365586,"genie.py",2745,3914,"",python,content
|
| 100 |
+
100,367129,"genie.py",2743,0,"",python,selection_mouse
|
| 101 |
+
101,368150,"genie.py",2744,0,"",python,selection_mouse
|
| 102 |
+
102,369159,"genie.py",2744,0," @nn.compact\n def sample(\n self,\n batch: Dict[str, Any],\n seq_len: int,\n steps: int = 25,\n temperature: float = 1,\n sample_argmax: bool = False,\n ) -> Any:\n """"""\n Autoregressively samples up to `seq_len` future frames, following Figure 8 of the paper.\n\n - Input frames are tokenized once.\n - Future frames are generated autoregressively in token space.\n - All frames are detokenized in a single pass.\n\n Note:\n - For interactive or step-wise sampling, detokenization should occur after each action.\n - To maintain consistent tensor shapes across timesteps, all current and future frames are decoded at every step.\n - Temporal causal structure is preserved by \n a) reapplying the mask before each decoding step.\n b) a temporal causal mask is applied within each ST-transformer block.\n\n Dimension keys:\n B: batch size \n T: number of input (conditioning) frames \n N: patches per frame \n S: sequence length \n A: action space \n D: model latent dimension\n """"""\n # --- Encode videos and actions ---\n tokenizer_out = self.tokenizer.vq_encode(batch[""videos""], training=False)\n token_idxs = tokenizer_out[""indices""] # (B, T, N)\n B, T, N = token_idxs.shape\n pad_shape = (B, seq_len - T, N)\n pad = jnp.zeros(pad_shape, dtype=token_idxs.dtype)\n token_idxs = jnp.concatenate([token_idxs, pad], axis=1) # (B, S, N)\n action_tokens = self.lam.vq.get_codes(batch[""latent_actions""])\n\n MaskGITLoop = nn.scan(\n MaskGITStep,\n variable_broadcast=""params"",\n split_rngs={""params"": False},\n in_axes=0,\n out_axes=0,\n length=steps,\n )\n \n loop_fn = MaskGITLoop(\n dynamics=self.dynamics,\n tokenizer=self.tokenizer,\n temperature=temperature,\n sample_argmax=sample_argmax,\n steps=steps,\n )\n\n def generation_step_fn(carry, step_t):\n rng, current_token_idxs = carry\n rng, step_rng = jax.random.split(rng)\n\n # Mask current and future frames (i.e., t >= step_t)\n mask = jnp.arange(seq_len) >= step_t # (S,)\n mask = jnp.broadcast_to(mask[None, :, None], (B, seq_len, N)) # (B, S, N)\n mask = mask.astype(bool)\n masked_token_idxs = current_token_idxs * ~mask\n\n # --- Initialize and run MaskGIT loop ---\n init_carry_maskgit = (\n step_rng,\n masked_token_idxs,\n mask,\n action_tokens,\n )\n final_carry_maskgit, _ = loop_fn(init_carry_maskgit, jnp.arange(steps))\n updated_token_idxs = final_carry_maskgit[1]\n new_carry = (rng, updated_token_idxs)\n return new_carry, None\n\n # --- Run the autoregressive generation using scan ---\n initial_carry = (batch[""rng""], token_idxs)\n timesteps_to_scan = jnp.arange(T, seq_len)\n final_carry, _ = jax.lax.scan(\n generation_step_fn,\n initial_carry,\n timesteps_to_scan\n )\n final_token_idxs = final_carry[1]\n\n # --- Decode all tokens at once at the end ---\n final_frames = self.tokenizer.decode(\n final_token_idxs,\n video_hw=batch[""videos""].shape[2:4],\n )\n return final_frames\n\n def vq_encode(self, batch, training) -> Dict[str, Any]:\n # --- Preprocess videos ---\n lam_output = self.lam.vq_encode(batch[""videos""], training=training)\n return lam_output[""indices""]\n\n\nclass MaskGITStep(nn.Module):\n dynamics: nn.Module\n tokenizer: nn.Module\n temperature: float\n sample_argmax: bool\n steps: int\n\n @nn.compact\n def __call__(self, carry, x):\n rng, token_idxs, mask, action_tokens = carry\n step = x\n N = token_idxs.shape[2]\n\n # --- Construct + encode video ---\n vid_embed = self.dynamics.patch_embed(token_idxs) # (B, S, N, D)\n mask_token = self.dynamics.mask_token # (1, 1, 1, D,)\n mask_expanded = mask[..., None] # (B, S, N, 1) \n vid_embed = jnp.where(mask_expanded, mask_token, vid_embed)\n\n # --- Predict transition ---\n act_embed = self.dynamics.action_up(action_tokens)\n vid_embed += jnp.pad(act_embed, ((0, 0), (1, 0), (0, 0), (0, 0)))\n unmasked_ratio = jnp.cos(jnp.pi * (step + 1) / (self.steps * 2))\n step_temp = self.temperature * (1.0 - unmasked_ratio)\n final_logits = self.dynamics.dynamics(vid_embed) / step_temp\n\n # --- Sample new tokens for final frame ---\n if self.sample_argmax:\n sampled_token_idxs = jnp.argmax(final_logits, axis=-1)\n else:\n rng, _rng = jax.random.split(rng)\n sampled_token_idxs = jnp.where(\n step == self.steps - 1,\n jnp.argmax(final_logits, axis=-1),\n jax.random.categorical(_rng, final_logits),\n )\n gather_fn = jax.vmap(jax.vmap(jax.vmap(lambda x, y: x[y])))\n final_token_probs = gather_fn(jax.nn.softmax(final_logits), sampled_token_idxs)\n final_token_probs += ~mask\n # Update masked tokens only\n token_idxs = jnp.where(mask, sampled_token_idxs, token_idxs)\n\n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n idx_mask = jnp.arange(final_token_probs.shape[-1]) > num_unmasked_tokens\n sorted_idxs = jnp.argsort(final_token_probs, axis=-1, descending=True)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask))\n new_mask = mask_update_fn(mask, sorted_idxs)\n\n new_carry = (rng, token_idxs, new_mask, action_tokens)\n return new_carry, None",python,content
|
| 103 |
+
103,370006,"genie.py",8679,0,"\n ",python,content
|
| 104 |
+
104,370116,"genie.py",8684,4,"",python,content
|
| 105 |
+
105,371031,"genie.py",8684,0,"\n ",python,content
|
| 106 |
+
106,371365,"genie.py",8685,4,"",python,content
|
| 107 |
+
107,377778,"genie.py",0,0,"",python,tab
|
| 108 |
+
108,377844,"genie.py",137,0,"",python,selection_command
|
| 109 |
+
109,379545,"genie.py",0,0,"from typing import Dict, Any\n\nfrom orbax.checkpoint import PyTreeCheckpointer\nimport jax\nimport jax.numpy as jnp\nimport flax.linen as nn\n\nfrom models.dynamics import DynamicsMaskGIT\nfrom models.lam import LatentActionModel\nfrom models.tokenizer import TokenizerVQVAE\n\n\nclass Genie(nn.Module):\n """"""Genie model""""""\n\n # --- Tokenizer ---\n in_dim: int\n tokenizer_dim: int\n latent_patch_dim: int\n num_patch_latents: int\n patch_size: int\n tokenizer_num_blocks: int\n tokenizer_num_heads: int\n # --- LAM ---\n lam_dim: int\n latent_action_dim: int\n num_latent_actions: int\n lam_patch_size: int\n lam_num_blocks: int\n lam_num_heads: int\n # --- Dynamics ---\n dyna_dim: int\n dyna_num_blocks: int\n dyna_num_heads: int\n dropout: float = 0.0\n mask_limit: float = 0.0\n\n def setup(self):\n self.tokenizer = TokenizerVQVAE(\n in_dim=self.in_dim,\n model_dim=self.tokenizer_dim,\n latent_dim=self.latent_patch_dim,\n num_latents=self.num_patch_latents,\n patch_size=self.patch_size,\n num_blocks=self.tokenizer_num_blocks,\n num_heads=self.tokenizer_num_heads,\n dropout=0.0,\n codebook_dropout=0.0,\n )\n self.lam = LatentActionModel(\n in_dim=self.in_dim,\n model_dim=self.lam_dim,\n latent_dim=self.latent_patch_dim,\n num_latents=self.num_latent_actions,\n patch_size=self.lam_patch_size,\n num_blocks=self.lam_num_blocks,\n num_heads=self.lam_num_heads,\n dropout=0.0,\n codebook_dropout=0.0,\n )\n self.dynamics = DynamicsMaskGIT(\n model_dim=self.dyna_dim,\n num_latents=self.num_patch_latents,\n num_blocks=self.dyna_num_blocks,\n num_heads=self.dyna_num_heads,\n dropout=self.dropout,\n mask_limit=self.mask_limit,\n )\n\n def __call__(self, batch: Dict[str, Any], training: bool = True) -> Dict[str, Any]:\n tokenizer_outputs = self.tokenizer.vq_encode(batch[""videos""], training=False)\n lam_outputs = self.lam.vq_encode(batch[""videos""], training=False)\n outputs = dict(\n video_tokens=jax.lax.stop_gradient(tokenizer_outputs[""indices""]),\n latent_actions=jax.lax.stop_gradient(lam_outputs[""z_q""]),\n )\n outputs[""mask_rng""] = batch[""mask_rng""]\n dyna_outputs = self.dynamics(outputs, training)\n outputs.update(dyna_outputs)\n mle_indices = jnp.argmax(outputs[""token_logits""], axis=-1)\n outputs[""recon""] = self.tokenizer.decode(\n mle_indices, batch[""videos""].shape[2:4]\n )\n return outputs\n\n @nn.compact\n def sample(\n self,\n batch: Dict[str, Any],\n steps: int = 25,\n temperature: int = 1,\n sample_argmax: bool = False,\n ) -> Any:\n # --- Encode videos and actions ---\n tokenizer_out = self.tokenizer.vq_encode(batch[""videos""], training=False)\n token_idxs = tokenizer_out[""indices""]\n new_frame_idxs = jnp.zeros_like(token_idxs)[:, 0]\n action_tokens = self.lam.vq.get_codes(batch[""latent_actions""])\n\n # --- Initialize MaskGIT ---\n init_mask = jnp.ones_like(token_idxs, dtype=bool)[:, 0]\n init_carry = (\n batch[""rng""],\n new_frame_idxs,\n init_mask,\n token_idxs,\n action_tokens,\n )\n MaskGITLoop = nn.scan(\n MaskGITStep,\n variable_broadcast=""params"",\n split_rngs={""params"": False},\n in_axes=0,\n out_axes=0,\n length=steps,\n )\n\n # --- Run MaskGIT loop ---\n loop_fn = MaskGITLoop(\n dynamics=self.dynamics,\n tokenizer=self.tokenizer,\n temperature=temperature,\n sample_argmax=sample_argmax,\n steps=steps,\n )\n final_carry, _ = loop_fn(init_carry, jnp.arange(steps))\n new_frame_idxs = final_carry[1]\n new_frame_pixels = self.tokenizer.decode(\n jnp.expand_dims(new_frame_idxs, 1),\n video_hw=batch[""videos""].shape[2:4],\n )\n return new_frame_pixels\n\n def vq_encode(self, batch, training) -> Dict[str, Any]:\n # --- Preprocess videos ---\n lam_output = self.lam.vq_encode(batch[""videos""], training=training)\n return lam_output[""indices""]\n\n\nclass MaskGITStep(nn.Module):\n dynamics: nn.Module\n tokenizer: nn.Module\n temperature: float\n sample_argmax: bool\n steps: int\n\n @nn.compact\n def __call__(self, carry, x):\n rng, token_idxs, mask, action_tokens = carry\n step = x\n N = token_idxs.shape[2]\n\n # --- Construct + encode video ---\n vid_embed = self.dynamics.patch_embed(token_idxs) # (B, S, N, D)\n mask_token = self.dynamics.mask_token # (1, 1, 1, D,)\n mask_expanded = mask[..., None] # (B, S, N, 1) \n vid_embed = jnp.where(mask_expanded, mask_token, vid_embed)\n\n # --- Predict transition ---\n act_embed = self.dynamics.action_up(action_tokens)\n vid_embed += jnp.pad(act_embed, ((0, 0), (1, 0), (0, 0), (0, 0)))\n unmasked_ratio = jnp.cos(jnp.pi * (step + 1) / (self.steps * 2))\n step_temp = self.temperature * (1.0 - unmasked_ratio)\n final_logits = self.dynamics.dynamics(vid_embed) / step_temp\n\n # --- Sample new tokens for final frame ---\n if self.sample_argmax:\n sampled_token_idxs = jnp.argmax(final_logits, axis=-1)\n else:\n rng, _rng = jax.random.split(rng)\n sampled_token_idxs = jnp.where(\n step == self.steps - 1,\n jnp.argmax(final_logits, axis=-1),\n jax.random.categorical(_rng, final_logits),\n )\n gather_fn = jax.vmap(jax.vmap(jax.vmap(lambda x, y: x[y])))\n final_token_probs = gather_fn(jax.nn.softmax(final_logits), sampled_token_idxs)\n final_token_probs += ~mask\n # Update masked tokens only\n token_idxs = jnp.where(mask, sampled_token_idxs, token_idxs)\n\n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n idx_mask = jnp.arange(final_token_probs.shape[-1]) > num_unmasked_tokens\n sorted_idxs = jnp.argsort(final_token_probs, axis=-1, descending=True)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask))\n new_mask = mask_update_fn(mask, sorted_idxs)\n\n new_carry = (rng, token_idxs, new_mask, action_tokens)\n return new_carry, None\n\n\ndef restore_genie_components(params: Dict[str, Any], tokenizer: str, lam: str):\n """"""Restore pre-trained Genie components""""""\n params[""params""][""tokenizer""].update(\n PyTreeCheckpointer().restore(tokenizer)[""model""][""params""][""params""]\n )\n params[""params""][""lam""].update(\n PyTreeCheckpointer().restore(lam)[""model""][""params""][""params""]\n )\n return params\n",python,tab
|
| 110 |
+
110,379547,"genie.py",137,0,"",python,selection_mouse
|
| 111 |
+
111,380221,"genie.py",136,0,"",python,selection_mouse
|
| 112 |
+
112,380223,"genie.py",135,0,"",python,selection_command
|
| 113 |
+
113,416823,"genie.py",3717,0,"",python,selection_mouse
|
| 114 |
+
114,421437,"genie.py",0,0,"",python,tab
|
| 115 |
+
115,421439,"genie.py",4609,0,"",python,selection_mouse
|
| 116 |
+
116,421439,"genie.py",4608,0,"",python,selection_command
|
| 117 |
+
117,422058,"genie.py",4610,0,"",python,selection_mouse
|
| 118 |
+
118,422815,"genie.py",4609,0,"",python,selection_mouse
|
| 119 |
+
119,422859,"genie.py",4608,0,"",python,selection_command
|
| 120 |
+
120,424565,"genie.py",4609,0,"\n # --- Run MaskGIT loop ---",python,content
|
| 121 |
+
121,424582,"genie.py",4618,0,"",python,selection_command
|
| 122 |
+
122,426041,"genie.py",4608,0,"",python,selection_command
|
| 123 |
+
123,430728,"genie.py",4627,0,"",python,selection_mouse
|
| 124 |
+
124,431729,"genie.py",4609,0,"",python,selection_mouse
|
| 125 |
+
125,431731,"genie.py",4608,0,"",python,selection_command
|
| 126 |
+
126,434063,"genie.py",4862,0,"",python,selection_mouse
|
| 127 |
+
127,434065,"genie.py",4861,0,"",python,selection_command
|
| 128 |
+
128,450431,"genie.py",8719,0,"",python,selection_mouse
|
| 129 |
+
129,450435,"genie.py",8718,0,"",python,selection_command
|
| 130 |
+
130,453692,"genie.py",8717,0,"",python,selection_command
|
| 131 |
+
131,453865,"genie.py",8716,0,"",python,selection_command
|
| 132 |
+
132,454067,"genie.py",8715,0,"",python,selection_command
|
| 133 |
+
133,454889,"genie.py",8715,4,"",python,content
|
| 134 |
+
134,459081,"genie.py",4605,0,"",python,selection_mouse
|
| 135 |
+
135,459613,"genie.py",4605,4,"",python,content
|
| 136 |
+
136,463564,"genie.py",2739,0,"",python,selection_mouse
|
| 137 |
+
137,463992,"genie.py",2739,4,"",python,content
|
| 138 |
+
138,510207,"genie.py",2771,0,"",python,selection_mouse
|
| 139 |
+
139,510223,"genie.py",2770,0,"",python,selection_command
|
| 140 |
+
140,518711,"genie.py",5103,0,"",python,selection_mouse
|
| 141 |
+
141,519650,"genie.py",5102,0,"",python,selection_command
|
| 142 |
+
142,527244,"genie.py",5102,1,"=",python,content
|
| 143 |
+
143,529180,"genie.py",5024,0,"",python,selection_mouse
|
| 144 |
+
144,529413,"genie.py",5024,1," ",python,selection_mouse
|
| 145 |
+
145,529413,"genie.py",5024,2," a",python,selection_mouse
|
| 146 |
+
146,529414,"genie.py",5024,3," an",python,selection_mouse
|
| 147 |
+
147,529428,"genie.py",5024,4," and",python,selection_mouse
|
| 148 |
+
148,529441,"genie.py",5024,5," and ",python,selection_mouse
|
| 149 |
+
149,529459,"genie.py",5024,7," and fu",python,selection_mouse
|
| 150 |
+
150,529504,"genie.py",5024,8," and fut",python,selection_mouse
|
| 151 |
+
151,529545,"genie.py",5024,10," and futur",python,selection_mouse
|
| 152 |
+
152,529546,"genie.py",5024,11," and future",python,selection_mouse
|
| 153 |
+
153,529565,"genie.py",5024,12," and future ",python,selection_mouse
|
| 154 |
+
154,529591,"genie.py",5024,13," and future f",python,selection_mouse
|
| 155 |
+
155,529639,"genie.py",5024,14," and future fr",python,selection_mouse
|
| 156 |
+
156,529648,"genie.py",5024,15," and future fra",python,selection_mouse
|
| 157 |
+
157,529711,"genie.py",5024,16," and future fram",python,selection_mouse
|
| 158 |
+
158,530331,"genie.py",5024,15," and future fra",python,selection_mouse
|
| 159 |
+
159,530372,"genie.py",5024,14," and future fr",python,selection_mouse
|
| 160 |
+
160,530418,"genie.py",5024,13," and future f",python,selection_mouse
|
| 161 |
+
161,530626,"genie.py",5024,12," and future ",python,selection_mouse
|
| 162 |
+
162,530676,"genie.py",5024,11," and future",python,selection_mouse
|
| 163 |
+
163,530766,"genie.py",5024,10," and futur",python,selection_mouse
|
| 164 |
+
164,532232,"genie.py",5053,0,"=",python,content
|
| 165 |
+
165,532232,"genie.py",5052,1,"",python,content
|
| 166 |
+
166,533650,"genie.py",5024,76," and future frames (i.e., t == step_t)\n mask = jnp.arange(seq_len",python,selection_command
|
| 167 |
+
167,534146,"genie.py",5024,11," and future",python,selection_command
|
| 168 |
+
168,534980,"genie.py",5034,0,"",python,selection_command
|
| 169 |
+
169,535115,"genie.py",5033,0,"",python,selection_command
|
| 170 |
+
170,535620,"genie.py",5032,0,"",python,selection_command
|
| 171 |
+
171,535635,"genie.py",5031,0,"",python,selection_command
|
| 172 |
+
172,535671,"genie.py",5030,0,"",python,selection_command
|
| 173 |
+
173,535717,"genie.py",5029,0,"",python,selection_command
|
| 174 |
+
174,535759,"genie.py",5028,0,"",python,selection_command
|
| 175 |
+
175,535759,"genie.py",5027,0,"",python,selection_command
|
| 176 |
+
176,535826,"genie.py",5026,0,"",python,selection_command
|
| 177 |
+
177,535947,"genie.py",5025,0,"",python,selection_command
|
| 178 |
+
178,536348,"genie.py",5025,4,"",python,content
|
| 179 |
+
179,536699,"genie.py",5025,7,"",python,content
|
| 180 |
+
180,537512,"genie.py",5026,0,"",python,selection_command
|
| 181 |
+
181,538034,"genie.py",5027,0,"",python,selection_command
|
| 182 |
+
182,538059,"genie.py",5028,0,"",python,selection_command
|
| 183 |
+
183,538081,"genie.py",5029,0,"",python,selection_command
|
| 184 |
+
184,538104,"genie.py",5030,0,"",python,selection_command
|
| 185 |
+
185,538255,"genie.py",5031,0,"",python,selection_command
|
| 186 |
+
186,538696,"genie.py",5030,0,"",python,selection_command
|
| 187 |
+
187,539040,"genie.py",5030,1,"",python,content
|
| 188 |
+
188,554120,"genie.py",5030,1," ",python,selection_mouse
|
| 189 |
+
189,554121,"genie.py",5030,3," (i",python,selection_mouse
|
| 190 |
+
190,554144,"genie.py",5030,5," (i.e",python,selection_mouse
|
| 191 |
+
191,554160,"genie.py",5030,7," (i.e.,",python,selection_mouse
|
| 192 |
+
192,554194,"genie.py",5030,9," (i.e., t",python,selection_mouse
|
| 193 |
+
193,554241,"genie.py",5030,65," (i.e., t == step_t)\n mask = jnp.arange(seq_len) == st",python,selection_mouse
|
| 194 |
+
194,554286,"genie.py",5030,66," (i.e., t == step_t)\n mask = jnp.arange(seq_len) == ste",python,selection_mouse
|
| 195 |
+
195,554286,"genie.py",5030,67," (i.e., t == step_t)\n mask = jnp.arange(seq_len) == step",python,selection_mouse
|
| 196 |
+
196,554291,"genie.py",5030,68," (i.e., t == step_t)\n mask = jnp.arange(seq_len) == step_",python,selection_mouse
|
| 197 |
+
197,554326,"genie.py",5030,69," (i.e., t == step_t)\n mask = jnp.arange(seq_len) == step_t",python,selection_mouse
|
| 198 |
+
198,554372,"genie.py",5030,70," (i.e., t == step_t)\n mask = jnp.arange(seq_len) == step_t ",python,selection_mouse
|
| 199 |
+
199,554415,"genie.py",5030,71," (i.e., t == step_t)\n mask = jnp.arange(seq_len) == step_t #",python,selection_mouse
|
| 200 |
+
200,554416,"genie.py",5030,72," (i.e., t == step_t)\n mask = jnp.arange(seq_len) == step_t # ",python,selection_mouse
|
| 201 |
+
201,554462,"genie.py",5030,73," (i.e., t == step_t)\n mask = jnp.arange(seq_len) == step_t # (",python,selection_mouse
|
| 202 |
+
202,554502,"genie.py",5030,74," (i.e., t == step_t)\n mask = jnp.arange(seq_len) == step_t # (S",python,selection_mouse
|
| 203 |
+
203,554548,"genie.py",5030,75," (i.e., t == step_t)\n mask = jnp.arange(seq_len) == step_t # (S,",python,selection_mouse
|
| 204 |
+
204,554589,"genie.py",5030,20," (i.e., t == step_t)",python,selection_mouse
|
| 205 |
+
205,554893,"genie.py",5050,0,"",python,selection_mouse
|
| 206 |
+
206,554895,"genie.py",5049,0,"",python,selection_command
|
| 207 |
+
207,555540,"genie.py",5050,0,"",python,selection_mouse
|
| 208 |
+
208,555547,"genie.py",5049,0,"",python,selection_command
|
| 209 |
+
209,555682,"genie.py",5049,1,")",python,selection_mouse
|
| 210 |
+
210,555691,"genie.py",5050,0,"",python,selection_command
|
| 211 |
+
211,555711,"genie.py",5047,3,"_t)",python,selection_mouse
|
| 212 |
+
212,555727,"genie.py",5046,4,"p_t)",python,selection_mouse
|
| 213 |
+
213,555742,"genie.py",5045,5,"ep_t)",python,selection_mouse
|
| 214 |
+
214,555772,"genie.py",5044,6,"tep_t)",python,selection_mouse
|
| 215 |
+
215,555819,"genie.py",5042,8," step_t)",python,selection_mouse
|
| 216 |
+
216,555864,"genie.py",5041,9,"= step_t)",python,selection_mouse
|
| 217 |
+
217,555865,"genie.py",5040,10,"== step_t)",python,selection_mouse
|
| 218 |
+
218,555865,"genie.py",5039,11," == step_t)",python,selection_mouse
|
| 219 |
+
219,555866,"genie.py",5038,12,"t == step_t)",python,selection_mouse
|
| 220 |
+
220,555866,"genie.py",5037,13," t == step_t)",python,selection_mouse
|
| 221 |
+
221,555909,"genie.py",5036,14,", t == step_t)",python,selection_mouse
|
| 222 |
+
222,555955,"genie.py",5035,15,"., t == step_t)",python,selection_mouse
|
| 223 |
+
223,555957,"genie.py",5034,16,"e., t == step_t)",python,selection_mouse
|
| 224 |
+
224,556008,"genie.py",5033,17,".e., t == step_t)",python,selection_mouse
|
| 225 |
+
225,556060,"genie.py",5032,18,"i.e., t == step_t)",python,selection_mouse
|
| 226 |
+
226,556205,"genie.py",5031,19,"(i.e., t == step_t)",python,selection_mouse
|
| 227 |
+
227,557425,"genie.py",5031,19,"",python,content
|
| 228 |
+
228,557442,"genie.py",5030,0,"",python,selection_command
|
| 229 |
+
229,558985,"genie.py",5030,1,"",python,content
|
| 230 |
+
230,558990,"genie.py",5029,0,"",python,selection_command
|
| 231 |
+
231,565946,"genie.py",5030,0,"",python,selection_command
|
| 232 |
+
232,566207,"genie.py",5030,0," ",python,content
|
| 233 |
+
233,566209,"genie.py",5031,0,"",python,selection_keyboard
|
| 234 |
+
234,566494,"genie.py",5031,0,"()",python,content
|
| 235 |
+
235,566495,"genie.py",5032,0,"",python,selection_keyboard
|
| 236 |
+
236,566865,"genie.py",5032,0,"f",python,content
|
| 237 |
+
237,566866,"genie.py",5033,0,"",python,selection_keyboard
|
| 238 |
+
238,567012,"genie.py",5033,0,"i",python,content
|
| 239 |
+
239,567013,"genie.py",5034,0,"",python,selection_keyboard
|
| 240 |
+
240,567639,"genie.py",5033,1,"",python,content
|
| 241 |
+
241,567918,"genie.py",5033,0,"u",python,content
|
| 242 |
+
242,567919,"genie.py",5034,0,"",python,selection_keyboard
|
| 243 |
+
243,568068,"genie.py",5034,0,"t",python,content
|
| 244 |
+
244,568069,"genie.py",5035,0,"",python,selection_keyboard
|
| 245 |
+
245,568538,"genie.py",5035,0,"u",python,content
|
| 246 |
+
246,568539,"genie.py",5036,0,"",python,selection_keyboard
|
| 247 |
+
247,569644,"genie.py",5036,0,"r",python,content
|
| 248 |
+
248,569645,"genie.py",5037,0,"",python,selection_keyboard
|
| 249 |
+
249,570091,"genie.py",5037,0,"e",python,content
|
| 250 |
+
250,570092,"genie.py",5038,0,"",python,selection_keyboard
|
| 251 |
+
251,570244,"genie.py",5038,0," ",python,content
|
| 252 |
+
252,570245,"genie.py",5039,0,"",python,selection_keyboard
|
| 253 |
+
253,570387,"genie.py",5039,0,"f",python,content
|
| 254 |
+
254,570388,"genie.py",5040,0,"",python,selection_keyboard
|
| 255 |
+
255,570870,"genie.py",5040,0,"r",python,content
|
| 256 |
+
256,570871,"genie.py",5041,0,"",python,selection_keyboard
|
| 257 |
+
257,571044,"genie.py",5041,0,"a",python,content
|
| 258 |
+
258,571045,"genie.py",5042,0,"",python,selection_keyboard
|
| 259 |
+
259,571167,"genie.py",5042,0,"m",python,content
|
| 260 |
+
260,571168,"genie.py",5043,0,"",python,selection_keyboard
|
| 261 |
+
261,571262,"genie.py",5043,0,"e",python,content
|
| 262 |
+
262,571263,"genie.py",5044,0,"",python,selection_keyboard
|
| 263 |
+
263,571419,"genie.py",5044,0,"s",python,content
|
| 264 |
+
264,571419,"genie.py",5045,0,"",python,selection_keyboard
|
| 265 |
+
265,571497,"genie.py",5045,0," ",python,content
|
| 266 |
+
266,571498,"genie.py",5046,0,"",python,selection_keyboard
|
| 267 |
+
267,571621,"genie.py",5046,0,"a",python,content
|
| 268 |
+
268,571621,"genie.py",5047,0,"",python,selection_keyboard
|
| 269 |
+
269,572234,"genie.py",5047,0,"r",python,content
|
| 270 |
+
270,572235,"genie.py",5048,0,"",python,selection_keyboard
|
| 271 |
+
271,572407,"genie.py",5048,0,"e",python,content
|
| 272 |
+
272,572408,"genie.py",5049,0,"",python,selection_keyboard
|
| 273 |
+
273,572521,"genie.py",5049,0," ",python,content
|
| 274 |
+
274,572522,"genie.py",5050,0,"",python,selection_keyboard
|
| 275 |
+
275,572652,"genie.py",5050,0,"m",python,content
|
| 276 |
+
276,572653,"genie.py",5051,0,"",python,selection_keyboard
|
| 277 |
+
277,572711,"genie.py",5051,0,"a",python,content
|
| 278 |
+
278,572711,"genie.py",5052,0,"",python,selection_keyboard
|
| 279 |
+
279,572755,"genie.py",5052,0,"s",python,content
|
| 280 |
+
280,572755,"genie.py",5053,0,"",python,selection_keyboard
|
| 281 |
+
281,572973,"genie.py",5053,0,"k",python,content
|
| 282 |
+
282,572974,"genie.py",5054,0,"",python,selection_keyboard
|
| 283 |
+
283,573302,"genie.py",5054,0,"e",python,content
|
| 284 |
+
284,573303,"genie.py",5055,0,"",python,selection_keyboard
|
| 285 |
+
285,573757,"genie.py",5055,0,"d",python,content
|
| 286 |
+
286,573758,"genie.py",5056,0,"",python,selection_keyboard
|
| 287 |
+
287,574057,"genie.py",5056,0," ",python,content
|
| 288 |
+
288,574058,"genie.py",5057,0,"",python,selection_keyboard
|
| 289 |
+
289,583490,"genie.py",5057,0,"by default",python,content
|
| 290 |
+
290,583880,"genie.py",5067,0," ",python,content
|
| 291 |
+
291,583882,"genie.py",5068,0,"",python,selection_keyboard
|
| 292 |
+
292,584561,"genie.py",5068,0,"u",python,content
|
| 293 |
+
293,584562,"genie.py",5069,0,"",python,selection_keyboard
|
| 294 |
+
294,584664,"genie.py",5069,0,"s",python,content
|
| 295 |
+
295,584665,"genie.py",5070,0,"",python,selection_keyboard
|
| 296 |
+
296,584757,"genie.py",5070,0,"i",python,content
|
| 297 |
+
297,584758,"genie.py",5071,0,"",python,selection_keyboard
|
| 298 |
+
298,584844,"genie.py",5071,0,"n",python,content
|
| 299 |
+
299,584844,"genie.py",5072,0,"",python,selection_keyboard
|
| 300 |
+
300,584936,"genie.py",5072,0,"g",python,content
|
| 301 |
+
301,584937,"genie.py",5073,0,"",python,selection_keyboard
|
| 302 |
+
302,585028,"genie.py",5073,0," ",python,content
|
| 303 |
+
303,585029,"genie.py",5074,0,"",python,selection_keyboard
|
| 304 |
+
304,585224,"genie.py",5074,0,"c",python,content
|
| 305 |
+
305,585225,"genie.py",5075,0,"",python,selection_keyboard
|
| 306 |
+
306,585771,"genie.py",5075,0,"a",python,content
|
| 307 |
+
307,585772,"genie.py",5076,0,"",python,selection_keyboard
|
| 308 |
+
308,585922,"genie.py",5076,0,"u",python,content
|
| 309 |
+
309,585923,"genie.py",5077,0,"",python,selection_keyboard
|
| 310 |
+
310,586114,"genie.py",5077,0,"s",python,content
|
| 311 |
+
311,586115,"genie.py",5078,0,"",python,selection_keyboard
|
| 312 |
+
312,586452,"genie.py",5078,0,"a",python,content
|
| 313 |
+
313,586453,"genie.py",5079,0,"",python,selection_keyboard
|
| 314 |
+
314,586586,"genie.py",5079,0,"l",python,content
|
| 315 |
+
315,586587,"genie.py",5080,0,"",python,selection_keyboard
|
| 316 |
+
316,586664,"genie.py",5080,0," ",python,content
|
| 317 |
+
317,586665,"genie.py",5081,0,"",python,selection_keyboard
|
| 318 |
+
318,586772,"genie.py",5081,0,"m",python,content
|
| 319 |
+
319,586773,"genie.py",5082,0,"",python,selection_keyboard
|
| 320 |
+
320,586909,"genie.py",5082,0,"a",python,content
|
| 321 |
+
321,586910,"genie.py",5083,0,"",python,selection_keyboard
|
| 322 |
+
322,586975,"genie.py",5083,0,"s",python,content
|
| 323 |
+
323,586976,"genie.py",5084,0,"",python,selection_keyboard
|
| 324 |
+
324,587079,"genie.py",5084,0,"k",python,content
|
| 325 |
+
325,587080,"genie.py",5085,0,"",python,selection_keyboard
|
| 326 |
+
326,587209,"genie.py",5085,0," ",python,content
|
| 327 |
+
327,587210,"genie.py",5086,0,"",python,selection_keyboard
|
| 328 |
+
328,587298,"genie.py",5086,0,"i",python,content
|
| 329 |
+
329,587299,"genie.py",5087,0,"",python,selection_keyboard
|
| 330 |
+
330,587416,"genie.py",5087,0,"n",python,content
|
| 331 |
+
331,587417,"genie.py",5088,0,"",python,selection_keyboard
|
| 332 |
+
332,587462,"genie.py",5088,0," ",python,content
|
| 333 |
+
333,587462,"genie.py",5089,0,"",python,selection_keyboard
|
| 334 |
+
334,589426,"genie.py",5089,0,"S",python,content
|
| 335 |
+
335,589427,"genie.py",5090,0,"",python,selection_keyboard
|
| 336 |
+
336,589557,"genie.py",5090,0,"T",python,content
|
| 337 |
+
337,589558,"genie.py",5091,0,"",python,selection_keyboard
|
| 338 |
+
338,590518,"genie.py",5091,0,"-transformer",python,content
|
| 339 |
+
339,612811,"genie.py",8386,0,"",python,selection_mouse
|
| 340 |
+
340,613438,"genie.py",8378,0,"",python,selection_mouse
|
| 341 |
+
341,620653,"genie.py",8422,0,"",python,selection_mouse
|
| 342 |
+
342,623924,"genie.py",8423,0,"",python,selection_command
|
| 343 |
+
343,625079,"genie.py",8422,1,"",python,content
|
| 344 |
+
344,625303,"genie.py",8422,0,"<",python,content
|
| 345 |
+
345,625304,"genie.py",8423,0,"",python,selection_keyboard
|
| 346 |
+
346,625716,"genie.py",8423,0,"=",python,content
|
| 347 |
+
347,625717,"genie.py",8424,0,"",python,selection_keyboard
|
| 348 |
+
348,627841,"genie.py",8424,0," ",python,content
|
| 349 |
+
349,627843,"genie.py",8425,0,"",python,selection_keyboard
|
| 350 |
+
350,628247,"genie.py",8425,0,"N",python,content
|
| 351 |
+
351,628248,"genie.py",8426,0,"",python,selection_keyboard
|
| 352 |
+
352,628587,"genie.py",8426,0," ",python,content
|
| 353 |
+
353,628588,"genie.py",8427,0,"",python,selection_keyboard
|
| 354 |
+
354,628744,"genie.py",8427,0,"-",python,content
|
| 355 |
+
355,628745,"genie.py",8428,0,"",python,selection_keyboard
|
| 356 |
+
356,637777,"genie.py",8388,0,"",python,selection_mouse
|
| 357 |
+
357,638604,"genie.py",8387,0,"",python,selection_command
|
| 358 |
+
358,639202,"genie.py",8448,0,"\n ",python,content
|
| 359 |
+
359,639640,"genie.py",8457,0,"f",python,content
|
| 360 |
+
360,639641,"genie.py",8458,0,"",python,selection_keyboard
|
| 361 |
+
361,639733,"genie.py",8458,0,"i",python,content
|
| 362 |
+
362,639734,"genie.py",8459,0,"",python,selection_keyboard
|
| 363 |
+
363,639828,"genie.py",8459,0,"n",python,content
|
| 364 |
+
364,639829,"genie.py",8460,0,"",python,selection_keyboard
|
| 365 |
+
365,639926,"genie.py",8460,0,"a",python,content
|
| 366 |
+
366,639926,"genie.py",8461,0,"",python,selection_keyboard
|
| 367 |
+
367,640014,"genie.py",8461,0,"l",python,content
|
| 368 |
+
368,640016,"genie.py",8462,0,"",python,selection_keyboard
|
| 369 |
+
369,640351,"genie.py",8462,0,"_",python,content
|
| 370 |
+
370,640352,"genie.py",8463,0,"",python,selection_keyboard
|
| 371 |
+
371,642219,"genie.py",8463,0,"t",python,content
|
| 372 |
+
372,642221,"genie.py",8464,0,"",python,selection_keyboard
|
| 373 |
+
373,642352,"genie.py",8464,0,"o",python,content
|
| 374 |
+
374,642353,"genie.py",8465,0,"",python,selection_keyboard
|
| 375 |
+
375,642447,"genie.py",8465,0,"k",python,content
|
| 376 |
+
376,642448,"genie.py",8466,0,"",python,selection_keyboard
|
| 377 |
+
377,643095,"genie.py",8466,0,"e",python,content
|
| 378 |
+
378,643096,"genie.py",8467,0,"",python,selection_keyboard
|
| 379 |
+
379,643188,"genie.py",8467,0,"n",python,content
|
| 380 |
+
380,643191,"genie.py",8468,0,"",python,selection_keyboard
|
| 381 |
+
381,643668,"genie.py",8468,0,"_",python,content
|
| 382 |
+
382,643669,"genie.py",8469,0,"",python,selection_keyboard
|
| 383 |
+
383,643945,"genie.py",8469,0,"p",python,content
|
| 384 |
+
384,643945,"genie.py",8470,0,"",python,selection_keyboard
|
| 385 |
+
385,644099,"genie.py",8470,0,"r",python,content
|
| 386 |
+
386,644100,"genie.py",8471,0,"",python,selection_keyboard
|
| 387 |
+
387,644188,"genie.py",8471,0,"o",python,content
|
| 388 |
+
388,644190,"genie.py",8472,0,"",python,selection_keyboard
|
| 389 |
+
389,644421,"genie.py",8472,0,"b",python,content
|
| 390 |
+
390,644421,"genie.py",8473,0,"",python,selection_keyboard
|
| 391 |
+
391,644658,"genie.py",8473,0,"s",python,content
|
| 392 |
+
392,644659,"genie.py",8474,0,"",python,selection_keyboard
|
| 393 |
+
393,644846,"genie.py",8474,0,"_",python,content
|
| 394 |
+
394,644847,"genie.py",8475,0,"",python,selection_keyboard
|
| 395 |
+
395,645035,"genie.py",8475,0,"f",python,content
|
| 396 |
+
396,645036,"genie.py",8476,0,"",python,selection_keyboard
|
| 397 |
+
397,645165,"genie.py",8476,0,"l",python,content
|
| 398 |
+
398,645166,"genie.py",8477,0,"",python,selection_keyboard
|
| 399 |
+
399,645318,"genie.py",8477,0,"a",python,content
|
| 400 |
+
400,645319,"genie.py",8478,0,"",python,selection_keyboard
|
| 401 |
+
401,645496,"genie.py",8478,0,"t",python,content
|
| 402 |
+
402,645497,"genie.py",8479,0,"",python,selection_keyboard
|
| 403 |
+
403,653294,"genie.py",8479,0," = einops.rearrange(final_token_probs, ""b s n -> b (s n)"")",python,content
|
| 404 |
+
404,664215,"genie.py",8556,0,"",python,selection_mouse
|
| 405 |
+
405,665816,"genie.py",8589,0,"",python,selection_mouse
|
| 406 |
+
406,676623,"genie.py",8589,0,"_flat",python,content
|
| 407 |
+
407,677657,"genie.py",8609,0,"",python,selection_mouse
|
| 408 |
+
408,677806,"genie.py",8605,10,"descending",python,selection_mouse
|
| 409 |
+
409,678021,"genie.py",8605,11,"descending=",python,selection_mouse
|
| 410 |
+
410,678028,"genie.py",8605,15,"descending=True",python,selection_mouse
|
| 411 |
+
411,678495,"genie.py",8605,15,"",python,content
|
| 412 |
+
412,678605,"genie.py",8604,1,"",python,content
|
| 413 |
+
413,678911,"genie.py",8603,1,"",python,content
|
| 414 |
+
414,680061,"genie.py",8604,0,"",python,selection_mouse
|
| 415 |
+
415,682310,"genie.py",8704,0,"",python,selection_mouse
|
| 416 |
+
416,682869,"genie.py",8623,0,"",python,selection_mouse
|
| 417 |
+
417,685402,"genie.py",8564,0,"",python,selection_mouse
|
| 418 |
+
418,686903,"genie.py",8563,0,"",python,selection_command
|
| 419 |
+
419,688625,"genie.py",8562,0,"",python,selection_command
|
| 420 |
+
420,688806,"genie.py",8604,0,"\n ",python,content
|
| 421 |
+
421,689038,"genie.py",8613,0,"m",python,content
|
| 422 |
+
422,689039,"genie.py",8614,0,"",python,selection_keyboard
|
| 423 |
+
423,689135,"genie.py",8614,0,"a",python,content
|
| 424 |
+
424,689136,"genie.py",8615,0,"",python,selection_keyboard
|
| 425 |
+
425,689180,"genie.py",8615,0,"s",python,content
|
| 426 |
+
426,689182,"genie.py",8616,0,"",python,selection_keyboard
|
| 427 |
+
427,689294,"genie.py",8616,0,"k",python,content
|
| 428 |
+
428,689295,"genie.py",8617,0,"",python,selection_keyboard
|
| 429 |
+
429,689847,"genie.py",8617,0,"_",python,content
|
| 430 |
+
430,689849,"genie.py",8618,0,"",python,selection_keyboard
|
| 431 |
+
431,690458,"genie.py",8618,0,"f",python,content
|
| 432 |
+
432,690459,"genie.py",8619,0,"",python,selection_keyboard
|
| 433 |
+
433,690502,"genie.py",8619,0,"l",python,content
|
| 434 |
+
434,690503,"genie.py",8620,0,"",python,selection_keyboard
|
| 435 |
+
435,690655,"genie.py",8620,0,"a",python,content
|
| 436 |
+
436,690656,"genie.py",8621,0,"",python,selection_keyboard
|
| 437 |
+
437,690901,"genie.py",8621,0,"t",python,content
|
| 438 |
+
438,690903,"genie.py",8622,0,"",python,selection_keyboard
|
| 439 |
+
439,691121,"genie.py",8622,0," ",python,content
|
| 440 |
+
440,691122,"genie.py",8623,0,"",python,selection_keyboard
|
| 441 |
+
441,691566,"genie.py",8623,0,"= einops.rearrange(mask, ""b s n -> b (s n)"")",python,content
|
| 442 |
+
442,705699,"genie.py",8613,0,"",python,selection_command
|
| 443 |
+
443,707905,"genie.py",8605,63,"",python,content
|
| 444 |
+
444,707922,"genie.py",8613,0,"",python,selection_command
|
| 445 |
+
445,708062,"genie.py",8682,0,"\n mask_flat = einops.rearrange(mask, ""b s n -> b (s n)"")",python,content
|
| 446 |
+
446,708063,"genie.py",8691,0,"",python,selection_command
|
| 447 |
+
447,713388,"genie.py",8799,0," new_mask = einops.rearrange(new_mask, ""b (s n) -> b s n"")\n",python,content
|
| 448 |
+
448,713389,"genie.py",8784,0,"_flat",python,content
|
| 449 |
+
449,721894,"genie.py",8762,0,"",python,selection_mouse
|
| 450 |
+
450,723325,"genie.py",8762,0,"_",python,content
|
| 451 |
+
451,723326,"genie.py",8763,0,"",python,selection_keyboard
|
| 452 |
+
452,723699,"genie.py",8763,0,"f",python,content
|
| 453 |
+
453,723700,"genie.py",8764,0,"",python,selection_keyboard
|
| 454 |
+
454,723781,"genie.py",8764,0,"l",python,content
|
| 455 |
+
455,723782,"genie.py",8765,0,"",python,selection_keyboard
|
| 456 |
+
456,723967,"genie.py",8765,0,"a",python,content
|
| 457 |
+
457,723968,"genie.py",8766,0,"",python,selection_keyboard
|
| 458 |
+
458,724104,"genie.py",8766,0,"t",python,content
|
| 459 |
+
459,724105,"genie.py",8767,0,"",python,selection_keyboard
|
| 460 |
+
460,725501,"genie.py",8853,0,"_flat",python,content
|
| 461 |
+
461,725502,"genie.py",8858,0,"",python,selection_command
|
| 462 |
+
462,728250,"genie.py",8880,0,"",python,selection_mouse
|
| 463 |
+
463,729814,"genie.py",8878,0,"",python,selection_mouse
|
| 464 |
+
464,731280,"genie.py",8878,0,",",python,content
|
| 465 |
+
465,731281,"genie.py",8879,0,"",python,selection_keyboard
|
| 466 |
+
466,731433,"genie.py",8879,0," ",python,content
|
| 467 |
+
467,731434,"genie.py",8880,0,"",python,selection_keyboard
|
| 468 |
+
468,731757,"genie.py",8880,0,"n",python,content
|
| 469 |
+
469,731758,"genie.py",8881,0,"",python,selection_keyboard
|
| 470 |
+
470,732730,"genie.py",8881,0,"=N",python,content
|
| 471 |
+
471,733666,"genie.py",8885,0,"",python,selection_mouse
|
| 472 |
+
472,770425,"genie.py",9190,0,"",python,selection_mouse
|
| 473 |
+
473,836690,"TERMINAL",0,0,"\r[K[?1l>]0;tum_cte0515@hkn1991:~/Projects/tmp/jafar]633;D;0",,terminal_output
|
| 474 |
+
474,838681,"TERMINAL",0,0,"git status",,terminal_command
|
| 475 |
+
475,838691,"TERMINAL",0,0,"]633;E;2025-08-03 16:42:10 git status;d4f80100-2225-40b3-b029-72e571a8ef11]633;COn branch genie-sampling\r\nYour branch is up to date with 'origin/genie-sampling'.\r\n\r\nChanges not staged for commit:\r\n (use ""git add <file>..."" to update what will be committed)\r\n (use ""git restore <file>..."" to discard changes in working directory)\r\n\t[31mmodified: genie.py[m\r\n\r\nno changes added to commit (use ""git add"" and/or ""git commit -a"")\r\n]0;tum_cte0515@hkn1991:~/Projects/tmp/jafar]633;D;0",,terminal_output
|
| 476 |
+
476,843701,"TERMINAL",0,0,"git add genie.py",,terminal_command
|
| 477 |
+
477,843735,"TERMINAL",0,0,"]633;E;2025-08-03 16:42:15 git add genie.py ;d4f80100-2225-40b3-b029-72e571a8ef11]633;C]0;tum_cte0515@hkn1991:~/Projects/tmp/jafar]633;D;0]633;P;Cwd=/home/hk-project-p0023960/tum_cte0515/Projects/tmp/jafar",,terminal_output
|
| 478 |
+
478,851838,"TERMINAL",0,0,"git status",,terminal_command
|
| 479 |
+
479,858510,"TERMINAL",0,0,"git restore --staged genie.py",,terminal_command
|
| 480 |
+
480,864026,"TERMINAL",0,0,"git diff > diff.diff",,terminal_command
|
| 481 |
+
481,866790,"diff.diff",0,0,"diff --git a/genie.py b/genie.py\nindex 50729ab..dfa352c 100644\n--- a/genie.py\n+++ b/genie.py\n@@ -4,6 +4,7 @@ from orbax.checkpoint import PyTreeCheckpointer\n import jax\n import jax.numpy as jnp\n import flax.linen as nn\n+import einops\n \n from models.dynamics import DynamicsMaskGIT\n from models.lam import LatentActionModel\n@@ -87,25 +88,42 @@ class Genie(nn.Module):\n def sample(\n self,\n batch: Dict[str, Any],\n+ seq_len: int,\n steps: int = 25,\n- temperature: int = 1,\n+ temperature: float = 1,\n sample_argmax: bool = False,\n ) -> Any:\n+ """"""\n+ Autoregressively samples up to `seq_len` future frames, following Figure 8 of the paper.\n+\n+ - Input frames are tokenized once.\n+ - Future frames are generated autoregressively in token space.\n+ - All frames are detokenized in a single pass.\n+\n+ Note:\n+ - For interactive or step-wise sampling, detokenization should occur after each action.\n+ - To maintain consistent tensor shapes across timesteps, all current and future frames are decoded at every step.\n+ - Temporal causal structure is preserved by \n+ a) reapplying the mask before each decoding step.\n+ b) a temporal causal mask is applied within each ST-transformer block.\n+\n+ Dimension keys:\n+ B: batch size \n+ T: number of input (conditioning) frames \n+ N: patches per frame \n+ S: sequence length \n+ A: action space \n+ D: model latent dimension\n+ """"""\n # --- Encode videos and actions ---\n tokenizer_out = self.tokenizer.vq_encode(batch[""videos""], training=False)\n- token_idxs = tokenizer_out[""indices""]\n- new_frame_idxs = jnp.zeros_like(token_idxs)[:, 0]\n+ token_idxs = tokenizer_out[""indices""] # (B, T, N)\n+ B, T, N = token_idxs.shape\n+ pad_shape = (B, seq_len - T, N)\n+ pad = jnp.zeros(pad_shape, dtype=token_idxs.dtype)\n+ token_idxs = jnp.concatenate([token_idxs, pad], axis=1) # (B, S, N)\n action_tokens = self.lam.vq.get_codes(batch[""latent_actions""])\n \n- # --- Initialize MaskGIT ---\n- init_mask = jnp.ones_like(token_idxs, dtype=bool)[:, 0]\n- init_carry = (\n- batch[""rng""],\n- new_frame_idxs,\n- init_mask,\n- token_idxs,\n- action_tokens,\n- )\n MaskGITLoop = nn.scan(\n MaskGITStep,\n variable_broadcast=""params"",\n@@ -123,13 +141,45 @@ class Genie(nn.Module):\n sample_argmax=sample_argmax,\n steps=steps,\n )\n- final_carry, _ = loop_fn(init_carry, jnp.arange(steps))\n- new_frame_idxs = final_carry[1]\n- new_frame_pixels = self.tokenizer.decode(\n- jnp.expand_dims(new_frame_idxs, 1),\n+\n+ def generation_step_fn(carry, step_t):\n+ rng, current_token_idxs = carry\n+ rng, step_rng = jax.random.split(rng)\n+\n+ # Mask current frame (future frames are masked by default using causal mask in ST-transformer)\n+ mask = jnp.arange(seq_len) == step_t # (S,)\n+ mask = jnp.broadcast_to(mask[None, :, None], (B, seq_len, N)) # (B, S, N)\n+ mask = mask.astype(bool)\n+ masked_token_idxs = current_token_idxs * ~mask\n+\n+ # --- Initialize and run MaskGIT loop ---\n+ init_carry_maskgit = (\n+ step_rng,\n+ masked_token_idxs,\n+ mask,\n+ action_tokens,\n+ )\n+ final_carry_maskgit, _ = loop_fn(init_carry_maskgit, jnp.arange(steps))\n+ updated_token_idxs = final_carry_maskgit[1]\n+ new_carry = (rng, updated_token_idxs)\n+ return new_carry, None\n+\n+ # --- Run the autoregressive generation using scan ---\n+ initial_carry = (batch[""rng""], token_idxs)\n+ timesteps_to_scan = jnp.arange(T, seq_len)\n+ final_carry, _ = jax.lax.scan(\n+ generation_step_fn,\n+ initial_carry,\n+ timesteps_to_scan\n+ )\n+ final_token_idxs = final_carry[1]\n+\n+ # --- Decode all tokens at once at the end ---\n+ final_frames = self.tokenizer.decode(\n+ final_token_idxs,\n video_hw=batch[""videos""].shape[2:4],\n )\n- return new_frame_pixels\n+ return final_frames\n \n def vq_encode(self, batch, training) -> Dict[str, Any]:\n # --- Preprocess videos ---\n@@ -181,10 +231,13 @@ class MaskGITStep(nn.Module):\n \n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n- idx_mask = jnp.arange(final_token_probs.shape[-1]) > num_unmasked_tokens\n- sorted_idxs = jnp.argsort(final_token_probs, axis=-1, descending=True)\n+ idx_mask = jnp.arange(final_token_probs.shape[-1]) <= N - num_unmasked_tokens\n+ final_token_probs_flat = einops.rearrange(final_token_probs, ""b s n -> b (s n)"")\n+ sorted_idxs = jnp.argsort(final_token_probs_flat, axis=-1)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask))\n- new_mask = mask_update_fn(mask, sorted_idxs)\n+ mask_flat = einops.rearrange(mask, ""b s n -> b (s n)"")\n+ new_mask_flat = mask_update_fn(mask_flat, sorted_idxs)\n+ new_mask = einops.rearrange(new_mask_flat, ""b (s n) -> b s n"", n=N)\n \n new_carry = (rng, token_idxs, new_mask, action_tokens)\n return new_carry, None\n",diff,tab
|
| 482 |
+
482,867593,"diff.diff",752,0,"",diff,selection_mouse
|
| 483 |
+
483,868584,"diff.diff",0,0,"",diff,selection_command
|
| 484 |
+
484,868943,"diff.diff",0,32,"diff --git a/genie.py b/genie.py",diff,selection_command
|
| 485 |
+
485,869351,"diff.diff",0,5545,"diff --git a/genie.py b/genie.py\nindex 50729ab..dfa352c 100644\n--- a/genie.py\n+++ b/genie.py\n@@ -4,6 +4,7 @@ from orbax.checkpoint import PyTreeCheckpointer\n import jax\n import jax.numpy as jnp\n import flax.linen as nn\n+import einops\n \n from models.dynamics import DynamicsMaskGIT\n from models.lam import LatentActionModel\n@@ -87,25 +88,42 @@ class Genie(nn.Module):\n def sample(\n self,\n batch: Dict[str, Any],\n+ seq_len: int,\n steps: int = 25,\n- temperature: int = 1,\n+ temperature: float = 1,\n sample_argmax: bool = False,\n ) -> Any:\n+ """"""\n+ Autoregressively samples up to `seq_len` future frames, following Figure 8 of the paper.\n+\n+ - Input frames are tokenized once.\n+ - Future frames are generated autoregressively in token space.\n+ - All frames are detokenized in a single pass.\n+\n+ Note:\n+ - For interactive or step-wise sampling, detokenization should occur after each action.\n+ - To maintain consistent tensor shapes across timesteps, all current and future frames are decoded at every step.\n+ - Temporal causal structure is preserved by \n+ a) reapplying the mask before each decoding step.\n+ b) a temporal causal mask is applied within each ST-transformer block.\n+\n+ Dimension keys:\n+ B: batch size \n+ T: number of input (conditioning) frames \n+ N: patches per frame \n+ S: sequence length \n+ A: action space \n+ D: model latent dimension\n+ """"""\n # --- Encode videos and actions ---\n tokenizer_out = self.tokenizer.vq_encode(batch[""videos""], training=False)\n- token_idxs = tokenizer_out[""indices""]\n- new_frame_idxs = jnp.zeros_like(token_idxs)[:, 0]\n+ token_idxs = tokenizer_out[""indices""] # (B, T, N)\n+ B, T, N = token_idxs.shape\n+ pad_shape = (B, seq_len - T, N)\n+ pad = jnp.zeros(pad_shape, dtype=token_idxs.dtype)\n+ token_idxs = jnp.concatenate([token_idxs, pad], axis=1) # (B, S, N)\n action_tokens = self.lam.vq.get_codes(batch[""latent_actions""])\n \n- # --- Initialize MaskGIT ---\n- init_mask = jnp.ones_like(token_idxs, dtype=bool)[:, 0]\n- init_carry = (\n- batch[""rng""],\n- new_frame_idxs,\n- init_mask,\n- token_idxs,\n- action_tokens,\n- )\n MaskGITLoop = nn.scan(\n MaskGITStep,\n variable_broadcast=""params"",\n@@ -123,13 +141,45 @@ class Genie(nn.Module):\n sample_argmax=sample_argmax,\n steps=steps,\n )\n- final_carry, _ = loop_fn(init_carry, jnp.arange(steps))\n- new_frame_idxs = final_carry[1]\n- new_frame_pixels = self.tokenizer.decode(\n- jnp.expand_dims(new_frame_idxs, 1),\n+\n+ def generation_step_fn(carry, step_t):\n+ rng, current_token_idxs = carry\n+ rng, step_rng = jax.random.split(rng)\n+\n+ # Mask current frame (future frames are masked by default using causal mask in ST-transformer)\n+ mask = jnp.arange(seq_len) == step_t # (S,)\n+ mask = jnp.broadcast_to(mask[None, :, None], (B, seq_len, N)) # (B, S, N)\n+ mask = mask.astype(bool)\n+ masked_token_idxs = current_token_idxs * ~mask\n+\n+ # --- Initialize and run MaskGIT loop ---\n+ init_carry_maskgit = (\n+ step_rng,\n+ masked_token_idxs,\n+ mask,\n+ action_tokens,\n+ )\n+ final_carry_maskgit, _ = loop_fn(init_carry_maskgit, jnp.arange(steps))\n+ updated_token_idxs = final_carry_maskgit[1]\n+ new_carry = (rng, updated_token_idxs)\n+ return new_carry, None\n+\n+ # --- Run the autoregressive generation using scan ---\n+ initial_carry = (batch[""rng""], token_idxs)\n+ timesteps_to_scan = jnp.arange(T, seq_len)\n+ final_carry, _ = jax.lax.scan(\n+ generation_step_fn,\n+ initial_carry,\n+ timesteps_to_scan\n+ )\n+ final_token_idxs = final_carry[1]\n+\n+ # --- Decode all tokens at once at the end ---\n+ final_frames = self.tokenizer.decode(\n+ final_token_idxs,\n video_hw=batch[""videos""].shape[2:4],\n )\n- return new_frame_pixels\n+ return final_frames\n \n def vq_encode(self, batch, training) -> Dict[str, Any]:\n # --- Preprocess videos ---\n@@ -181,10 +231,13 @@ class MaskGITStep(nn.Module):\n \n # --- Update mask ---\n num_unmasked_tokens = jnp.round(N * (1.0 - unmasked_ratio)).astype(int)\n- idx_mask = jnp.arange(final_token_probs.shape[-1]) > num_unmasked_tokens\n- sorted_idxs = jnp.argsort(final_token_probs, axis=-1, descending=True)\n+ idx_mask = jnp.arange(final_token_probs.shape[-1]) <= N - num_unmasked_tokens\n+ final_token_probs_flat = einops.rearrange(final_token_probs, ""b s n -> b (s n)"")\n+ sorted_idxs = jnp.argsort(final_token_probs_flat, axis=-1)\n mask_update_fn = jax.vmap(lambda msk, ids: msk.at[ids].set(idx_mask))\n- new_mask = mask_update_fn(mask, sorted_idxs)\n+ mask_flat = einops.rearrange(mask, ""b s n -> b (s n)"")\n+ new_mask_flat = mask_update_fn(mask_flat, sorted_idxs)\n+ new_mask = einops.rearrange(new_mask_flat, ""b (s n) -> b s n"", n=N)\n \n new_carry = (rng, token_idxs, new_mask, action_tokens)\n return new_carry, None\n",diff,selection_command
|
| 486 |
+
486,955527,"genie.py",0,0,"",python,tab
|
| 487 |
+
487,957752,"sample.py",0,0,"",python,tab
|
| 488 |
+
488,979644,"sample.py",2976,0,"",python,selection_mouse
|
| 489 |
+
489,979646,"sample.py",2975,0,"",python,selection_command
|
| 490 |
+
490,979751,"sample.py",2975,1,"d",python,selection_mouse
|
| 491 |
+
491,979757,"sample.py",2976,0,"",python,selection_command
|
| 492 |
+
492,979778,"sample.py",2951,25,"\n return generated_vid",python,selection_mouse
|
| 493 |
+
493,979794,"sample.py",2931,45,"\n batch\n )\n return generated_vid",python,selection_mouse
|
| 494 |
+
494,979813,"sample.py",2895,81,"d_vid = sampling_fn(\n params,\n batch\n )\n return generated_vid",python,selection_mouse
|
| 495 |
+
495,979829,"sample.py",2785,191," _rng = jax.random.split(rng)\n batch = dict(videos=vid, latent_actions=action_batch, rng=_rng)\n generated_vid = sampling_fn(\n params,\n batch\n )\n return generated_vid",python,selection_mouse
|
| 496 |
+
496,979845,"sample.py",2669,307,"vid = video_batch[:, : args.start_frame + 1]\n sampling_fn = jax.jit(nn.apply(_sampling_wrapper, genie)) \n rng, _rng = jax.random.split(rng)\n batch = dict(videos=vid, latent_actions=action_batch, rng=_rng)\n generated_vid = sampling_fn(\n params,\n batch\n )\n return generated_vid",python,selection_mouse
|
| 497 |
+
497,979874,"sample.py",2615,361," _autoreg_sample(rng, video_batch, action_batch):\n vid = video_batch[:, : args.start_frame + 1]\n sampling_fn = jax.jit(nn.apply(_sampling_wrapper, genie)) \n rng, _rng = jax.random.split(rng)\n batch = dict(videos=vid, latent_actions=action_batch, rng=_rng)\n generated_vid = sampling_fn(\n params,\n batch\n )\n return generated_vid",python,selection_mouse
|
| 498 |
+
498,979918,"sample.py",2569,407,"-- Define autoregressive sampling loop ---\ndef _autoreg_sample(rng, video_batch, action_batch):\n vid = video_batch[:, : args.start_frame + 1]\n sampling_fn = jax.jit(nn.apply(_sampling_wrapper, genie)) \n rng, _rng = jax.random.split(rng)\n batch = dict(videos=vid, latent_actions=action_batch, rng=_rng)\n generated_vid = sampling_fn(\n params,\n batch\n )\n return generated_vid",python,selection_mouse
|
| 499 |
+
499,979960,"sample.py",2565,411,"\n# --- Define autoregressive sampling loop ---\ndef _autoreg_sample(rng, video_batch, action_batch):\n vid = video_batch[:, : args.start_frame + 1]\n sampling_fn = jax.jit(nn.apply(_sampling_wrapper, genie)) \n rng, _rng = jax.random.split(rng)\n batch = dict(videos=vid, latent_actions=action_batch, rng=_rng)\n generated_vid = sampling_fn(\n params,\n batch\n )\n return generated_vid",python,selection_mouse
|
| 500 |
+
500,979962,"sample.py",2461,515," return module.sample(batch, args.seq_len, args.maskgit_steps, args.temperature, args.sample_argmax)\n\n# --- Define autoregressive sampling loop ---\ndef _autoreg_sample(rng, video_batch, action_batch):\n vid = video_batch[:, : args.start_frame + 1]\n sampling_fn = jax.jit(nn.apply(_sampling_wrapper, genie)) \n rng, _rng = jax.random.split(rng)\n batch = dict(videos=vid, latent_actions=action_batch, rng=_rng)\n generated_vid = sampling_fn(\n params,\n batch\n )\n return generated_vid",python,selection_mouse
|
| 501 |
+
501,979966,"sample.py",2423,553,"def _sampling_wrapper(module, batch):\n return module.sample(batch, args.seq_len, args.maskgit_steps, args.temperature, args.sample_argmax)\n\n# --- Define autoregressive sampling loop ---\ndef _autoreg_sample(rng, video_batch, action_batch):\n vid = video_batch[:, : args.start_frame + 1]\n sampling_fn = jax.jit(nn.apply(_sampling_wrapper, genie)) \n rng, _rng = jax.random.split(rng)\n batch = dict(videos=vid, latent_actions=action_batch, rng=_rng)\n generated_vid = sampling_fn(\n params,\n batch\n )\n return generated_vid",python,selection_mouse
|
| 502 |
+
502,981058,"sample.py",2423,553,"",python,content
|
| 503 |
+
503,981438,"sample.py",2423,0,"def _sampling_wrapper(module, batch):\n return module.sample(batch, args.seq_len, args.maskgit_steps, args.temperature, args.sample_argmax)\n\n# --- Define autoregressive sampling loop ---\ndef _autoreg_sample(rng, video_batch, action_batch):\n vid = video_batch[:, : args.start_frame + 1]\n sampling_fn = jax.jit(nn.apply(_sampling_wrapper, genie)) \n rng, _rng = jax.random.split(rng)\n batch = dict(videos=vid, latent_actions=action_batch, rng=_rng)\n generated_vid = sampling_fn(\n params,\n batch\n )\n return generated_vid",python,content
|
| 504 |
+
504,983006,"sample.py",2977,0,"",python,selection_mouse
|
| 505 |
+
505,989842,"sample.py",2931,0,"",python,selection_mouse
|
| 506 |
+
506,990505,"sample.py",2951,0,"",python,selection_mouse
|
| 507 |
+
507,991263,"sample.py",2976,0,"",python,selection_mouse
|
| 508 |
+
508,992649,"genie.py",0,0,"",python,tab
|
| 509 |
+
509,1140179,"TERMINAL",0,0,"git push",,terminal_command
|
| 510 |
+
510,1140230,"TERMINAL",0,0,"]633;E;2025-08-03 16:47:12 git push;d4f80100-2225-40b3-b029-72e571a8ef11]633;C",,terminal_output
|
| 511 |
+
511,1141409,"TERMINAL",0,0,"Enumerating objects: 5, done.\r\nCounting objects: 20% (1/5)\rCounting objects: 40% (2/5)\rCounting objects: 60% (3/5)\rCounting objects: 80% (4/5)\rCounting objects: 100% (5/5)\rCounting objects: 100% (5/5), done.\r\nDelta compression using up to 152 threads\r\nCompressing objects: 33% (1/3)\rCompressing objects: 66% (2/3)\rCompressing objects: 100% (3/3)\rCompressing objects: 100% (3/3), done.\r\nWriting objects: 33% (1/3)\rWriting objects: 66% (2/3)\rWriting objects: 100% (3/3)\rWriting objects: 100% (3/3), 1.95 KiB | 667.00 KiB/s, done.\r\nTotal 3 (delta 2), reused 0 (delta 0), pack-reused 0\r\n",,terminal_output
|
| 512 |
+
512,1141563,"TERMINAL",0,0,"remote: Resolving deltas: 0% (0/2)[K\rremote: Resolving deltas: 50% (1/2)[K\rremote: Resolving deltas: 100% (2/2)[K\rremote: Resolving deltas: 100% (2/2), completed with 2 local objects.[K\r\n",,terminal_output
|
| 513 |
+
513,1141791,"TERMINAL",0,0,"To github.com:maharajamihir/jafar.git\r\n ec0d8b2..7fb86d7 genie-sampling -> genie-sampling\r\n]0;tum_cte0515@hkn1991:~/Projects/tmp/jafar]633;D;0",,terminal_output
|
| 514 |
+
514,1216550,"sample.py",0,0,"",python,tab
|
| 515 |
+
515,2056143,"genie.py",0,0,"",python,tab
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-07bd0028-3336-4375-9dd9-453a62e0affc1758023418620-2025_09_16-13.50.36.784/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-0e85c644-d3bf-4fc0-b546-5324075f1cc91757500459100-2025_09_10-12.34.40.648/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-1ae480a2-bc7d-4b65-b456-3679a88992ae1752076515942-2025_07_09-17.56.33.471/source.csv
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
2,24812,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"5:56:33 PM [info] Activating crowd-code\n5:56:33 PM [info] Recording started\n5:56:33 PM [info] Initializing git provider using file system watchers...\n5:56:33 PM [info] Git repository found\n5:56:33 PM [info] Git provider initialized successfully\n5:56:33 PM [info] Initial git state: [object Object]\n",Log,tab
|
| 3 |
+
3,25057,"TERMINAL",0,0,"idling",,terminal_command
|
| 4 |
+
4,25174,"TERMINAL",0,0,"[1;101H8[33d\t ",,terminal_output
|
| 5 |
+
5,26149,"TERMINAL",0,0,"[1;101H9[33d\t ",,terminal_output
|
| 6 |
+
6,27180,"TERMINAL",0,0,"[1;98H7:00[33d\t ",,terminal_output
|
| 7 |
+
7,28069,"TERMINAL",0,0,"/bin/python3 /hkfs/home/project/hk-project-p0023960/tum_cte0515/.cursor-server/extensions/ms-python.python-2024.12.3-linux-x64/python_files/printEnvVariablesToFile.py /hkfs/home/project/hk-project-p0023960/tum_cte0515/.cursor-server/extensions/ms-python.python-2024.12.3-linux-x64/python_files/deactivate/bash/envVars.txt",,terminal_command
|
| 8 |
+
8,28084,"TERMINAL",0,0,"]633;E;2025-07-09 17:57:01 /bin/python3 /hkfs/home/project/hk-project-p0023960/tum_cte0515/.cursor-server/extensions/ms-python.python-2024.12.3-linux-x64/python_files/printEnvVariablesToFile.py /hkfs/home/project/hk-project-p0023960/tum_cte0515/.cursor-server/extensions/ms-python.python-2024.12.3-linux-x64/python_files/deactivate/bash/envVars.txt;2757b4f9-70d1-4da5-bad7-c693a73e7031]633;C]0;tum_cte0515@hkn1990:/hkfs/home/project/hk-project-p0023960/tum_cte0515/.cursor-server/extensions/ms-python.python-2024.12.3-linux-x64/python_files/deactivate/bash]633;D;0",,terminal_output
|
| 9 |
+
9,28308,"TERMINAL",0,0,"[1;101H1[33d\t ",,terminal_output
|
| 10 |
+
10,29257,"TERMINAL",0,0,"[1;101H2[33d\t ",,terminal_output
|
| 11 |
+
11,30300,"TERMINAL",0,0,"[1;101H3[33d\t ",,terminal_output
|
| 12 |
+
12,31342,"TERMINAL",0,0,"[1;101H4[33d\t ",,terminal_output
|
| 13 |
+
13,32408,"TERMINAL",0,0,"[1;101H5[33d\t ",,terminal_output
|
| 14 |
+
14,33443,"TERMINAL",0,0,"[H[2JEvery 1.0s: sinfo_t_idle[1;61Hhkn1990.localdomain: Wed Jul 9 17:57:06 2025[3;1HPartition dev_cpuonly[3;35H: 10 nodes idle\r[4dPartition cpuonly[4;35H:\t 8 nodes idle\r[5dPartition dev_accelerated[5;35H:\t 0 nodes idle\r[6dPartition accelerated[6;35H:\t 2 nodes idle\r[7dPartition dev_accelerated-h100 :\t 1 nodes idle\r[8dPartition accelerated-h100[8;35H:\t 0 nodes idle\r[9dPartition large[9;35H:\t 7 nodes idle[33;105H",,terminal_output
|
| 15 |
+
15,33641,"TERMINAL",0,0,"[H[2JEvery 1.0s: sinfo_t_idle[1;54Hhkn1990.localdomain: Wed Jul 9 17:57:06 2025[3;1HPartition dev_cpuonly[3;35H: 10 nodes idle\r[4dPartition cpuonly[4;35H:\t 8 nodes idle\r[5dPartition dev_accelerated[5;35H:\t 0 nodes idle\r[6dPartition accelerated[6;35H:\t 2 nodes idle\r[7dPartition dev_accelerated-h100 :\t 1 nodes idle\r[8dPartition accelerated-h100[8;35H:\t 0 nodes idle\r[9dPartition large[9;35H:\t 7 nodes idle[33;98H[H[2JEvery 1.0s: sinfo_t_idle[1;46Hhkn1990.localdomain: Wed Jul 9 17:57:06 2025[3;1HPartition dev_cpuonly[3;35H: 10 nodes idle\r[4dPartition cpuonly[4;35H:\t 8 nodes idle\r[5dPartition dev_accelerated[5;35H:\t 0 nodes idle\r[6dPartition accelerated[6;35H:\t 2 nodes idle\r[7dPartition dev_accelerated-h100 :\t 1 nodes idle\r[8dPartition accelerated-h100[8;35H:\t 0 nodes idle\r[9dPartition large[9;35H:\t 7 nodes idle[33;90H",,terminal_output
|
| 16 |
+
16,33773,"TERMINAL",0,0,"[H[2JEvery 1.0s: sinfo_t_idle[1;45Hhkn1990.localdomain: Wed Jul 9 17:57:07 2025[3;1HPartition dev_cpuonly[3;35H: 10 nodes idle\r[4dPartition cpuonly[4;35H:\t 8 nodes idle\r[5dPartition dev_accelerated[5;35H:\t 0 nodes idle\r[6dPartition accelerated[6;35H:\t 2 nodes idle\r[7dPartition dev_accelerated-h100 :\t 1 nodes idle\r[8dPartition accelerated-h100[8;35H:\t 0 nodes idle\r[9dPartition large[9;35H:\t 7 nodes idle[33;89H",,terminal_output
|
| 17 |
+
17,34764,"TERMINAL",0,0,"[H[2JEvery 1.0s: sinfo_t_idle[1;44Hhkn1990.localdomain: Wed Jul 9 17:57:08 2025[3;1HPartition dev_cpuonly[3;35H: 10 nodes idle\r[4dPartition cpuonly[4;35H:\t 8 nodes idle\r[5dPartition dev_accelerated[5;35H:\t 0 nodes idle\r[6dPartition accelerated[6;35H:\t 2 nodes idle\r[7dPartition dev_accelerated-h100 :\t 1 nodes idle\r[8dPartition accelerated-h100[8;35H:\t 0 nodes idle\r[9dPartition large[9;35H:\t 7 nodes idle[33;88H",,terminal_output
|
| 18 |
+
18,35879,"TERMINAL",0,0,"[1;83H9[33;88H",,terminal_output
|
| 19 |
+
19,36786,"TERMINAL",0,0,"[33;1H[?1049l[23;0;0t\r[?1l>]0;tum_cte0515@hkn1990:~/Projects/jafar]633;D;0",,terminal_output
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-249f1768-ea07-4d12-8b50-2383233eade61754215674347-2025_08_03-12.08.35.58/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-311b67df-2f46-4805-a16c-07606ec1fc001751032376516-2025_06_27-15.53.06.902/source.csv
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
2,275,"tasks",0,0,"",Log,tab
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-66197d0b-1341-4b69-bb71-811a07151bee1759437984150-2025_10_02-22.47.02.640/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-8bf77bbd-2546-4cc2-b4c2-aa8a23cdc8e51758545574283-2025_09_22-14.53.22.970/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-8ebe1d51-f3d9-465d-9dcc-9f20b1658e961759413231847-2025_10_02-15.54.19.385/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-a61250bb-ca2a-471a-a3f2-baf03ed793791758104983691-2025_09_17-12.30.25.600/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-b6479f87-a6dd-4f48-918b-47aeda5068fc1750926520523-2025_06_26-10.29.13.179/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-b8280b40-f43a-4e79-816b-40c4a8f904a41757329807390-2025_09_08-13.11.16.646/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-cccb8167-b56c-49f5-8a6d-fb1d433ccf181754984083218-2025_08_12-09.36.49.473/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-dd953f38-c05c-432b-887a-f1b903a654ea1757946579500-2025_09_15-16.29.47.578/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-ef114a72-0eb6-4a23-a381-0f0468cdd19e1758035815330-2025_09_16-17.17.38.386/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-f95bc203-868d-4b00-95ac-111a3a77ba441753772820552-2025_07_29-09.07.39.448/source.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
927a8af5474e5654810c00ce2e09fd2de87d3e5722f33fa1090d867db114e403/crowd-code-fbdad54f-458b-4a49-b398-aff5c8bb59901759170581539-2025_09_29-20.30.43.940/source.csv
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sequence,Time,File,RangeOffset,RangeLength,Text,Language,Type
|
| 2 |
+
1,5,"slurm/jobs/mihir/horeka/jafar_og_reproduction/og_coinrun_dynamics_reproduction.sbatch",0,0,"#!/usr/bin/env bash\n\n#SBATCH --nodes=1\n#SBATCH --ntasks-per-node=1\n#SBATCH --time=2-00:00:00\n#SBATCH --cpus-per-task=8\n#SBATCH --gres=gpu:1\n#SBATCH --partition=accelerated\n#SBATCH --output=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/jafar_og_reproduction/dynamics/%x_%j.log\n#SBATCH --error=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/jafar_og_reproduction/dynamics/%x_%j.log\n#SBATCH --job-name=train_dynamics_coinrun_og_reproduction\n\n# Log the sbatch script\ncat $0\n\nsource .venv/bin/activate\n\njob_name=$SLURM_JOB_NAME\nslurm_job_id=$SLURM_JOB_ID\n\ntags=""coinrun_og dynanmics 10m_dataset repro_mihir""\n\nnpy_records_dir=""/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_coinrun/coinrun_episodes_10m""\n\n# TODO mihir: update the tokenizer and lam checkpoints\ntokenizer_ckpt_dir=""""\nlam_ckpt_dir=""""\n\nCHECKPOINT_DIR=""/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/mihir/jafar_og_reproduction/dynamics/${job_name}/${slurm_job_id}""\nmkdir -p $CHECKPOINT_DIR\n\nenv | grep SLURM\n\nsrun python jasmine/train_dynamics.py \\n --ckpt_dir $CHECKPOINT_DIR \\n --tokenizer_checkpoint=""${tokenizer_ckpt_dir}"" \\n --lam_checkpoint=""${lam_ckpt_dir}"" \\n --log_image_interval=1000 \\n --log \\n --name=""${job_name}_${slurm_job_id}"" \\n --tags ${tags} \\n --entity instant-uv \\n --project jafar \\n --data_dir $npy_records_dir \\n --wandb_id $slurm_job_id\n",shellscript,tab
|
| 3 |
+
2,613,"extension-output-pdoom-org.crowd-code-#1-crowd-code",0,0,"8:30:43 PM [info] Activating crowd-code\n8:30:43 PM [info] Recording started\n8:30:43 PM [info] Initializing git provider using file system watchers...\n",Log,tab
|
| 4 |
+
3,1003,"extension-output-pdoom-org.crowd-code-#1-crowd-code",150,0,"8:30:44 PM [info] Git repository found\n8:30:44 PM [info] Git provider initialized successfully\n8:30:44 PM [info] Initial git state: [object Object]\n",Log,content
|
| 5 |
+
4,1594,"slurm/jobs/mihir/horeka/jafar_og_reproduction/og_coinrun_dynamics_reproduction.sbatch",0,0,"",shellscript,tab
|
| 6 |
+
5,13198,"slurm/jobs/mihir/horeka/minecraft/default_runs/train_tokenizer_8_nodes.sbatch",0,0,"#!/usr/bin/env bash\n\n#SBATCH --nodes=8\n#SBATCH --ntasks-per-node=4\n#SBATCH --time=48:00:00\n#SBATCH --partition=accelerated\n#SBATCH --cpus-per-task=5\n#SBATCH --gres=gpu:4\n#SBATCH --output=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/%x_%j.log\n#SBATCH --error=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/%x_%j.log\n#SBATCH --job-name=train_tokenizer_batch_size_scaling_8_node\n#SBATCH --mem=100G\n#SBATCH --requeue\n#SBATCH --signal=b:usr1@300 # 5 min before timeout\n\n# --- signal trap to requeue job before timeout ---\nrequeue_job() {\n echo ""[$(date)] caught sigusr1 (timeout warning), requeueing slurm job $SLURM_JOB_ID...""\n # optional: trigger checkpoint saving here\n # e.g., touch $checkpoint_dir/requeue_trigger\n scontrol requeue $SLURM_JOB_ID\n exit 0\n}\n\ntrap requeue_job sigusr1\n\n# set checkpoint flag based on restart count\nrestart_count=$(scontrol show job $SLURM_JOB_ID | grep -o 'Restarts=[0-9]*' | cut -d'=' -f2)\n\nif [ $restart_count -eq 0 ]; then\n restore_ckpt_flag=""--no-restore-ckpt""\nelse\n restore_ckpt_flag=""--restore-ckpt""\nfi\n\n# Log the sbatch script\ncat $0\n\nmodule unload mpi/openmpi/5.0\nmodule unload devel/cuda/12.4\nsource .venv/bin/activate\n\narray_records_dir_train=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_minecraft/open_ai_minecraft_arrayrecords_chunked_train_val_split/train\narray_records_dir_val=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_minecraft/open_ai_minecraft_arrayrecords_chunked_train_val_split/val\n\njob_name=$SLURM_JOB_NAME\nslurm_job_id=$SLURM_JOB_ID\n\nCHECKPOINT_DIR=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/mihir/$job_name/$slurm_job_id\nmkdir -p $CHECKPOINT_DIR\n\nenv | grep SLURM\n\nsrun python jasmine/train_tokenizer.py \\n --ckpt_dir $CHECKPOINT_DIR \\n --batch_size=384 \\n --max_lr=3e-4 \\n --log_image_interval=1000 \\n --log_checkpoint_interval=1000 \\n --log \\n --patch_size=16 \\n --name=minecraft-tokenizer-default-$slurm_job_id \\n --tags minecraft-tokenizer default \\n --entity instant-uv \\n --project jafar \\n --data_dir $array_records_dir_train \\n --val_data_dir $array_records_dir_val &\n\nchild_pid=$!\n\nwait $child_pid\n",shellscript,tab
|
| 7 |
+
6,30897,"TERMINAL",0,0,"scancel 3528956",,terminal_command
|
| 8 |
+
7,30938,"TERMINAL",0,0,"]633;C]0;tum_cte0515@hkn1993:~/Projects/jasmine",,terminal_output
|
| 9 |
+
8,32401,"TERMINAL",0,0,"queue",,terminal_command
|
| 10 |
+
9,32502,"TERMINAL",0,0,"]633;C[?1049h[22;0;0t[1;16r(B[m[4l[?7h[H[2JEvery 1.0s: squeue --me[1;106Hhkn1993.localdomain: Mon Sep 29 20:31:16 2025[3;14HJOBID PARTITION NAME USER ST\tTIME NODES NODELIST(REASON)[4;12H3528956 accelerat train_la tum_cte0 CG 7:26:35\t 1 hkn0807[5;12H3528968 accelerat train_la tum_cte0 PD\t0:00\t 8 (Priority)[6;12H3528969 accelerat train_to tum_cte0 PD\t0:00\t 8 (Priority)[7;12H3528955 accelerat train_to tum_cte0 R 7:26:37\t 1 hkn0709[16;150H",,terminal_output
|
| 11 |
+
10,33557,"TERMINAL",0,0,"[1;145H7[7;60H8[16;150H",,terminal_output
|
| 12 |
+
11,34573,"TERMINAL",0,0,"[1;145H8[7;60H9[16;150H",,terminal_output
|
| 13 |
+
12,35644,"TERMINAL",0,0,"[1;145H9[7;59H40[16;150H",,terminal_output
|
| 14 |
+
13,36671,"TERMINAL",0,0,"[1;144H20[7;60H1[16;150H",,terminal_output
|
| 15 |
+
14,37746,"TERMINAL",0,0,"[1;145H1[7;60H2[16;150H",,terminal_output
|
| 16 |
+
15,38758,"TERMINAL",0,0,"[1;145H2[7;60H3[16;150H",,terminal_output
|
| 17 |
+
16,39787,"TERMINAL",0,0,"[1;145H3[7;60H4[16;150H",,terminal_output
|
| 18 |
+
17,40834,"TERMINAL",0,0,"[1;145H4[7;60H5[16;150H",,terminal_output
|
| 19 |
+
18,41911,"TERMINAL",0,0,"[1;145H5[7;60H6[16;150H",,terminal_output
|
| 20 |
+
19,42943,"TERMINAL",0,0,"[1;145H6[7;60H7[16;150H",,terminal_output
|
| 21 |
+
20,43627,"TERMINAL",0,0,"[16;1H[?1049l[23;0;0t\r[?1l>]0;tum_cte0515@hkn1993:~/Projects/jasmine",,terminal_output
|
| 22 |
+
21,48614,"TERMINAL",0,0,"source .venv/bin/activate",,terminal_command
|
| 23 |
+
22,54309,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",0,0,"#!/usr/bin/env bash\n\n#SBATCH --nodes=1\n#SBATCH --ntasks-per-node=1\n#SBATCH --time=48:00:00\n#SBATCH --partition=accelerated\n#SBATCH --cpus-per-task=5\n#SBATCH --gres=gpu:1\n#SBATCH --output=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/coinrun/lam/%x_%j.log\n#SBATCH --error=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/coinrun/lam/%x_%j.log\n#SBATCH --job-name=train_lam_default\n#SBATCH --requeue\n#SBATCH --signal=b:usr1@300 # 5 min before timeout\n\n# Log the sbatch script\ncat $0\n\nmodule unload mpi/openmpi/5.0\nmodule unload devel/cuda/12.4\nsource .venv/bin/activate\n\narray_records_dir_train=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_coinrun/coinrun_episodes_10m_gt_actions_split/train\narray_records_dir_val=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_coinrun/coinrun_episodes_10m_gt_actions_split/val\n\njob_name=$SLURM_JOB_NAME\nslurm_job_id=$SLURM_JOB_ID\n\nCHECKPOINT_DIR=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/big-runs/lam/$job_name/$slurm_job_id\nmkdir -p $CHECKPOINT_DIR\n\nenv | grep SLURM\n\nsrun python jasmine/train_lam.py \\n --save_ckpt \\n --image_height=64 \\n --image_width=64 \\n --ckpt_dir $CHECKPOINT_DIR \\n --batch_size=120 \\n --log \\n --name=coinrun-lam-default-$slurm_job_id \\n --tags lam coinrun default \\n --entity instant-uv \\n --project jafar \\n --data_dir $array_records_dir_train \\n --val_data_dir $array_records_dir_val \n",shellscript,tab
|
| 24 |
+
23,56801,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1228,0,"",shellscript,selection_mouse
|
| 25 |
+
24,57525,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1272,0,"",shellscript,selection_mouse
|
| 26 |
+
25,57528,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1271,0,"",shellscript,selection_command
|
| 27 |
+
26,58062,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1260,0,"",shellscript,selection_mouse
|
| 28 |
+
27,58076,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1259,0,"",shellscript,selection_command
|
| 29 |
+
28,58622,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1260,0,"\n ",shellscript,content
|
| 30 |
+
29,59305,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1265,0,"-",shellscript,content
|
| 31 |
+
30,59307,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1266,0,"",shellscript,selection_keyboard
|
| 32 |
+
31,59433,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1266,0,"-",shellscript,content
|
| 33 |
+
32,59435,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1267,0,"",shellscript,selection_keyboard
|
| 34 |
+
33,59632,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1267,0,"m",shellscript,content
|
| 35 |
+
34,59634,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1268,0,"",shellscript,selection_keyboard
|
| 36 |
+
35,59716,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1268,0,"a",shellscript,content
|
| 37 |
+
36,59717,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1269,0,"",shellscript,selection_keyboard
|
| 38 |
+
37,59899,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1269,0,"x",shellscript,content
|
| 39 |
+
38,59900,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1270,0,"",shellscript,selection_keyboard
|
| 40 |
+
39,60820,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1270,0,"_",shellscript,content
|
| 41 |
+
40,60822,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1271,0,"",shellscript,selection_keyboard
|
| 42 |
+
41,61106,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1271,0,"l",shellscript,content
|
| 43 |
+
42,61108,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1272,0,"",shellscript,selection_keyboard
|
| 44 |
+
43,61293,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1272,0,"r",shellscript,content
|
| 45 |
+
44,61295,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1273,0,"",shellscript,selection_keyboard
|
| 46 |
+
45,62052,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1273,0,"=",shellscript,content
|
| 47 |
+
46,62054,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1274,0,"",shellscript,selection_keyboard
|
| 48 |
+
47,63013,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1274,0,"1",shellscript,content
|
| 49 |
+
48,63017,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1275,0,"",shellscript,selection_keyboard
|
| 50 |
+
49,63419,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1274,1,"",shellscript,content
|
| 51 |
+
50,63628,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1274,0,"3",shellscript,content
|
| 52 |
+
51,63629,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1275,0,"",shellscript,selection_keyboard
|
| 53 |
+
52,65582,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1275,0,"e",shellscript,content
|
| 54 |
+
53,65585,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1276,0,"",shellscript,selection_keyboard
|
| 55 |
+
54,65720,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1276,0,"-",shellscript,content
|
| 56 |
+
55,65721,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1277,0,"",shellscript,selection_keyboard
|
| 57 |
+
56,66012,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1277,0,"5",shellscript,content
|
| 58 |
+
57,66013,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1278,0,"",shellscript,selection_keyboard
|
| 59 |
+
58,67875,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1278,0," ",shellscript,content
|
| 60 |
+
59,67877,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1279,0,"",shellscript,selection_keyboard
|
| 61 |
+
60,68053,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1279,0,"\",shellscript,content
|
| 62 |
+
61,68054,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1280,0,"",shellscript,selection_keyboard
|
| 63 |
+
62,68533,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1279,0,"",shellscript,selection_command
|
| 64 |
+
63,69773,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1275,0,"",shellscript,selection_mouse
|
| 65 |
+
64,75236,"jasmine/train_lam.py",0,0,"import os\n\nos.environ.setdefault(""XLA_PYTHON_CLIENT_MEM_FRACTION"", ""0.98"")\n\nfrom dataclasses import dataclass, field\nimport itertools\nfrom typing import cast, Optional\n\nimport einops\nfrom jax.sharding import Mesh, PartitionSpec, NamedSharding\nfrom jax.experimental.mesh_utils import create_device_mesh\nimport optax\nimport orbax.checkpoint as ocp\nimport numpy as np\nimport dm_pix as pix\nimport jax\nimport jax.numpy as jnp\nimport tyro\nimport wandb\nimport grain\nimport flax.nnx as nnx\n\nfrom models.lam import LatentActionModel\nfrom utils.dataloader import get_dataloader\nfrom utils.train_utils import (\n get_lr_schedule,\n count_parameters_by_component,\n print_mem_stats,\n print_compiled_memory_stats,\n print_compiled_cost_analysis,\n)\n\n\n@dataclass\nclass Args:\n # Experiment\n num_steps: int = 200_000\n seed: int = 0\n seq_len: int = 16\n image_channels: int = 3\n image_height: int = 90\n image_width: int = 160\n data_dir: str = """"\n save_ckpt: bool = False\n restore_ckpt: bool = False\n # Optimization\n batch_size: int = 36\n vq_beta: float = 0.25\n init_lr: float = 0.0\n max_lr: float = 3e-5\n decay_end: float = 0.0\n wsd_decay_steps: int = (\n 10000 # NOTE: wsd_decay_steps will only be used when using a wsd-schedule\n )\n warmup_steps: int = 5000\n lr_schedule: str = ""wsd"" # supported options: wsd, cos\n vq_reset_thresh: int = 50\n # LAM\n model_dim: int = 512\n ffn_dim: int = 2048\n latent_dim: int = 32\n num_latents: int = 6\n patch_size: int = 16\n num_blocks: int = 4\n num_heads: int = 8\n dropout: float = 0.0\n codebook_dropout: float = 0.0\n param_dtype = jnp.float32\n dtype = jnp.bfloat16\n # Logging\n log: bool = False\n entity: str = """"\n project: str = """"\n name: str = ""train_lam""\n tags: list[str] = field(default_factory=lambda: [""lam""])\n log_interval: int = 5\n log_image_interval: int = 250\n ckpt_dir: str = """"\n log_checkpoint_interval: int = 10000\n log_checkpoint_keep_period: int = 20000\n val_data_dir: str = """"\n val_interval: int = 20_000\n val_steps: int = 50\n wandb_id: str = """"\n use_flash_attention: bool = True\n\n\ndef build_model(args: Args, rng: jax.Array) -> tuple[LatentActionModel, jax.Array]:\n rng, _rng = jax.random.split(rng)\n rngs = nnx.Rngs(_rng)\n return (\n LatentActionModel(\n in_dim=args.image_channels,\n model_dim=args.model_dim,\n ffn_dim=args.ffn_dim,\n latent_dim=args.latent_dim,\n num_latents=args.num_latents,\n patch_size=args.patch_size,\n num_blocks=args.num_blocks,\n num_heads=args.num_heads,\n dropout=args.dropout,\n codebook_dropout=args.codebook_dropout,\n param_dtype=args.param_dtype,\n dtype=args.dtype,\n use_flash_attention=args.use_flash_attention,\n rngs=rngs,\n ),\n rng,\n )\n\n\ndef build_optimizer(model: LatentActionModel, args: Args) -> nnx.ModelAndOptimizer:\n lr_schedule = get_lr_schedule(\n args.lr_schedule,\n args.init_lr,\n args.max_lr,\n args.decay_end,\n args.num_steps,\n args.warmup_steps,\n args.wsd_decay_steps,\n )\n tx = optax.adamw(\n learning_rate=lr_schedule,\n b1=0.9,\n b2=0.9,\n weight_decay=1e-4,\n mu_dtype=args.param_dtype, # moments in full precision\n )\n optimizer = nnx.ModelAndOptimizer(model, tx)\n return optimizer\n\n\ndef build_mesh_and_sharding(\n num_devices: int,\n) -> tuple[Mesh, NamedSharding, NamedSharding]:\n device_mesh_arr = create_device_mesh((num_devices,))\n mesh = Mesh(devices=device_mesh_arr, axis_names=(""data"",))\n replicated_sharding = NamedSharding(mesh, PartitionSpec())\n videos_sharding = NamedSharding(mesh, PartitionSpec(""data"", None, None, None, None))\n return mesh, replicated_sharding, videos_sharding\n\n\ndef shard_optimizer_states(\n optimizer: nnx.ModelAndOptimizer, replicated_sharding: NamedSharding\n) -> None:\n model_state = nnx.state(optimizer.model)\n model_sharded_state = jax.lax.with_sharding_constraint(\n model_state, replicated_sharding\n )\n nnx.update(optimizer.model, model_sharded_state)\n optimizer_state = nnx.state(optimizer, nnx.optimizer.OptState)\n optimizer_sharded_state = jax.lax.with_sharding_constraint(\n optimizer_state, replicated_sharding\n )\n nnx.update(optimizer, optimizer_sharded_state)\n\n\ndef build_dataloader(args: Args, data_dir: str) -> grain.DataLoaderIterator:\n image_shape = (args.image_height, args.image_width, args.image_channels)\n array_record_files = [\n os.path.join(data_dir, x)\n for x in os.listdir(data_dir)\n if x.endswith("".array_record"")\n ]\n grain_dataloader = get_dataloader(\n array_record_files,\n args.seq_len,\n # NOTE: We deliberately pass the global batch size\n # The dataloader shards the dataset across all processes\n args.batch_size,\n *image_shape,\n num_workers=8,\n prefetch_buffer_size=1,\n seed=args.seed,\n )\n initial_state = grain_dataloader._create_initial_state()\n grain_iterator = grain.DataLoaderIterator(grain_dataloader, initial_state)\n return grain_iterator\n\n\ndef build_checkpoint_manager(args: Args) -> Optional[ocp.CheckpointManager]:\n if args.restore_ckpt or args.save_ckpt:\n handler_registry = ocp.handlers.DefaultCheckpointHandlerRegistry()\n handler_registry.add(\n ""model_state"", ocp.args.PyTreeSave, ocp.handlers.PyTreeCheckpointHandler\n )\n handler_registry.add(\n ""model_state"", ocp.args.PyTreeRestore, ocp.handlers.PyTreeCheckpointHandler\n )\n handler_registry.add(\n ""train_dataloader_state"",\n grain.checkpoint.CheckpointSave,\n cast(ocp.handlers.CheckpointHandler, grain.checkpoint.CheckpointHandler),\n )\n handler_registry.add(\n ""train_dataloader_state"",\n grain.checkpoint.CheckpointRestore,\n cast(ocp.handlers.CheckpointHandler, grain.checkpoint.CheckpointHandler),\n )\n if args.val_data_dir:\n handler_registry.add(\n ""val_dataloader_state"",\n grain.checkpoint.CheckpointSave,\n cast(\n ocp.handlers.CheckpointHandler, grain.checkpoint.CheckpointHandler\n ),\n )\n handler_registry.add(\n ""val_dataloader_state"",\n grain.checkpoint.CheckpointRestore,\n cast(\n ocp.handlers.CheckpointHandler, grain.checkpoint.CheckpointHandler\n ),\n )\n checkpoint_options = ocp.CheckpointManagerOptions(\n save_interval_steps=args.log_checkpoint_interval,\n max_to_keep=3,\n keep_period=args.log_checkpoint_keep_period,\n step_format_fixed_length=6,\n cleanup_tmp_directories=True,\n )\n checkpoint_manager = ocp.CheckpointManager(\n args.ckpt_dir,\n options=checkpoint_options,\n handler_registry=handler_registry,\n )\n return checkpoint_manager\n else:\n return None\n\n\ndef restore_checkpoint_if_needed(\n args: Args,\n checkpoint_manager: Optional[ocp.CheckpointManager],\n optimizer: nnx.ModelAndOptimizer,\n train_iterator: grain.DataLoaderIterator,\n val_iterator: Optional[grain.DataLoaderIterator],\n restore_step: Optional[int] = None,\n) -> tuple[\n int, nnx.ModelAndOptimizer, grain.DataLoaderIterator, grain.DataLoaderIterator\n]:\n step = 0\n if checkpoint_manager and restore_step is None:\n restore_step = checkpoint_manager.latest_step()\n if args.restore_ckpt:\n assert checkpoint_manager is not None\n abstract_optimizer = nnx.eval_shape(lambda: optimizer)\n abstract_optimizer_state = nnx.state(abstract_optimizer)\n if val_iterator:\n restore_args = ocp.args.Composite(\n model_state=ocp.args.PyTreeRestore(abstract_optimizer_state), # type: ignore\n train_dataloader_state=grain.checkpoint.CheckpointRestore(train_iterator), # type: ignore\n val_dataloader_state=grain.checkpoint.CheckpointRestore(val_iterator), # type: ignore\n )\n else:\n restore_args = ocp.args.Composite(\n model_state=ocp.args.PyTreeRestore(abstract_optimizer_state), # type: ignore\n train_dataloader_state=grain.checkpoint.CheckpointRestore(train_iterator), # type: ignore\n )\n restored = checkpoint_manager.restore(restore_step, args=restore_args)\n restored_optimizer_state = restored[""model_state""]\n nnx.update(optimizer, restored_optimizer_state)\n train_iterator = restored[""train_dataloader_state""]\n if val_iterator:\n val_iterator = restored[""val_dataloader_state""]\n step = restore_step or 0\n print(f""Restored dataloader and model state from step {step}"")\n return step, optimizer, train_iterator, val_iterator\n\n\ndef enable_sowing(lam: LatentActionModel) -> None:\n for model in [lam.encoder, lam.decoder]:\n setattr(model, ""sow_logits"", True)\n for blk in getattr(model, ""blocks"", []):\n setattr(blk, ""sow_weights"", True)\n setattr(blk, ""sow_activations"", True)\n\n\ndef main(args: Args) -> None:\n jax.distributed.initialize()\n num_devices = jax.device_count()\n if num_devices == 0:\n raise ValueError(""No JAX devices found."")\n print(f""Running on {num_devices} devices."")\n\n if args.batch_size % num_devices != 0:\n raise ValueError(\n f""Global batch size {args.batch_size} must be divisible by ""\n f""number of devices {num_devices}.""\n )\n\n rng = jax.random.key(args.seed)\n\n # --- Initialize model ---\n lam, rng = build_model(args, rng)\n\n # Count parameters\n _, params, _ = nnx.split(lam, nnx.Param, ...)\n param_counts = count_parameters_by_component(params)\n\n if args.log and jax.process_index() == 0:\n wandb_init_kwargs = {\n ""entity"": args.entity,\n ""project"": args.project,\n ""name"": args.name,\n ""tags"": args.tags,\n ""group"": ""debug"",\n ""config"": args,\n }\n\n if args.wandb_id:\n wandb_init_kwargs.update(\n {\n ""id"": args.wandb_id,\n ""resume"": ""allow"",\n }\n )\n wandb.init(**wandb_init_kwargs)\n\n wandb.config.update({""model_param_count"": param_counts})\n\n print(""Parameter counts:"")\n print(param_counts)\n\n # --- Initialize optimizer ---\n optimizer = build_optimizer(lam, args)\n del lam\n\n # FIXME: switch to create_hybrid_device_mesh for runs spanning multiple nodes\n _, replicated_sharding, videos_sharding = build_mesh_and_sharding(num_devices)\n\n shard_optimizer_states(optimizer, replicated_sharding)\n\n # --- Initialize checkpoint manager ---\n checkpoint_manager = build_checkpoint_manager(args)\n\n # --- Create DataLoaderIterator from dataloader ---\n train_iterator = build_dataloader(args, args.data_dir)\n val_iterator = None\n if args.val_data_dir:\n val_iterator = build_dataloader(args, args.val_data_dir)\n\n # --- Restore checkpoint ---\n step, optimizer, train_iterator, val_iterator = restore_checkpoint_if_needed(\n args, checkpoint_manager, optimizer, train_iterator, val_iterator\n )\n\n # --- Define loss and train step (close over args) ---\n def lam_loss_fn(\n model: LatentActionModel, inputs: dict, training: bool = True\n ) -> tuple[jax.Array, tuple[jax.Array, jax.Array, dict]]:\n gt = jnp.asarray(inputs[""videos""], dtype=jnp.float32) / 255.0\n inputs[""videos""] = gt.astype(args.dtype)\n outputs = model(inputs, training)\n outputs[""recon""] = outputs[""recon""].astype(jnp.float32)\n gt_future_frames = gt[:, 1:]\n mse = jnp.square(gt_future_frames - outputs[""recon""]).mean()\n q_loss = jnp.square(jax.lax.stop_gradient(outputs[""emb""]) - outputs[""z""]).mean()\n commitment_loss = jnp.square(\n outputs[""emb""] - jax.lax.stop_gradient(outputs[""z""])\n ).mean()\n loss = mse + q_loss + args.vq_beta * commitment_loss\n\n gt_val = gt_future_frames.clip(0, 1).reshape(-1, *gt_future_frames.shape[2:])\n recon = outputs[""recon""].clip(0, 1).reshape(-1, *outputs[""recon""].shape[2:])\n psnr = jnp.asarray(pix.psnr(gt_val, recon)).mean()\n ssim = jnp.asarray(pix.ssim(gt_val, recon)).mean()\n count_fn = jax.vmap(lambda i: (outputs[""indices""] == i).sum())\n index_counts = count_fn(jnp.arange(args.num_latents))\n metrics = dict(\n loss=loss,\n mse=mse,\n q_loss=q_loss,\n commitment_loss=commitment_loss,\n psnr=psnr,\n ssim=ssim,\n codebook_usage=(index_counts != 0).mean(),\n )\n return loss, (outputs[""recon""], index_counts, metrics)\n\n @nnx.jit(donate_argnums=0)\n def train_step(\n optimizer: nnx.ModelAndOptimizer,\n inputs: dict,\n action_last_active: jax.Array,\n rng: jax.Array,\n ) -> tuple[jax.Array, jax.Array, jax.Array, dict]:\n def loss_fn(\n model: LatentActionModel,\n ) -> tuple[jax.Array, tuple[jax.Array, jax.Array, dict]]:\n model.train()\n return lam_loss_fn(model, inputs, training=True)\n\n # --- Update model ---\n (loss, (recon, idx_counts, metrics)), grads = nnx.value_and_grad(\n loss_fn, has_aux=True\n )(optimizer.model)\n optimizer.update(grads)\n\n # --- Reset inactive latent actions ---\n codebook = optimizer.model.vq.codebook\n num_codes = len(codebook)\n active_codes = idx_counts != 0.0\n action_last_active = jnp.where(active_codes, 0, action_last_active + 1)\n p_code = active_codes / active_codes.sum()\n reset_idxs = jax.random.choice(rng, num_codes, shape=(num_codes,), p=p_code)\n do_reset = action_last_active >= args.vq_reset_thresh\n new_codebook = jnp.where(\n jnp.expand_dims(do_reset, -1), codebook[reset_idxs], codebook.value\n )\n optimizer.model.vq.codebook.value = new_codebook\n action_last_active = jnp.where(do_reset, 0, action_last_active)\n return loss, recon, action_last_active, metrics\n\n @nnx.jit\n def val_step(\n lam: LatentActionModel, inputs: dict\n ) -> tuple[jax.Array, jax.Array, dict]:\n lam.eval()\n (loss, (recon, _, metrics)) = lam_loss_fn(lam, inputs, training=False)\n return loss, recon, metrics\n\n def calculate_validation_metrics(val_dataloader, lam):\n step = 0\n loss_per_step = []\n metrics_per_step = []\n batch = None\n recon = None\n for batch in val_dataloader:\n loss, recon, metrics = val_step(lam, batch)\n loss_per_step.append(loss)\n metrics_per_step.append(metrics)\n step += 1\n if step > args.val_steps:\n break\n\n if step < args.val_steps:\n print(\n f""Warning: Your validation dataset is too small to make val_steps many steps. Made {step} steps, expected {args.val_steps}""\n )\n\n val_loss = np.mean(loss_per_step)\n val_metrics = {\n f""val_{key}"": np.mean([float(m[key]) for m in metrics_per_step])\n for key in metrics_per_step[0].keys()\n }\n val_metrics[""val_loss""] = val_loss\n return val_metrics, batch, recon\n\n # --- TRAIN LOOP ---\n dataloader_train = (\n {\n ""videos"": jax.make_array_from_process_local_data(\n videos_sharding, elem[""videos""]\n ),\n }\n for elem in train_iterator\n )\n dataloader_val = None\n if val_iterator:\n dataloader_val = (\n {\n ""videos"": jax.make_array_from_process_local_data(\n videos_sharding, elem[""videos""]\n ),\n }\n for elem in val_iterator\n )\n action_last_active = jnp.zeros(args.num_latents, dtype=jnp.int32)\n if jax.process_index() == 0:\n first_batch = next(dataloader_train)\n compiled = train_step.lower(\n optimizer, first_batch, action_last_active, rng\n ).compile()\n print_compiled_memory_stats(compiled.memory_analysis())\n print_compiled_cost_analysis(compiled.cost_analysis())\n # Do not skip the first batch during training\n dataloader_train = itertools.chain([first_batch], dataloader_train)\n print(f""Starting training from step {step}..."")\n first_step = step\n while step < args.num_steps:\n for batch in dataloader_train:\n # --- Train step ---\n rng, _rng = jax.random.split(rng, 2)\n loss, recon, action_last_active, metrics = train_step(\n optimizer, batch, action_last_active, _rng\n )\n if step == first_step:\n print_mem_stats(""After params initialized"")\n step += 1\n\n # --- Validation loss ---\n val_results = {}\n if dataloader_val and step % args.val_interval == 0:\n print(""Calculating validation metrics..."")\n val_metrics, val_gt_batch, val_recon = calculate_validation_metrics(\n dataloader_val, optimizer.model\n )\n print(f""Step {step}, validation loss: {val_metrics['val_loss']}"")\n val_results = {\n ""metrics"": val_metrics,\n ""gt_batch"": val_gt_batch,\n ""recon"": val_recon,\n }\n\n # --- Logging ---\n if args.log:\n if step % args.log_interval == 0 and jax.process_index() == 0:\n log_dict = {""loss"": loss, ""step"": step, **metrics}\n if val_results:\n log_dict.update(val_results[""metrics""])\n wandb.log(log_dict)\n if step % args.log_image_interval == 0:\n gt_seq = batch[""videos""][0, 1:].astype(jnp.float32) / 255.0\n recon_seq = recon[0].clip(0, 1)\n comparison_seq = jnp.concatenate((gt_seq, recon_seq), axis=1)\n comparison_seq = einops.rearrange(\n comparison_seq * 255, ""t h w c -> h (t w) c""\n )\n if val_results:\n val_results[""gt_seq_val""] = (\n val_results[""gt_batch""][""videos""][0, 1:].astype(jnp.float32)\n / 255.0\n )\n val_results[""recon_seq_val""] = val_results[""recon""][0].clip(\n 0, 1\n )\n val_results[""val_comparison_seq""] = jnp.concatenate(\n (val_results[""gt_seq_val""], val_results[""recon_seq_val""]),\n axis=1,\n )\n val_results[""val_comparison_seq""] = einops.rearrange(\n val_results[""val_comparison_seq""] * 255,\n ""t h w c -> h (t w) c"",\n )\n # NOTE: Process-dependent control flow deliberately happens\n # after indexing operation since it must not contain code\n # sections that lead to cross-accelerator communication.\n if jax.process_index() == 0:\n log_images = dict(\n image=wandb.Image(np.asarray(gt_seq[0])),\n recon=wandb.Image(np.asarray(recon_seq[0])),\n true_vs_recon=wandb.Image(\n np.asarray(comparison_seq.astype(np.uint8))\n ),\n )\n if val_results:\n log_images.update(\n {\n ""val_image"": wandb.Image(\n np.asarray(val_results[""gt_seq_val""][0])\n ),\n ""val_recon"": wandb.Image(\n np.asarray(val_results[""recon_seq_val""][0])\n ),\n ""val_true_vs_recon"": wandb.Image(\n np.asarray(\n val_results[""val_comparison_seq""].astype(\n np.uint8\n )\n )\n ),\n }\n )\n wandb.log(log_images)\n # --- Checkpointing ---\n if args.save_ckpt and step % args.log_checkpoint_interval == 0:\n assert checkpoint_manager is not None\n optimizer_state = nnx.state(optimizer)\n if val_iterator:\n ckpt_manager_args = ocp.args.Composite(\n model_state=ocp.args.PyTreeSave(optimizer_state), # type: ignore\n train_dataloader_state=grain.checkpoint.CheckpointSave( # type: ignore\n train_iterator # type: ignore\n ),\n val_dataloader_state=grain.checkpoint.CheckpointSave( # type: ignore\n val_iterator # type: ignore\n ),\n )\n else:\n ckpt_manager_args = ocp.args.Composite(\n model_state=ocp.args.PyTreeSave(optimizer_state), # type: ignore\n train_dataloader_state=grain.checkpoint.CheckpointSave( # type: ignore\n train_iterator # type: ignore\n ),\n )\n checkpoint_manager.save(step, args=ckpt_manager_args)\n print(f""Saved checkpoint at step {step}"")\n if step >= args.num_steps:\n break\n\n if checkpoint_manager:\n checkpoint_manager.close()\n\n\nif __name__ == ""__main__"":\n args = tyro.cli(Args)\n main(args)\n",python,tab
|
| 66 |
+
65,80162,"jasmine/train_lam.py",1124,0,"",python,selection_mouse
|
| 67 |
+
66,80346,"jasmine/train_lam.py",1120,6,"max_lr",python,selection_mouse
|
| 68 |
+
67,86383,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",0,0,"",shellscript,tab
|
| 69 |
+
68,89762,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1277,0,"",shellscript,selection_mouse
|
| 70 |
+
69,90944,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1277,1,"6",shellscript,content
|
| 71 |
+
70,93892,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1276,0,"",shellscript,selection_command
|
| 72 |
+
71,94054,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1275,0,"",shellscript,selection_command
|
| 73 |
+
72,94497,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1274,0,"",shellscript,selection_command
|
| 74 |
+
73,95462,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",1274,1,"5",shellscript,content
|
| 75 |
+
74,100499,"TERMINAL",0,0,"sync-runner",,terminal_command
|
| 76 |
+
75,100562,"TERMINAL",0,0,"]633;Csending incremental file list\r\n",,terminal_output
|
| 77 |
+
76,100949,"TERMINAL",0,0,"pyproject.toml\r\n",,terminal_output
|
| 78 |
+
77,101117,"TERMINAL",0,0,"r",,terminal_output
|
| 79 |
+
78,101190,"TERMINAL",0,0,"u",,terminal_output
|
| 80 |
+
79,101359,"TERMINAL",0,0,"n",,terminal_output
|
| 81 |
+
80,101549,"TERMINAL",0,0,"ne",,terminal_output
|
| 82 |
+
81,101602,"TERMINAL",0,0,"r",,terminal_output
|
| 83 |
+
82,101669,"TERMINAL",0,0,"\r\n",,terminal_output
|
| 84 |
+
83,102832,"TERMINAL",0,0,"jasmine/\r\njasmine/genie.py\r\njasmine/sample.py\r\njasmine/train_dynamics.py\r\njasmine/models/\r\njasmine/models/dynamics.py\r\njasmine/utils/\r\njasmine/utils/dataloader_torch.py\r\nslurm/jobs/mihir/horeka/breakout/noise_schedule_runs/full-prec/train_dyn_single_gpu.sh\r\n",,terminal_output
|
| 85 |
+
84,103054,"TERMINAL",0,0,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh\r\nslurm/jobs/mihir/horeka/preprocessing/\r\nslurm/jobs/mihir/horeka/preprocessing/doom_chunked.sh\r\n",,terminal_output
|
| 86 |
+
85,103131,"TERMINAL",0,0,"\r\nsent 115,079 bytes received 432 bytes 46,204.40 bytes/sec\r\ntotal size is 28,204,848 speedup is 244.17\r\n]0;tum_cte0515@hkn1993:~/Projects/jasmine",,terminal_output
|
| 87 |
+
86,103164,"TERMINAL",0,0,"runner",,terminal_command
|
| 88 |
+
87,106589,"TERMINAL",0,0,"git branch",,terminal_command
|
| 89 |
+
88,109444,"TERMINAL",0,0,"dev",,terminal_command
|
| 90 |
+
89,111011,"TERMINAL",0,0,"git branch",,terminal_command
|
| 91 |
+
90,111060,"TERMINAL",0,0,"]633;C[?1h=\r",,terminal_output
|
| 92 |
+
91,111557,"TERMINAL",0,0,"* [32mablation/use-pytorch-dataloader[m[m\r\n action-mapper[m[m\r\n add-noise-to-combat-exposure-bias[m[m\r\n add-wandb-name-and-tags[m[m\r\n before-nnx[m[m\r\n causal-mem-reduce[m[m\r\n causal-spatiotemporal-kv-cache[m[m\r\n causal-st-transformer[m[m\r\n causal-transformer-dynamics-model[m[m\r\n causal-transformer-nnx-no-kv-cache[m[m\r\n coinrun-gt-actions[m[m\r\n convert-to-jax-array-in-iter[m[m\r\n correct-batched-sampling[m[m\r\n dev[m[m\r\n dont-let-tf-see-gpu[m[m\r\n:[K",,terminal_output
|
| 93 |
+
92,113179,"TERMINAL",0,0,"\r[K\r[K:[K",,terminal_output
|
| 94 |
+
93,113356,"TERMINAL",0,0,"\r[K\r[K:[K",,terminal_output
|
| 95 |
+
94,113567,"TERMINAL",0,0,"\r[K\r[K:[K",,terminal_output
|
| 96 |
+
95,114843,"TERMINAL",0,0,"\r[K\r[K:[K",,terminal_output
|
| 97 |
+
96,115448,"TERMINAL",0,0,"\r[K[?1l>]0;tum_cte0515@hkn1993:~/Projects/jasmine",,terminal_output
|
| 98 |
+
97,118009,"TERMINAL",0,0,"git status",,terminal_command
|
| 99 |
+
98,118056,"TERMINAL",0,0,"]633;C",,terminal_output
|
| 100 |
+
99,118185,"TERMINAL",0,0,"On branch ablation/use-pytorch-dataloader\r\nLast commands done (2 commands done):\r\n pick ba37453 feat: generate coinrun dataset with val split\r\n pick faadd10 feat: implemented validation loss for all three models\r\nNext commands to do (26 remaining commands):\r\n pick 9a17dbb fix: pass val data path to dataloader\r\n pick 6e69cdb fix typo in image logging\r\n (use ""git rebase --edit-todo"" to view and edit)\r\nYou are currently editing a commit while rebasing branch 'gt-actions' on 'c7522f2'.\r\n (use ""git commit --amend"" to amend the current commit)\r\n (use ""git rebase --continue"" once you are satisfied with your changes)\r\n\r\nChanges not staged for commit:\r\n (use ""git add <file>..."" to update what will be committed)\r\n (use ""git restore <file>..."" to discard changes in working directory)\r\n\t[31mmodified: jasmine/train_dynamics.py[m\r\n\t[31mmodified: pyproject.toml[m\r\n\r\nUntracked files:\r\n (use ""git add <file>..."" to include in what will be committed)\r\n\t[31mdata/_vizdoom.ini[m\r\n\t[31mdata/data/[m\r\n\t[31mdata/jasmine_data/vizdoom/[m\r\n\t[31mdata/uv.lock[m\r\n\t[31mdiff.diff[m\r\n\t[31mdiff2.diff[m\r\n\t[31minput_pipeline/[m\r\n\t[31mjasmine/utils/dataloader_torch.py[m\r\n\t[31mkiller.sh[m\r\n\t[31mkiller_partition.sh[m\r\n\t[31mlog.log[m\r\n\t[31moverfit_dir.zip[m\r\n\t[31mrequirements-franz.txt[m\r\n\t[31msamples/[m\r\n\t[31mscripts_cremers/[m\r\n\t[31mslurm/[m\r\n\t[31mtest.py[m\r\n\t[31mutils/[m\r\n\t[31muv.lock[m\r\n\r\nno changes added to commit (use ""git add"" and/or ""git commit -a"")\r\n]0;tum_cte0515@hkn1993:~/Projects/jasmine",,terminal_output
|
| 101 |
+
100,127406,"TERMINAL",0,0,"git add jasmine/utils/dataloader_torch.py",,terminal_command
|
| 102 |
+
101,127433,"TERMINAL",0,0,"]633;C]0;tum_cte0515@hkn1993:~/Projects/jasmine",,terminal_output
|
| 103 |
+
102,133324,"TERMINAL",0,0,"git commit -am ""added torch dataloader""",,terminal_command
|
| 104 |
+
103,133374,"TERMINAL",0,0,"]633;C",,terminal_output
|
| 105 |
+
104,135068,"TERMINAL",0,0,"black....................................................................",,terminal_output
|
| 106 |
+
105,137270,"TERMINAL",0,0,"[41mFailed[m\r\n[2m- hook id: black[m\r\n[2m- files were modified by this hook[m\r\n\r\n[1mreformatted jasmine/utils/dataloader_torch.py[0m\r\n[1mreformatted jasmine/train_dynamics.py[0m\r\n\r\n[1mAll done! ✨ 🍰 ✨[0m\r\n[34m[1m2 files [0m[1mreformatted[0m.\r\n\r\n]0;tum_cte0515@hkn1993:~/Projects/jasmine",,terminal_output
|
| 107 |
+
106,139016,"TERMINAL",0,0,"git add jasmine/utils/dataloader_torch.py",,terminal_command
|
| 108 |
+
107,139065,"TERMINAL",0,0,"]633;C",,terminal_output
|
| 109 |
+
108,139119,"TERMINAL",0,0,"]0;tum_cte0515@hkn1993:~/Projects/jasmine",,terminal_output
|
| 110 |
+
109,140181,"TERMINAL",0,0,"git commit -am ""added torch dataloader""",,terminal_command
|
| 111 |
+
110,140240,"TERMINAL",0,0,"]633;C",,terminal_output
|
| 112 |
+
111,140758,"TERMINAL",0,0,"black....................................................................",,terminal_output
|
| 113 |
+
112,141060,"TERMINAL",0,0,"[42mPassed[m\r\n",,terminal_output
|
| 114 |
+
113,141172,"TERMINAL",0,0,"[ablation/use-pytorch-dataloader c486cd9] added torch dataloader\r\n 3 files changed, 43 insertions(+), 68 deletions(-)\r\n create mode 100644 jasmine/utils/dataloader_torch.py\r\n]0;tum_cte0515@hkn1993:~/Projects/jasmine",,terminal_output
|
| 115 |
+
114,145776,"TERMINAL",0,0,"git branch",,terminal_command
|
| 116 |
+
115,145880,"TERMINAL",0,0,"]633;C[?1h=\r* [32mablation/use-pytorch-dataloader[m[m\r\n action-mapper[m[m\r\n add-noise-to-combat-exposure-bias[m[m\r\n add-wandb-name-and-tags[m[m\r\n before-nnx[m[m\r\n causal-mem-reduce[m[m\r\n causal-spatiotemporal-kv-cache[m[m\r\n causal-st-transformer[m[m\r\n causal-transformer-dynamics-model[m[m\r\n causal-transformer-nnx-no-kv-cache[m[m\r\n coinrun-gt-actions[m[m\r\n convert-to-jax-array-in-iter[m[m\r\n correct-batched-sampling[m[m\r\n dev[m[m\r\n dont-let-tf-see-gpu[m[m\r\n:[K",,terminal_output
|
| 117 |
+
116,146366,"TERMINAL",0,0,"\r[K/",,terminal_output
|
| 118 |
+
117,149573,"TERMINAL",0,0,"[Kqq",,terminal_output
|
| 119 |
+
118,150440,"TERMINAL",0,0,"[H[2J[H[H[2J[H* [32mablation/use-pytorch-dataloader[m[m\r\n action-mapper[m[m\r\n add-noise-to-combat-exposure-bias[m[m\r\n add-wandb-name-and-tags[m[m\r\n before-nnx[m[m\r\n causal-mem-reduce[m[m\r\n causal-spatiotemporal-kv-cache[m[m\r\n causal-st-transformer[m[m\r\n causal-transformer-dynamics-model[m[m\r\n causal-transformer-nnx-no-kv-cache[m[m\r\n coinrun-gt-actions[m[m\r\n convert-to-jax-array-in-iter[m[m\r\n correct-batched-sampling[m[m\r\n dev[m[m\r\n dont-let-tf-see-gpu[m[m\r\n:[K",,terminal_output
|
| 120 |
+
119,151403,"TERMINAL",0,0,"\r[K[?1l>\r\n]0;tum_cte0515@hkn1993:~/Projects/jasmine",,terminal_output
|
| 121 |
+
120,153667,"TERMINAL",0,0,"git checkout add-noise-to-combat-exposure-bias",,terminal_command
|
| 122 |
+
121,153718,"TERMINAL",0,0,"]633;C",,terminal_output
|
| 123 |
+
122,153931,"TERMINAL",0,0,"Switched to branch 'add-noise-to-combat-exposure-bias'\r\nYour branch is up to date with 'origin/add-noise-to-combat-exposure-bias'.\r\n]0;tum_cte0515@hkn1993:~/Projects/jasmine",,terminal_output
|
| 124 |
+
123,155370,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",0,0,"Switched from branch 'ablation/use-pytorch-dataloader' to 'add-noise-to-combat-exposure-bias'",shellscript,git_branch_checkout
|
| 125 |
+
124,156237,"TERMINAL",0,0,"runner",,terminal_command
|
| 126 |
+
125,157938,"TERMINAL",0,0,"sync-runner",,terminal_command
|
| 127 |
+
126,158013,"TERMINAL",0,0,"]633;Csending incremental file list\r\n",,terminal_output
|
| 128 |
+
127,163149,"TERMINAL",0,0,"./\r\npyproject.toml\r\n",,terminal_output
|
| 129 |
+
128,164888,"TERMINAL",0,0,"jasmine/\r\njasmine/genie.py\r\njasmine/sample.py\r\njasmine/train_dynamics.py\r\njasmine/models/\r\njasmine/models/dynamics.py\r\njasmine/utils/\r\n\r\nsent 116,290 bytes received 350 bytes 15,552.00 bytes/sec\r\ntotal size is 28,210,925 speedup is 241.86\r\n]0;tum_cte0515@hkn1993:~/Projects/jasmine_jobs",,terminal_output
|
| 130 |
+
129,168168,"TERMINAL",0,0,"sbatch slurm/jobs/mihir/horeka/coinrun/default_runs/train_lam_default.sh",,terminal_command
|
| 131 |
+
130,168201,"TERMINAL",0,0,"]633;CSubmitted batch job 3529697\r\n]0;tum_cte0515@hkn1993:~/Projects/jasmine_jobs",,terminal_output
|
| 132 |
+
131,174845,"jasmine/utils/dataloader.py",0,0,"import jax\nimport numpy as np\nimport grain\nfrom typing import Any\nimport pickle\n\n\nclass EpisodeLengthFilter(grain.transforms.Filter):\n """"""\n A Grain Filter that keeps only episodes with sufficient length.\n """"""\n\n def __init__(self, seq_len: int, image_h: int, image_w: int, image_c: int):\n """"""Initializes the filter with sequence length requirements.""""""\n self.seq_len = seq_len\n self.image_h = image_h\n self.image_w = image_w\n self.image_c = image_c\n\n def filter(self, element: Any) -> bool:\n """"""\n Filters episodes based on length.\n\n Args:\n element: A dictionary representing one record from the DataSource.\n Expected to contain 'raw_video' (bytes) and 'sequence_length' (int)\n\n Returns:\n True if the episode has sufficient length, False otherwise.\n """"""\n assert isinstance(element, bytes)\n element = pickle.loads(element)\n\n current_episode_len = element[""sequence_length""]\n if current_episode_len < self.seq_len:\n print(\n f""Filtering out episode with length {current_episode_len}, which is ""\n f""shorter than the requested sequence length {self.seq_len}.""\n )\n return False\n\n return True\n\n\nclass ProcessEpisodeAndSlice(grain.transforms.RandomMap):\n """"""\n A Grain Transformation that combines parsing, slicing, and normalizing.\n """"""\n\n def __init__(self, seq_len: int, image_h: int, image_w: int, image_c: int):\n """"""Initializes the transformation with processing parameters.""""""\n self.seq_len = seq_len\n self.image_h = image_h\n self.image_w = image_w\n self.image_c = image_c\n\n def random_map(self, element: dict, rng: np.random.Generator) -> Any:\n """"""\n Processes a single raw episode from the data source.\n\n Args:\n element: A dictionary representing one record from the DataSource.\n Expected to contain 'raw_video' (bytes) and 'sequence_length' (int)\n rng: A per-record random number generator provided by the Grain sampler.\n\n Returns:\n A processed video sequence as a NumPy array with shape\n (seq_len, height, width, channels) and dtype float32.\n """"""\n assert isinstance(element, bytes)\n element = pickle.loads(element)\n\n video_shape = (\n element[""sequence_length""],\n self.image_h,\n self.image_w,\n self.image_c,\n )\n episode_tensor = np.frombuffer(element[""raw_video""], dtype=np.uint8)\n episode_tensor = episode_tensor.reshape(video_shape)\n\n current_episode_len = episode_tensor.shape[0]\n if current_episode_len < self.seq_len:\n raise ValueError(\n f""Episode length {current_episode_len} is shorter than ""\n f""requested sequence length {self.seq_len}. This should ""\n f""have been filtered out.""\n )\n\n max_start_idx = current_episode_len - self.seq_len\n\n start_idx = rng.integers(0, max_start_idx + 1)\n\n seq = episode_tensor[start_idx : start_idx + self.seq_len]\n\n data_dict = {""videos"": seq}\n if ""actions"" in element.keys():\n actions_tensor = np.array(element[""actions""])\n actions = actions_tensor[start_idx : start_idx + self.seq_len]\n data_dict[""actions""] = actions\n\n return data_dict\n\n\ndef get_dataloader(\n array_record_paths: list[str],\n seq_len: int,\n global_batch_size: int,\n image_h: int,\n image_w: int,\n image_c: int,\n num_workers: int = 1,\n prefetch_buffer_size: int = 1,\n seed: int = 42,\n):\n """"""\n Creates a data loading pipeline using Grain.\n """"""\n if not array_record_paths:\n raise ValueError(""array_record_paths list cannot be empty."")\n\n num_processes = jax.process_count()\n\n if global_batch_size % num_processes != 0:\n raise ValueError(\n f""Global batch size {global_batch_size} must be divisible by ""\n f""the number of JAX processes {num_processes} for proper sharding.""\n )\n per_process_batch_size = global_batch_size // num_processes\n\n source = grain.sources.ArrayRecordDataSource(array_record_paths)\n\n sampler = grain.samplers.IndexSampler(\n num_records=len(source),\n shard_options=grain.sharding.ShardByJaxProcess(drop_remainder=True),\n shuffle=True,\n num_epochs=None,\n seed=seed,\n )\n\n operations = [\n EpisodeLengthFilter(\n seq_len=seq_len, image_h=image_h, image_w=image_w, image_c=image_c\n ),\n ProcessEpisodeAndSlice(\n seq_len=seq_len, image_h=image_h, image_w=image_w, image_c=image_c\n ),\n grain.transforms.Batch(batch_size=per_process_batch_size, drop_remainder=True),\n ]\n\n read_options = grain.ReadOptions(\n prefetch_buffer_size=prefetch_buffer_size,\n num_threads=1,\n )\n dataloader = grain.DataLoader(\n data_source=source,\n sampler=sampler,\n operations=operations,\n worker_count=num_workers,\n worker_buffer_size=1,\n read_options=read_options,\n )\n\n return dataloader\n",python,tab
|
| 133 |
+
132,196824,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_tokenizer_default.sh",0,0,"#!/usr/bin/env bash\n\n#SBATCH --nodes=1\n#SBATCH --ntasks-per-node=1\n#SBATCH --time=48:00:00\n#SBATCH --partition=accelerated\n#SBATCH --cpus-per-task=5\n#SBATCH --gres=gpu:1\n#SBATCH --output=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/coinrun/tokenizer/%x_%j.log\n#SBATCH --error=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/coinrun/tokenizer/%x_%j.log\n#SBATCH --job-name=train_tokenizer_default\n#SBATCH --requeue\n#SBATCH --signal=b:usr1@300 # 5 min before timeout\n\n# Log the sbatch script\ncat $0\n\nmodule unload mpi/openmpi/5.0\nmodule unload devel/cuda/12.4\nsource .venv/bin/activate\n\narray_records_dir_train=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_coinrun/coinrun_episodes_10m_gt_actions_split/train\narray_records_dir_val=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_coinrun/coinrun_episodes_10m_gt_actions_split/val\n\n\njob_name=$SLURM_JOB_NAME\nslurm_job_id=$SLURM_JOB_ID\n\nCHECKPOINT_DIR=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/big-runs/tokenizer/$job_name/$slurm_job_id\nmkdir -p $CHECKPOINT_DIR\n\nenv | grep SLURM\n\nsrun python jasmine/train_tokenizer.py \\n --save_ckpt \\n --image_height=64 \\n --image_width=64 \\n --ckpt_dir $CHECKPOINT_DIR \\n --batch_size=120 \\n --init_lr=0 \\n --patch_size=16 \\n --log \\n --name=coinrun-tokenizer-default-$slurm_job_id \\n --tags tokenizer coinrun default \\n --entity instant-uv \\n --project jafar \\n --data_dir $array_records_dir_train \\n --val_data_dir $array_records_dir_val \\n",shellscript,tab
|
| 134 |
+
133,198803,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_tokenizer_default.sh",1326,0,"",shellscript,selection_mouse
|
| 135 |
+
134,201451,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_tokenizer_default.sh",1310,22,"",shellscript,content
|
| 136 |
+
135,201493,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_tokenizer_default.sh",1314,0,"",shellscript,selection_command
|
| 137 |
+
136,205494,"TERMINAL",0,0,"sync-runner",,terminal_command
|
| 138 |
+
137,205568,"TERMINAL",0,0,"]633;Csending incremental file list\r\n",,terminal_output
|
| 139 |
+
138,207803,"TERMINAL",0,0,"slurm/jobs/mihir/horeka/coinrun/default_runs/train_tokenizer_default.sh\r\n",,terminal_output
|
| 140 |
+
139,207875,"TERMINAL",0,0,"\r\nsent 38,779 bytes received 260 bytes 15,615.60 bytes/sec\r\ntotal size is 28,210,903 speedup is 722.63\r\n]0;tum_cte0515@hkn1993:~/Projects/jasmine_jobs",,terminal_output
|
| 141 |
+
140,209763,"TERMINAL",0,0,"runner",,terminal_command
|
| 142 |
+
141,213567,"TERMINAL",0,0,"sbatch slurm/jobs/mihir/horeka/coinrun/default_runs/train_tokenizer_default.sh",,terminal_command
|
| 143 |
+
142,213576,"TERMINAL",0,0,"]633;CSubmitted batch job 3529698\r\n]0;tum_cte0515@hkn1993:~/Projects/jasmine_jobs",,terminal_output
|
| 144 |
+
143,224381,"TERMINAL",0,0,"queue",,terminal_command
|
| 145 |
+
144,224458,"TERMINAL",0,0,"]633;C[?1049h[22;0;0t[1;16r(B[m[4l[?7h[H[2JEvery 1.0s: squeue --me[1;106Hhkn1993.localdomain: Mon Sep 29 20:34:28 2025[3;14HJOBID PARTITION NAME USER ST\tTIME NODES NODELIST(REASON)[4;12H3528968 accelerat train_la tum_cte0 PD\t0:00\t 8 (Priority)[5;12H3528969 accelerat train_to tum_cte0 PD\t0:00\t 8 (Priority)[6;12H3529698 accelerat train_to tum_cte0 PD\t0:00\t 1 (Priority)[7;12H3529697 accelerat train_la tum_cte0 R\t0:36\t 1 hkn0429[8;12H3528955 accelerat train_to tum_cte0 R 7:29:49\t 1 hkn0709[16;150H",,terminal_output
|
| 146 |
+
145,225587,"TERMINAL",0,0,"[1;145H9[7;60H7[8d50[16;150H",,terminal_output
|
| 147 |
+
146,226585,"TERMINAL",0,0,"[1;144H30[7;60H8[8d1[16;150H",,terminal_output
|
| 148 |
+
147,227582,"TERMINAL",0,0,"[1;145H1[7;60H9[8d2[16;150H",,terminal_output
|
| 149 |
+
148,228632,"TERMINAL",0,0,"[1;145H2[7;59H40[8d3[16;150H",,terminal_output
|
| 150 |
+
149,229760,"TERMINAL",0,0,"[1;145H3[7;60H1[8d4[16;150H",,terminal_output
|
| 151 |
+
150,230887,"TERMINAL",0,0,"[1;145H4[7;60H2[8d5[16;150H",,terminal_output
|
| 152 |
+
151,231807,"TERMINAL",0,0,"[1;145H5[7;60H3[8d6[16;150H",,terminal_output
|
| 153 |
+
152,232814,"TERMINAL",0,0,"[1;145H6[7;60H4[8d7[16;150H",,terminal_output
|
| 154 |
+
153,233981,"TERMINAL",0,0,"[1;145H7[7;60H5[8d8[16;150H",,terminal_output
|
| 155 |
+
154,234830,"TERMINAL",0,0,"[16;1H[?1049l[23;0;0t\r[?1l>]0;tum_cte0515@hkn1993:~/Projects/jasmine_jobs",,terminal_output
|