Skip to content

fix: handle unsupported architectures gracefully in setup_env.py#478

Open
aayushbaluni wants to merge 1 commit intomicrosoft:mainfrom
aayushbaluni:fix/setup-env-error-handling
Open

fix: handle unsupported architectures gracefully in setup_env.py#478
aayushbaluni wants to merge 1 commit intomicrosoft:mainfrom
aayushbaluni:fix/setup-env-error-handling

Conversation

@aayushbaluni
Copy link

Summary

Fixes three error-handling bugs in setup_env.py that cause crashes or misleading exit codes on unsupported platforms.

Bug 1 — exit(0) on error condition (line 212):
compile() calls exit(0) when the architecture is unsupported, reporting success instead of failure.

Bug 2 — ARCH_ALIAS KeyError on unrecognized platforms (line 85):
system_info() uses a dict lookup ARCH_ALIAS[platform.machine()] which raises KeyError for architectures not in the alias table (e.g. i686, riscv64, ppc64le). This crashes before the architecture check in compile() can provide a proper error message.

Bug 3 — parse_args() KeyError on unsupported arch (line 225):
parse_args() uses SUPPORTED_QUANT_TYPES[arch] for argparse choices, which also raises KeyError for unknown architectures.

Changes

  • setup_env.py:85: Changed ARCH_ALIAS[platform.machine()] to ARCH_ALIAS.get(platform.machine(), platform.machine()) — unknown architectures now pass through instead of crashing.
  • setup_env.py:212: Changed exit(0) to sys.exit(1) — error condition now reports failure correctly.
  • setup_env.py:225-228: Added early arch check in parse_args() with a clear error message before argparse tries to use the unsupported arch.

Testing

  • Known architectures (AMD64, x86_64, aarch64, arm64, ARM64) behave identically to before
  • Unknown architectures now get a clear error message instead of an unhandled KeyError traceback
  • All changes are backward-compatible with existing supported platforms
  • No unrelated changes included

Made with Cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant