Skip to content

Support DeepSWE on MaxText models in Tunix - #2051

Closed
niting wants to merge 1 commit into
google:mainfrom
niting:deepswe
Closed

Support DeepSWE on MaxText models in Tunix#2051
niting wants to merge 1 commit into
google:mainfrom
niting:deepswe

Conversation

@niting

@niting niting commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Primarily adds a script train_maxtext_nb.py that uses MaxText models on a DeepSWE setup. The DeepSWE setup uses agentic sandboxes which maintains warmpools for faster training execution. Modifies Dockerfile accordingly to install necessary dependencies, adds a flag to swe_env.py to allow limiting warmpool replicas. Makes various robustness fixes for error logging etc.

  • I have added all the necessary unit tests for my change.
  • I have verified that my change does not break existing code and all unit tests pass.
  • I have added all appropriate doc-strings/documentation.
  • My PR is based on the latest changes of the main branch (if unsure, rebase the code).
  • I have signed the Contributor License Agreement.
  • I have followed Contribution Guidelines.

Comment thread examples/deepswe/swe_env.py Outdated
images = self._extract_images(batch)
if images and self.fleet:
target_replicas = (
self.max_warmpool_size

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this can be self.max_warmpool_size or self.num_generations

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread examples/deepswe/train_maxtext_nb.py Outdated
NODE_SELECTOR_VAL = args.node_selector_val


# Monkeypatch r2egym DockerRuntime to dynamically configure Kubernetes nodeSelector.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this this in a standalone r2e_gym_helper.py file? so we can reuse it later

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also realized I didn't need the agentic sandbox patch. Only the patch for overriding the node selector in r2egym.

"Fatal error in runner for pair %d: %s",
env.extra_kwargs["pair_index"],
"Fatal error in runner for pair %s: %s",
env.extra_kwargs.get("pair_index", "unknown"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when will pair_index be None?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this entirely. It's possible this was happening in certain conditoins that are not common.

Comment thread Dockerfile Outdated

RUN bash /app/scripts/install_tunix_vllm_requirement.sh
# Install SFT/MaxText dependencies (unconditional)
RUN pip install --upgrade flax && \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv pip install upgrade?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread examples/deepswe/swe_env.py Outdated
max_concurrent=effective_max_concurrent,
window_size=batch_size,
max_warmpool_size=num_generations,
max_warmpool_size=max_warmpool_size if max_warmpool_size is not None else num_generations,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to use max_concurrency here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will likely not be right? max_concurrency for my script is 256, but I want two replicas per stream so I set max_warmpool_size to 2 so that I have 512 sandboxes with 256 on standby at a time.

@wang2yn84 wang2yn84 Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, so the max_warmpool_size is per image. The naming is a bit misleading. nit, maybe max_warmpool_per_stream or per_image?

Comment thread examples/deepswe/train_maxtext_nb.py
Comment thread examples/deepswe/train_maxtext_nb.py
Comment thread Dockerfile
@wang2yn84

Copy link
Copy Markdown
Collaborator

Hi Nitin, please squash the commits into one before submission.

- Add train_maxtext_nb for agentic GRPO training with MaxText and vLLM.
- Add r2e_gym_helper with nodeSelector patching for Kubernetes execution on GKE.
- Add max_warmpool_size to swe_env to allow limiting warm pool replicas.
- Pass tokenizer_pad_id in AutoModel for MaxText causal LM loading.
- Update Dockerfile to optimize layer caching and configure DeepSWE MaxText dependencies.
copybara-service Bot pushed a commit that referenced this pull request Sep 2, 2026
--
f98e5632d4fc224a1b0213709b867cceee35e165 by Nitin Gangahar <niting@google.com>:

Support DeepSWE on MaxText models in Tunix

- Add train_maxtext_nb for agentic GRPO training with MaxText and vLLM.
- Add r2e_gym_helper with nodeSelector patching for Kubernetes execution on GKE.
- Add max_warmpool_replicas to swe_env to allow limiting warm pool replicas.
- Pass tokenizer_pad_id in AutoModel for MaxText causal LM loading.
- Update Dockerfile to optimize layer caching and configure DeepSWE MaxText dependencies.

COPYBARA_INTEGRATE_REVIEW=#2051 from niting:deepswe f98e5632d4fc224a1b0213709b867cceee35e165
PiperOrigin-RevId: 974800060
@niting

niting commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

This was merged separately: https://github.com/google/tunix/blob/main/examples/deepswe/train_maxtext_nb.py, due to some shenanigans with our internal (Google) importer. Closing this PR out.

@niting niting closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants