Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .superpowers/sdd/task-1-fix-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Task 1 review-fix report

Status: DONE

Review finding addressed:

- Restored `sync_cube()` immediately after the final global-write loops in the
small/shared CFFT, RFFT, and IRFFT interleaved kernels.
- The three insertion points match upstream commit
`e66fe2e60f9dfb4c77be5c68cc9979bbdbabc354` (CubeK PR #8); no algorithm,
threshold, layout, or launch-interface changes were made.

Verification:

- Targeted small CFFT round-trip test: passed.
- Targeted RFFT reference test: passed.
- Targeted IRFFT reference test: passed.
- `cargo test -p cubek-fft --all-features`: passed (2 unit + 77 integration + doctests).
- `cargo clippy -p cubek-fft --all-targets --all-features -- -D warnings`: passed.
- `cargo fmt --all -- --check`: passed.
- `git diff --check`: passed.

Concerns: none.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
resolver = "2"

members = [
"crates/cubek-fft",
"crates/cubek-matmul",
"crates/cubek-quant",
"crates/cubek-random",
Expand All @@ -18,7 +19,6 @@ exclude = [
"crates/cubek",
"crates/cubek-attention",
"crates/cubek-convolution",
"crates/cubek-fft",
"crates/cubek-interpolate",
"crates/cubek-reduce",
]
Expand All @@ -35,8 +35,8 @@ version = "0.2.0"
# PR/CI builds use the tensor4all CubeCL commit that adds the `t4a-cubecl*`
# package manifests. Published packages use the registry packages at the same
# exact versions.
cubecl = { package = "t4a-cubecl", git = "https://github.com/tensor4all/cubecl.git", rev = "6424d9da407d4bc10034aee3bae52705eb5d2da0", version = "=0.10.0", default-features = false }
cubecl-common = { package = "t4a-cubecl-common", git = "https://github.com/tensor4all/cubecl.git", rev = "6424d9da407d4bc10034aee3bae52705eb5d2da0", version = "=0.10.0", default-features = false }
cubecl = { package = "t4a-cubecl", git = "https://github.com/tensor4all/cubecl.git", rev = "11b52669f13e27bbe188f988fd696df6d989a562", version = "=0.10.0", default-features = false }
cubecl-common = { package = "t4a-cubecl-common", git = "https://github.com/tensor4all/cubecl.git", rev = "11b52669f13e27bbe188f988fd696df6d989a562", version = "=0.10.0", default-features = false }

derive-new = { version = "0.7.0", default-features = false }
log = { default-features = false, version = "0.4.22" }
Expand Down
2 changes: 1 addition & 1 deletion crates/cubek-attention/src/components/stage/unit/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<SK: StageFamily, SV: StageFamily, SO: StageFamily<ReadWrite>> StageAttentio
CubeDimResource::Units(units * blueprint.tiling_scheme.stage_size.seq_q)
}
_ => {
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"Error: Expected unit tile attention, got a plane tile attention".to_string(),
)));
}
Expand Down
14 changes: 7 additions & 7 deletions crates/cubek-attention/src/components/tile/attention.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ fn validate_unit(
let check_divisible =
|dim: u32, vec_size: u32, name: &str, vec_name: &str| -> Result<(), AttentionSetupError> {
if !dim.is_multiple_of(vec_size) {
return Err(AttentionSetupError::InvalidConfig(Box::new(format!(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(format!(
"Tile's {} ({:?}) must be divisible by {} vector size ({:?})",
name, dim, vec_name, vec_size
))));
Expand Down Expand Up @@ -223,7 +223,7 @@ fn validate_blackbox(
dtypes: &AttentionElems,
) -> Result<(), AttentionSetupError> {
if dtypes.query_global != dtypes.query_tile {
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"Query global and tile types must be the same because no stage to cast in between",
)));
}
Expand Down Expand Up @@ -268,7 +268,7 @@ fn validate_blackbox(
}

if line_sizes_mask > 1 {
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"Line size mask > 1 not supported yet on accelerated tile attention",
)));
}
Expand All @@ -278,27 +278,27 @@ fn validate_blackbox(
let softmax_total = softmax_num_rows * softmax_num_cols;

if !softmax_total.is_multiple_of(cfg.plane_dim) {
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"Softmax size should be divisible by plane dim",
)));
}

if cfg.inner_layout == InnerLayout::Contiguous && softmax_num_rows > cfg.plane_dim {
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"More than one row per unit not supported with this inner layout",
)));
}

if cfg.inner_layout == InnerLayout::SplitRows
&& !softmax_total.is_multiple_of(2 * cfg.plane_dim)
{
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"With split rows, units must have two elements each",
)));
}

if cfg.tile_size.head_dim < cfg.tile_size.val_dim {
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"Can't have tile head_dim < tile val dim (not sure why)",
)));
}
Expand Down
10 changes: 5 additions & 5 deletions crates/cubek-attention/src/routines/blackbox_accelerated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ fn blueprint<R: Runtime>(
.map_err(map_err)?;

if tile_size_score_matmul.m != values_matmul.m {
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"Seq_q mismatch: `m` of score_matmul does not match `m` of values_matmul. ",
)));
}

if tile_size_score_matmul.n != values_matmul.k {
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"Seq_kv mismatch: `n` of score_matmul does not match `k` of values_matmul. ",
)));
}
Expand Down Expand Up @@ -208,21 +208,21 @@ fn validate(
if !(problem.dims.seq_q as u32)
.is_multiple_of(blueprint.tiling_scheme.elements_in_stage_seq_q())
{
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"Stage seq_q must divide problem seq_q".to_string(),
)));
}

if !(problem.dims.head_dim as u32).is_multiple_of(blueprint.tiling_scheme.tile_size.head_dim) {
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"Tile size head dim must divide problem head dim".to_string(),
)));
}

if blueprint.tiling_scheme.partition_size.head_dim * blueprint.tiling_scheme.tile_size.head_dim
!= problem.dims.head_dim as u32
{
return Err(AttentionSetupError::InvalidConfig(Box::new(format!(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(format!(
"Tiling scheme's total head dim ({}) does not match problem's head dim ({})",
blueprint.tiling_scheme.partition_size.head_dim
* blueprint.tiling_scheme.tile_size.head_dim,
Expand Down
6 changes: 3 additions & 3 deletions crates/cubek-attention/src/routines/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl Routine for UnitRoutine {
CubeDimResource::Units(units * blueprint.tiling_scheme.stage_size.seq_q)
}
_ => {
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"Error: Expected unit tile attention, got a plane tile attention".to_string(),
)));
}
Expand Down Expand Up @@ -136,15 +136,15 @@ fn validate(
blueprint: AttentionBlueprint,
) -> Result<AttentionBlueprint, AttentionSetupError> {
if !(problem.dims.head_dim as u32).is_multiple_of(blueprint.tiling_scheme.tile_size.head_dim) {
return Err(AttentionSetupError::InvalidConfig(Box::new(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"Tile size head dim must divide problem head dim".to_string(),
)));
}

if blueprint.tiling_scheme.partition_size.head_dim * blueprint.tiling_scheme.tile_size.head_dim
!= problem.dims.head_dim as u32
{
return Err(AttentionSetupError::InvalidConfig(Box::new(format!(
return Err(AttentionSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(format!(
"Tiling scheme's total head dim ({}) does not match problem's head dim ({})",
blueprint.tiling_scheme.partition_size.head_dim
* blueprint.tiling_scheme.tile_size.head_dim,
Expand Down
2 changes: 1 addition & 1 deletion crates/cubek-convolution/src/components/stage/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl TilingValidation for BiasTilingLayout {
fn check(config: StageMemoryConfig) -> Result<(), InvalidConfigError> {
let stage_width = config.elements_per_stage_along_col();
if config.vector_size > stage_width {
return Err(Box::new(format!(
return Err(cubek_std::InvalidConfigError::new(format!(
"Invalid vector size. Got {:?} which should not be >{:?}",
config.vector_size, stage_width,
)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ where
/// rejected.
#[allow(dead_code)]
pub(crate) fn unsupported_tma_error() -> ConvSetupError {
ConvSetupError::Matmul(MatmulSetupError::InvalidConfig(Box::new(
ConvSetupError::Matmul(MatmulSetupError::InvalidConfig(cubek_std::InvalidConfigError::new(
"Data backprop doesn't yet work with current TMA tiling strategy",
)))
}
9 changes: 5 additions & 4 deletions crates/cubek-fft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ cpu-reference = ["dep:num-complex", "dep:cubek-test-utils"]

[dependencies]
cubecl = { workspace = true }
cubek-test-utils = { package = "t4a-cubek-test-utils", path = "./../cubek-test-utils/", version = "0.2.0", default-features = false, optional = true }
num-complex = { workspace = true, optional = true }
thiserror = { workspace = true }
cubek-test-utils = { package = "t4a-cubek-test-utils", path = "./../cubek-test-utils/", version = "=0.2.0", default-features = false, optional = true }
num-complex = { version = "0.4.6", optional = true }

[dev-dependencies]
num-complex = { workspace = true }
num-complex = "0.4.6"
cubecl = { workspace = true, features = ["test-runtime"] }
cubecl-common = { workspace = true }
cubek-fft = { path = ".", features = ["cpu-reference"] }
cubek-test-utils = { package = "t4a-cubek-test-utils", path = "./../cubek-test-utils/", version = "0.2.0", default-features = false }
cubek-test-utils = { package = "t4a-cubek-test-utils", path = "./../cubek-test-utils/", version = "=0.2.0", default-features = false }
Loading
Loading