fp8 math/packed store#917
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for packed float8x2 types in the PTO compiler and PTODSL, renames pto.vec to pto.Vec (using size instead of lanes), introduces SIMT scalar math aliases, and extends pto.simt_allreduce to support 32-bit integers. It also enforces that alloc_buffer is used only within SIMT subkernels and updates stg to support exact vector payloads. The review feedback highlights two critical safety issues: potential AttributeError crashes when handling raw Python scalars in stg within ptodsl/_ops.py, and a double-fault risk in _validate_scratch_buffer within ptodsl/_allreduce.py if the scratch object lacks a type attribute.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| raw_value = unwrap_surface_value(value) | ||
| if raw_value.type == elem_type: | ||
| stored_value = raw_value | ||
| elif VectorType.isinstance(elem_type): | ||
| raise TypeError( | ||
| f"stg(value, ...) vector value type must match destination element type: " | ||
| f"got {raw_value.type}, expected {elem_type}" | ||
| ) | ||
| else: | ||
| stored_value = coerce_scalar_to_type(value, elem_type, context="stg(value, ...)") |
There was a problem hiding this comment.
If value is a raw Python scalar (such as a float or int), unwrap_surface_value(value) returns the raw scalar itself, which does not have a type attribute. Accessing raw_value.type directly on line 5197 will raise an AttributeError. We should check hasattr(raw_value, "type") before accessing raw_value.type to avoid crashing on raw Python scalars.
raw_value = unwrap_surface_value(value)
if hasattr(raw_value, "type") and raw_value.type == elem_type:
stored_value = raw_value
elif VectorType.isinstance(elem_type):
got_type = getattr(raw_value, "type", type(raw_value))
raise TypeError(
f"stg(value, ...) vector value type must match destination element type: "
f"got {got_type}, expected {elem_type}"
)
else:
stored_value = coerce_scalar_to_type(value, elem_type, context="stg(value, ...)")| raw_scratch = unwrap_surface_value(scratch) | ||
| try: | ||
| scratch_type = _pto.PtrType(raw_scratch.type) | ||
| except Exception as exc: | ||
| raise TypeError(f"{context} requires a UB scratch buffer pointer, got {raw_scratch.type}") from exc |
There was a problem hiding this comment.
If raw_scratch does not have a type attribute (e.g., if it is a raw Python object or not a wrapped MLIR Value), accessing raw_scratch.type in the except block will raise an AttributeError. This causes a double-fault and masks the original exception. We should check hasattr(raw_scratch, "type") first to safely handle this case.
raw_scratch = unwrap_surface_value(scratch)
if not hasattr(raw_scratch, "type"):
raise TypeError(f"{context} requires a UB scratch buffer pointer, got {raw_scratch}")
try:
scratch_type = _pto.PtrType(raw_scratch.type)
except Exception as exc:
raise TypeError(f"{context} requires a UB scratch buffer pointer, got {raw_scratch.type}") from exc
Codex Review该评论由 review 机器人自动更新。
SummaryReview failed at stage Findings未生成结构化 findings,因为 review 过程提前失败。 Log Tail |
0bcbaee to
8d1629a
Compare
9a99940 to
f3bd1cb
Compare
4ce12ed to
292260f
Compare
TODO:
新增实现
与需求相关 - 确认的项目:
其他: