Skip to content
This repository was archived by the owner on Sep 30, 2026. It is now read-only.

Expose occupany limiting factors (#1330) - #1330

Closed
divyanshk wants to merge 1 commit into
mainfrom
export-D98209055
Closed

divyanshk wants to merge 1 commit into
mainfrom
export-D98209055

Conversation

@divyanshk

@divyanshk divyanshk commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

What's different in this diff? Nothing. It is on top of MTIA's changes to include the right symbols
in their cuda_occupancy.h shim: D97952003, D98009788.
The failure in MTIA tests were because these symbols didn't exist earlier.

cudaOccResult from cuda_occupancy.h has information which should help better interpret Kineto's occupany estimates.

struct cudaOccResult {
    int activeBlocksPerMultiprocessor; // Occupancy
    unsigned int limitingFactors;      // Factors that limited occupancy. A bit
                                       // field that counts the limiting
                                       // factors, see cudaOccLimitingFactor
    int blockLimitRegs;                // Occupancy due to register
                                       // usage, INT_MAX if the kernel does not
                                       // use any register.
    int blockLimitSharedMem;           // Occupancy due to shared memory
                                       // usage, INT_MAX if the kernel does not
                                       // use shared memory.
    int blockLimitWarps;               // Occupancy due to block size limit
    int blockLimitBlocks;              // Occupancy due to maximum number of blocks
                                       // managable per SM
    int blockLimitBarriers;            // Occupancy due to block barrier usage
    int allocatedRegistersPerBlock;    // Actual number of registers allocated per
                                       // block
    size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
                                       // per block
    cudaOccPartitionedGCConfig partitionedGCConfig;
                                       // Report if partitioned global caching
                                       // is actually enabled.
};

The limitingFactors field is a bitmask indicating which resource(s) constrained occupancy:

enum cudaOccLimitingFactor {
  OCC_LIMIT_WARPS    = 0x01,  // Block size (threads)
  OCC_LIMIT_REGS     = 0x02,  // Register usage
  OCC_LIMIT_SMEM     = 0x04,  // Shared memory
  OCC_LIMIT_BLOCKS   = 0x08,  // Max blocks per SM
  OCC_LIMIT_BARRIERS = 0x10   // Barrier usage
};

Fields like blockLimitXXX show the headroom in maximum number of blocks per SM if only XXX was the constraint.

activeBlocksPerMultiprocessor is the minimum value of the all blockLimitXXX values. For eg, a kernel with:

limitingFactors: 3 (binary 0011 = warps + registers)
blockLimitWarps: 4
blockLimitRegs: 2
activeBlocksPerMultiprocessor: 2

This means occupancy is register-limited (2 blocks instead of potential 4).

Note: this is not on the hot-path of profiling, but on the post-processing side. So there should be no overhead. Plus we do populate occ_result already, just weren't using other attributes.

Reviewed By: fenypatel99, scotts

Differential Revision: D98209055

@meta-cla meta-cla Bot added the cla signed label Mar 25, 2026
@meta-codesync

meta-codesync Bot commented Mar 25, 2026

Copy link
Copy Markdown

@divyanshk has exported this pull request. If you are a Meta employee, you can view the originating Diff in D98209055.

@meta-codesync meta-codesync Bot changed the title Expose occupany limiting factors Expose occupany limiting factors (#1330) Mar 26, 2026
meta-codesync Bot pushed a commit that referenced this pull request Mar 26, 2026
Summary:

What's different in this diff? Nothing. It is on top of MTIA's changes to include the right symbols
in their `cuda_occupancy.h` shim: D97952003, D98009788.
The failure in MTIA tests were because these symbols didn't exist earlier.
-----------------------------------------------------------------------------------------------------

`cudaOccResult` from `cuda_occupancy.h` has information which should help better interpret Kineto's occupany estimates.

```
struct cudaOccResult {
    int activeBlocksPerMultiprocessor; // Occupancy
    unsigned int limitingFactors;      // Factors that limited occupancy. A bit
                                       // field that counts the limiting
                                       // factors, see cudaOccLimitingFactor
    int blockLimitRegs;                // Occupancy due to register
                                       // usage, INT_MAX if the kernel does not
                                       // use any register.
    int blockLimitSharedMem;           // Occupancy due to shared memory
                                       // usage, INT_MAX if the kernel does not
                                       // use shared memory.
    int blockLimitWarps;               // Occupancy due to block size limit
    int blockLimitBlocks;              // Occupancy due to maximum number of blocks
                                       // managable per SM
    int blockLimitBarriers;            // Occupancy due to block barrier usage
    int allocatedRegistersPerBlock;    // Actual number of registers allocated per
                                       // block
    size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
                                       // per block
    cudaOccPartitionedGCConfig partitionedGCConfig;
                                       // Report if partitioned global caching
                                       // is actually enabled.
};
```

The `limitingFactors` field is a bitmask indicating which resource(s) constrained occupancy:

```
enum cudaOccLimitingFactor {
  OCC_LIMIT_WARPS    = 0x01,  // Block size (threads)
  OCC_LIMIT_REGS     = 0x02,  // Register usage
  OCC_LIMIT_SMEM     = 0x04,  // Shared memory
  OCC_LIMIT_BLOCKS   = 0x08,  // Max blocks per SM
  OCC_LIMIT_BARRIERS = 0x10   // Barrier usage
};
```


Fields like `blockLimitXXX` show the headroom in maximum number of blocks per SM if only XXX was the constraint.

`activeBlocksPerMultiprocessor` is the minimum value of the all `blockLimitXXX` values. For eg, a kernel with:
```
limitingFactors: 3 (binary 0011 = warps + registers)
blockLimitWarps: 4
blockLimitRegs: 2
activeBlocksPerMultiprocessor: 2
```
This means occupancy is register-limited (2 blocks instead of potential 4).

Note: this is not on the hot-path of profiling, but on the post-processing side. So there should be no overhead. Plus we do populate `occ_result` already, just weren't using other attributes.

Reviewed By: scotts

Differential Revision: D98209055
meta-codesync Bot pushed a commit that referenced this pull request Mar 26, 2026
Summary:

What's different in this diff? Nothing. It is on top of MTIA's changes to include the right symbols
in their `cuda_occupancy.h` shim: D97952003, D98009788.
The failure in MTIA tests were because these symbols didn't exist earlier.
-----------------------------------------------------------------------------------------------------

`cudaOccResult` from `cuda_occupancy.h` has information which should help better interpret Kineto's occupany estimates.

```
struct cudaOccResult {
    int activeBlocksPerMultiprocessor; // Occupancy
    unsigned int limitingFactors;      // Factors that limited occupancy. A bit
                                       // field that counts the limiting
                                       // factors, see cudaOccLimitingFactor
    int blockLimitRegs;                // Occupancy due to register
                                       // usage, INT_MAX if the kernel does not
                                       // use any register.
    int blockLimitSharedMem;           // Occupancy due to shared memory
                                       // usage, INT_MAX if the kernel does not
                                       // use shared memory.
    int blockLimitWarps;               // Occupancy due to block size limit
    int blockLimitBlocks;              // Occupancy due to maximum number of blocks
                                       // managable per SM
    int blockLimitBarriers;            // Occupancy due to block barrier usage
    int allocatedRegistersPerBlock;    // Actual number of registers allocated per
                                       // block
    size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
                                       // per block
    cudaOccPartitionedGCConfig partitionedGCConfig;
                                       // Report if partitioned global caching
                                       // is actually enabled.
};
```

The `limitingFactors` field is a bitmask indicating which resource(s) constrained occupancy:

```
enum cudaOccLimitingFactor {
  OCC_LIMIT_WARPS    = 0x01,  // Block size (threads)
  OCC_LIMIT_REGS     = 0x02,  // Register usage
  OCC_LIMIT_SMEM     = 0x04,  // Shared memory
  OCC_LIMIT_BLOCKS   = 0x08,  // Max blocks per SM
  OCC_LIMIT_BARRIERS = 0x10   // Barrier usage
};
```


Fields like `blockLimitXXX` show the headroom in maximum number of blocks per SM if only XXX was the constraint.

`activeBlocksPerMultiprocessor` is the minimum value of the all `blockLimitXXX` values. For eg, a kernel with:
```
limitingFactors: 3 (binary 0011 = warps + registers)
blockLimitWarps: 4
blockLimitRegs: 2
activeBlocksPerMultiprocessor: 2
```
This means occupancy is register-limited (2 blocks instead of potential 4).

Note: this is not on the hot-path of profiling, but on the post-processing side. So there should be no overhead. Plus we do populate `occ_result` already, just weren't using other attributes.

Reviewed By: scotts

Differential Revision: D98209055
divyanshk added a commit that referenced this pull request Mar 26, 2026
Summary:
Pull Request resolved: #1330

What's different in this diff? Nothing. It is on top of MTIA's changes to include the right symbols
in their `cuda_occupancy.h` shim: D97952003, D98009788.
The failure in MTIA tests were because these symbols didn't exist earlier.
-----------------------------------------------------------------------------------------------------

`cudaOccResult` from `cuda_occupancy.h` has information which should help better interpret Kineto's occupany estimates.

```
struct cudaOccResult {
    int activeBlocksPerMultiprocessor; // Occupancy
    unsigned int limitingFactors;      // Factors that limited occupancy. A bit
                                       // field that counts the limiting
                                       // factors, see cudaOccLimitingFactor
    int blockLimitRegs;                // Occupancy due to register
                                       // usage, INT_MAX if the kernel does not
                                       // use any register.
    int blockLimitSharedMem;           // Occupancy due to shared memory
                                       // usage, INT_MAX if the kernel does not
                                       // use shared memory.
    int blockLimitWarps;               // Occupancy due to block size limit
    int blockLimitBlocks;              // Occupancy due to maximum number of blocks
                                       // managable per SM
    int blockLimitBarriers;            // Occupancy due to block barrier usage
    int allocatedRegistersPerBlock;    // Actual number of registers allocated per
                                       // block
    size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
                                       // per block
    cudaOccPartitionedGCConfig partitionedGCConfig;
                                       // Report if partitioned global caching
                                       // is actually enabled.
};
```

The `limitingFactors` field is a bitmask indicating which resource(s) constrained occupancy:

```
enum cudaOccLimitingFactor {
  OCC_LIMIT_WARPS    = 0x01,  // Block size (threads)
  OCC_LIMIT_REGS     = 0x02,  // Register usage
  OCC_LIMIT_SMEM     = 0x04,  // Shared memory
  OCC_LIMIT_BLOCKS   = 0x08,  // Max blocks per SM
  OCC_LIMIT_BARRIERS = 0x10   // Barrier usage
};
```

Fields like `blockLimitXXX` show the headroom in maximum number of blocks per SM if only XXX was the constraint.

`activeBlocksPerMultiprocessor` is the minimum value of the all `blockLimitXXX` values. For eg, a kernel with:
```
limitingFactors: 3 (binary 0011 = warps + registers)
blockLimitWarps: 4
blockLimitRegs: 2
activeBlocksPerMultiprocessor: 2
```
This means occupancy is register-limited (2 blocks instead of potential 4).

Note: this is not on the hot-path of profiling, but on the post-processing side. So there should be no overhead. Plus we do populate `occ_result` already, just weren't using other attributes.

Reviewed By: scotts

Differential Revision: D98209055
meta-codesync Bot pushed a commit that referenced this pull request Mar 26, 2026
Summary:

What's different in this diff? Nothing. It is on top of MTIA's changes to include the right symbols
in their `cuda_occupancy.h` shim: D97952003, D98009788.
The failure in MTIA tests were because these symbols didn't exist earlier.
-----------------------------------------------------------------------------------------------------

`cudaOccResult` from `cuda_occupancy.h` has information which should help better interpret Kineto's occupany estimates.

```
struct cudaOccResult {
    int activeBlocksPerMultiprocessor; // Occupancy
    unsigned int limitingFactors;      // Factors that limited occupancy. A bit
                                       // field that counts the limiting
                                       // factors, see cudaOccLimitingFactor
    int blockLimitRegs;                // Occupancy due to register
                                       // usage, INT_MAX if the kernel does not
                                       // use any register.
    int blockLimitSharedMem;           // Occupancy due to shared memory
                                       // usage, INT_MAX if the kernel does not
                                       // use shared memory.
    int blockLimitWarps;               // Occupancy due to block size limit
    int blockLimitBlocks;              // Occupancy due to maximum number of blocks
                                       // managable per SM
    int blockLimitBarriers;            // Occupancy due to block barrier usage
    int allocatedRegistersPerBlock;    // Actual number of registers allocated per
                                       // block
    size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
                                       // per block
    cudaOccPartitionedGCConfig partitionedGCConfig;
                                       // Report if partitioned global caching
                                       // is actually enabled.
};
```

The `limitingFactors` field is a bitmask indicating which resource(s) constrained occupancy:

```
enum cudaOccLimitingFactor {
  OCC_LIMIT_WARPS    = 0x01,  // Block size (threads)
  OCC_LIMIT_REGS     = 0x02,  // Register usage
  OCC_LIMIT_SMEM     = 0x04,  // Shared memory
  OCC_LIMIT_BLOCKS   = 0x08,  // Max blocks per SM
  OCC_LIMIT_BARRIERS = 0x10   // Barrier usage
};
```


Fields like `blockLimitXXX` show the headroom in maximum number of blocks per SM if only XXX was the constraint.

`activeBlocksPerMultiprocessor` is the minimum value of the all `blockLimitXXX` values. For eg, a kernel with:
```
limitingFactors: 3 (binary 0011 = warps + registers)
blockLimitWarps: 4
blockLimitRegs: 2
activeBlocksPerMultiprocessor: 2
```
This means occupancy is register-limited (2 blocks instead of potential 4).

Note: this is not on the hot-path of profiling, but on the post-processing side. So there should be no overhead. Plus we do populate `occ_result` already, just weren't using other attributes.

Reviewed By: scotts

Differential Revision: D98209055
divyanshk added a commit that referenced this pull request Mar 26, 2026
Summary:
Pull Request resolved: #1330

What's different in this diff? Nothing. It is on top of MTIA's changes to include the right symbols
in their `cuda_occupancy.h` shim: D97952003, D98009788.
The failure in MTIA tests were because these symbols didn't exist earlier.
-----------------------------------------------------------------------------------------------------

`cudaOccResult` from `cuda_occupancy.h` has information which should help better interpret Kineto's occupany estimates.

```
struct cudaOccResult {
    int activeBlocksPerMultiprocessor; // Occupancy
    unsigned int limitingFactors;      // Factors that limited occupancy. A bit
                                       // field that counts the limiting
                                       // factors, see cudaOccLimitingFactor
    int blockLimitRegs;                // Occupancy due to register
                                       // usage, INT_MAX if the kernel does not
                                       // use any register.
    int blockLimitSharedMem;           // Occupancy due to shared memory
                                       // usage, INT_MAX if the kernel does not
                                       // use shared memory.
    int blockLimitWarps;               // Occupancy due to block size limit
    int blockLimitBlocks;              // Occupancy due to maximum number of blocks
                                       // managable per SM
    int blockLimitBarriers;            // Occupancy due to block barrier usage
    int allocatedRegistersPerBlock;    // Actual number of registers allocated per
                                       // block
    size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
                                       // per block
    cudaOccPartitionedGCConfig partitionedGCConfig;
                                       // Report if partitioned global caching
                                       // is actually enabled.
};
```

The `limitingFactors` field is a bitmask indicating which resource(s) constrained occupancy:

```
enum cudaOccLimitingFactor {
  OCC_LIMIT_WARPS    = 0x01,  // Block size (threads)
  OCC_LIMIT_REGS     = 0x02,  // Register usage
  OCC_LIMIT_SMEM     = 0x04,  // Shared memory
  OCC_LIMIT_BLOCKS   = 0x08,  // Max blocks per SM
  OCC_LIMIT_BARRIERS = 0x10   // Barrier usage
};
```

Fields like `blockLimitXXX` show the headroom in maximum number of blocks per SM if only XXX was the constraint.

`activeBlocksPerMultiprocessor` is the minimum value of the all `blockLimitXXX` values. For eg, a kernel with:
```
limitingFactors: 3 (binary 0011 = warps + registers)
blockLimitWarps: 4
blockLimitRegs: 2
activeBlocksPerMultiprocessor: 2
```
This means occupancy is register-limited (2 blocks instead of potential 4).

Note: this is not on the hot-path of profiling, but on the post-processing side. So there should be no overhead. Plus we do populate `occ_result` already, just weren't using other attributes.

Reviewed By: scotts

Differential Revision: D98209055
meta-codesync Bot pushed a commit that referenced this pull request Mar 27, 2026
Summary:

What's different in this diff? Nothing. It is on top of MTIA's changes to include the right symbols
in their `cuda_occupancy.h` shim: D97952003, D98009788.
The failure in MTIA tests were because these symbols didn't exist earlier.
-----------------------------------------------------------------------------------------------------

`cudaOccResult` from `cuda_occupancy.h` has information which should help better interpret Kineto's occupany estimates.

```
struct cudaOccResult {
    int activeBlocksPerMultiprocessor; // Occupancy
    unsigned int limitingFactors;      // Factors that limited occupancy. A bit
                                       // field that counts the limiting
                                       // factors, see cudaOccLimitingFactor
    int blockLimitRegs;                // Occupancy due to register
                                       // usage, INT_MAX if the kernel does not
                                       // use any register.
    int blockLimitSharedMem;           // Occupancy due to shared memory
                                       // usage, INT_MAX if the kernel does not
                                       // use shared memory.
    int blockLimitWarps;               // Occupancy due to block size limit
    int blockLimitBlocks;              // Occupancy due to maximum number of blocks
                                       // managable per SM
    int blockLimitBarriers;            // Occupancy due to block barrier usage
    int allocatedRegistersPerBlock;    // Actual number of registers allocated per
                                       // block
    size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
                                       // per block
    cudaOccPartitionedGCConfig partitionedGCConfig;
                                       // Report if partitioned global caching
                                       // is actually enabled.
};
```

The `limitingFactors` field is a bitmask indicating which resource(s) constrained occupancy:

```
enum cudaOccLimitingFactor {
  OCC_LIMIT_WARPS    = 0x01,  // Block size (threads)
  OCC_LIMIT_REGS     = 0x02,  // Register usage
  OCC_LIMIT_SMEM     = 0x04,  // Shared memory
  OCC_LIMIT_BLOCKS   = 0x08,  // Max blocks per SM
  OCC_LIMIT_BARRIERS = 0x10   // Barrier usage
};
```


Fields like `blockLimitXXX` show the headroom in maximum number of blocks per SM if only XXX was the constraint.

`activeBlocksPerMultiprocessor` is the minimum value of the all `blockLimitXXX` values. For eg, a kernel with:
```
limitingFactors: 3 (binary 0011 = warps + registers)
blockLimitWarps: 4
blockLimitRegs: 2
activeBlocksPerMultiprocessor: 2
```
This means occupancy is register-limited (2 blocks instead of potential 4).

Note: this is not on the hot-path of profiling, but on the post-processing side. So there should be no overhead. Plus we do populate `occ_result` already, just weren't using other attributes.

Reviewed By: fenypatel99, scotts

Differential Revision: D98209055
meta-codesync Bot pushed a commit that referenced this pull request Mar 27, 2026
Summary:

What's different in this diff? Nothing. It is on top of MTIA's changes to include the right symbols
in their `cuda_occupancy.h` shim: D97952003, D98009788.
The failure in MTIA tests were because these symbols didn't exist earlier.
-----------------------------------------------------------------------------------------------------

`cudaOccResult` from `cuda_occupancy.h` has information which should help better interpret Kineto's occupany estimates.

```
struct cudaOccResult {
    int activeBlocksPerMultiprocessor; // Occupancy
    unsigned int limitingFactors;      // Factors that limited occupancy. A bit
                                       // field that counts the limiting
                                       // factors, see cudaOccLimitingFactor
    int blockLimitRegs;                // Occupancy due to register
                                       // usage, INT_MAX if the kernel does not
                                       // use any register.
    int blockLimitSharedMem;           // Occupancy due to shared memory
                                       // usage, INT_MAX if the kernel does not
                                       // use shared memory.
    int blockLimitWarps;               // Occupancy due to block size limit
    int blockLimitBlocks;              // Occupancy due to maximum number of blocks
                                       // managable per SM
    int blockLimitBarriers;            // Occupancy due to block barrier usage
    int allocatedRegistersPerBlock;    // Actual number of registers allocated per
                                       // block
    size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
                                       // per block
    cudaOccPartitionedGCConfig partitionedGCConfig;
                                       // Report if partitioned global caching
                                       // is actually enabled.
};
```

The `limitingFactors` field is a bitmask indicating which resource(s) constrained occupancy:

```
enum cudaOccLimitingFactor {
  OCC_LIMIT_WARPS    = 0x01,  // Block size (threads)
  OCC_LIMIT_REGS     = 0x02,  // Register usage
  OCC_LIMIT_SMEM     = 0x04,  // Shared memory
  OCC_LIMIT_BLOCKS   = 0x08,  // Max blocks per SM
  OCC_LIMIT_BARRIERS = 0x10   // Barrier usage
};
```


Fields like `blockLimitXXX` show the headroom in maximum number of blocks per SM if only XXX was the constraint.

`activeBlocksPerMultiprocessor` is the minimum value of the all `blockLimitXXX` values. For eg, a kernel with:
```
limitingFactors: 3 (binary 0011 = warps + registers)
blockLimitWarps: 4
blockLimitRegs: 2
activeBlocksPerMultiprocessor: 2
```
This means occupancy is register-limited (2 blocks instead of potential 4).

Note: this is not on the hot-path of profiling, but on the post-processing side. So there should be no overhead. Plus we do populate `occ_result` already, just weren't using other attributes.

Reviewed By: fenypatel99, scotts

Differential Revision: D98209055
divyanshk added a commit that referenced this pull request Mar 27, 2026
Summary:
Pull Request resolved: #1330

What's different in this diff? Nothing. It is on top of MTIA's changes to include the right symbols
in their `cuda_occupancy.h` shim: D97952003, D98009788.
The failure in MTIA tests were because these symbols didn't exist earlier.
-----------------------------------------------------------------------------------------------------

`cudaOccResult` from `cuda_occupancy.h` has information which should help better interpret Kineto's occupany estimates.

```
struct cudaOccResult {
    int activeBlocksPerMultiprocessor; // Occupancy
    unsigned int limitingFactors;      // Factors that limited occupancy. A bit
                                       // field that counts the limiting
                                       // factors, see cudaOccLimitingFactor
    int blockLimitRegs;                // Occupancy due to register
                                       // usage, INT_MAX if the kernel does not
                                       // use any register.
    int blockLimitSharedMem;           // Occupancy due to shared memory
                                       // usage, INT_MAX if the kernel does not
                                       // use shared memory.
    int blockLimitWarps;               // Occupancy due to block size limit
    int blockLimitBlocks;              // Occupancy due to maximum number of blocks
                                       // managable per SM
    int blockLimitBarriers;            // Occupancy due to block barrier usage
    int allocatedRegistersPerBlock;    // Actual number of registers allocated per
                                       // block
    size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
                                       // per block
    cudaOccPartitionedGCConfig partitionedGCConfig;
                                       // Report if partitioned global caching
                                       // is actually enabled.
};
```

The `limitingFactors` field is a bitmask indicating which resource(s) constrained occupancy:

```
enum cudaOccLimitingFactor {
  OCC_LIMIT_WARPS    = 0x01,  // Block size (threads)
  OCC_LIMIT_REGS     = 0x02,  // Register usage
  OCC_LIMIT_SMEM     = 0x04,  // Shared memory
  OCC_LIMIT_BLOCKS   = 0x08,  // Max blocks per SM
  OCC_LIMIT_BARRIERS = 0x10   // Barrier usage
};
```

Fields like `blockLimitXXX` show the headroom in maximum number of blocks per SM if only XXX was the constraint.

`activeBlocksPerMultiprocessor` is the minimum value of the all `blockLimitXXX` values. For eg, a kernel with:
```
limitingFactors: 3 (binary 0011 = warps + registers)
blockLimitWarps: 4
blockLimitRegs: 2
activeBlocksPerMultiprocessor: 2
```
This means occupancy is register-limited (2 blocks instead of potential 4).

Note: this is not on the hot-path of profiling, but on the post-processing side. So there should be no overhead. Plus we do populate `occ_result` already, just weren't using other attributes.

Reviewed By: fenypatel99, scotts

Differential Revision: D98209055
Summary:
Pull Request resolved: #1330

What's different in this diff? Nothing. It is on top of MTIA's changes to include the right symbols
in their `cuda_occupancy.h` shim: D97952003, D98009788.
The failure in MTIA tests were because these symbols didn't exist earlier.
-----------------------------------------------------------------------------------------------------

`cudaOccResult` from `cuda_occupancy.h` has information which should help better interpret Kineto's occupany estimates.

```
struct cudaOccResult {
    int activeBlocksPerMultiprocessor; // Occupancy
    unsigned int limitingFactors;      // Factors that limited occupancy. A bit
                                       // field that counts the limiting
                                       // factors, see cudaOccLimitingFactor
    int blockLimitRegs;                // Occupancy due to register
                                       // usage, INT_MAX if the kernel does not
                                       // use any register.
    int blockLimitSharedMem;           // Occupancy due to shared memory
                                       // usage, INT_MAX if the kernel does not
                                       // use shared memory.
    int blockLimitWarps;               // Occupancy due to block size limit
    int blockLimitBlocks;              // Occupancy due to maximum number of blocks
                                       // managable per SM
    int blockLimitBarriers;            // Occupancy due to block barrier usage
    int allocatedRegistersPerBlock;    // Actual number of registers allocated per
                                       // block
    size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
                                       // per block
    cudaOccPartitionedGCConfig partitionedGCConfig;
                                       // Report if partitioned global caching
                                       // is actually enabled.
};
```

The `limitingFactors` field is a bitmask indicating which resource(s) constrained occupancy:

```
enum cudaOccLimitingFactor {
  OCC_LIMIT_WARPS    = 0x01,  // Block size (threads)
  OCC_LIMIT_REGS     = 0x02,  // Register usage
  OCC_LIMIT_SMEM     = 0x04,  // Shared memory
  OCC_LIMIT_BLOCKS   = 0x08,  // Max blocks per SM
  OCC_LIMIT_BARRIERS = 0x10   // Barrier usage
};
```

Fields like `blockLimitXXX` show the headroom in maximum number of blocks per SM if only XXX was the constraint.

`activeBlocksPerMultiprocessor` is the minimum value of the all `blockLimitXXX` values. For eg, a kernel with:
```
limitingFactors: 3 (binary 0011 = warps + registers)
blockLimitWarps: 4
blockLimitRegs: 2
activeBlocksPerMultiprocessor: 2
```
This means occupancy is register-limited (2 blocks instead of potential 4).

Note: this is not on the hot-path of profiling, but on the post-processing side. So there should be no overhead. Plus we do populate `occ_result` already, just weren't using other attributes.

Reviewed By: fenypatel99, scotts

Differential Revision: D98209055
@meta-codesync

meta-codesync Bot commented Mar 27, 2026

Copy link
Copy Markdown

This pull request has been merged in 185fe9c.

pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Apr 2, 2026
Includes the following commits:

* Expose occupany limiting factors (pytorch/kineto#1330)
* remove the rocprofiler early exit hack (pytorch/kineto#1329)
* Remove duplicate test ignore (pytorch/kineto#1328)
* Ensure that async doesn't loop while sync is active (pytorch/kineto#1327)
* Add host_name to OSS Kineto trace metadata via gethostname() (pytorch/kineto#1323)
* Revert D97166802 (pytorch/kineto#1326)
* Fix Lingering INT32 Overflow (pytorch/kineto#1324)
* Re-enabled some hardcoded tests (pytorch/kineto#1321)
* Expose occupany limiting factors (pytorch/kineto#1322)

Authored with Claude.
Pull Request resolved: #178918
Approved by: https://github.com/divyanshk
weifengpy pushed a commit to pytorch/pytorch that referenced this pull request Apr 7, 2026
Includes the following commits:

* Expose occupany limiting factors (pytorch/kineto#1330)
* remove the rocprofiler early exit hack (pytorch/kineto#1329)
* Remove duplicate test ignore (pytorch/kineto#1328)
* Ensure that async doesn't loop while sync is active (pytorch/kineto#1327)
* Add host_name to OSS Kineto trace metadata via gethostname() (pytorch/kineto#1323)
* Revert D97166802 (pytorch/kineto#1326)
* Fix Lingering INT32 Overflow (pytorch/kineto#1324)
* Re-enabled some hardcoded tests (pytorch/kineto#1321)
* Expose occupany limiting factors (pytorch/kineto#1322)

Authored with Claude.
Pull Request resolved: #178918
Approved by: https://github.com/divyanshk
nklshy-aws pushed a commit to nklshy-aws/pytorch that referenced this pull request Apr 7, 2026
Includes the following commits:

* Expose occupany limiting factors (pytorch/kineto#1330)
* remove the rocprofiler early exit hack (pytorch/kineto#1329)
* Remove duplicate test ignore (pytorch/kineto#1328)
* Ensure that async doesn't loop while sync is active (pytorch/kineto#1327)
* Add host_name to OSS Kineto trace metadata via gethostname() (pytorch/kineto#1323)
* Revert D97166802 (pytorch/kineto#1326)
* Fix Lingering INT32 Overflow (pytorch/kineto#1324)
* Re-enabled some hardcoded tests (pytorch/kineto#1321)
* Expose occupany limiting factors (pytorch/kineto#1322)

Authored with Claude.
Pull Request resolved: pytorch#178918
Approved by: https://github.com/divyanshk
scotts added a commit to scotts/pytorch that referenced this pull request Apr 9, 2026
Includes the following commits:

- Fix GPU trace collection on ROCm by ensuring early rocprofiler-sdk tool registration (pytorch/kineto#1338) 4ff89e8
- Remove tb_plugin CI workflows (pytorch/kineto#1341) e335a7d
- Remove INFO logs from kineto trace metadata to fix invalid JSON (pytorch/kineto#1336) 502c513
- Expose occupany limiting factors (pytorch/kineto#1330) 185fe9c
- remove the rocprofiler early exit hack (pytorch/kineto#1329) 0c8ede0

Authored with Claude.
scotts added a commit to scotts/pytorch that referenced this pull request Apr 10, 2026
Includes the following commits:

- Emit USDT logger messages on profiler start/stop (pytorch/kineto#1325) b2103f7
- Fix NCCL metadata missing on GPU kernels due to CUPTI buffer ordering (pytorch/kineto#1354) 360873c
- Modernize target_link_libraries in Cmakelists.txt (pytorch/kineto#1283) 2b26470
- Replace shared_ptr singleton with Meyers singleton in CuptiCallbackApi (pytorch/kineto#1350) f287ee7
- Fix XpuptiProfilerTest link error and double free crash (pytorch/kineto#1349) eea2334
- Fix missing wait_on_cuda_event_record_corr_id in Event Synchronize activities (pytorch/kineto#1318) f689d8a
- approximate clock fast path for arm (pytorch/kineto#1333) ec4a9b0
- Fix ABBA deadlock in bufferCompleted when verbose logging is enabled (pytorch/kineto#1347) 404f8cd
- refactor JSON chrome trace writing (pytorch/kineto#1342) c51fcfe
- Fix GPU trace collection on ROCm by ensuring early rocprofiler-sdk tool registration (pytorch/kineto#1338) 4ff89e8
- Remove tb_plugin CI workflows (pytorch/kineto#1341) e335a7d
- Remove INFO logs from kineto trace metadata to fix invalid JSON (pytorch/kineto#1336) 502c513
- Expose occupany limiting factors (pytorch/kineto#1330) 185fe9c

Authored with Claude.
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Apr 10, 2026
Includes the following commits:

- Emit USDT logger messages on profiler start/stop (pytorch/kineto#1325) b2103f7
- Fix NCCL metadata missing on GPU kernels due to CUPTI buffer ordering (pytorch/kineto#1354) 360873c
- Modernize target_link_libraries in Cmakelists.txt (pytorch/kineto#1283) 2b26470
- Replace shared_ptr singleton with Meyers singleton in CuptiCallbackApi (pytorch/kineto#1350) f287ee7
- Fix XpuptiProfilerTest link error and double free crash (pytorch/kineto#1349) eea2334
- Fix missing wait_on_cuda_event_record_corr_id in Event Synchronize activities (pytorch/kineto#1318) f689d8a
- approximate clock fast path for arm (pytorch/kineto#1333) ec4a9b0
- Fix ABBA deadlock in bufferCompleted when verbose logging is enabled (pytorch/kineto#1347) 404f8cd
- refactor JSON chrome trace writing (pytorch/kineto#1342) c51fcfe
- Fix GPU trace collection on ROCm by ensuring early rocprofiler-sdk tool registration (pytorch/kineto#1338) 4ff89e8
- Remove tb_plugin CI workflows (pytorch/kineto#1341) e335a7d
- Remove INFO logs from kineto trace metadata to fix invalid JSON (pytorch/kineto#1336) 502c513
- Expose occupany limiting factors (pytorch/kineto#1330) 185fe9c

Authored with Claude.
Pull Request resolved: #179906
Approved by: https://github.com/ryanzhang22
bobrenjc93 pushed a commit to bobrenjc93/pytorch that referenced this pull request Apr 10, 2026
Includes the following commits:

* Expose occupany limiting factors (pytorch/kineto#1330)
* remove the rocprofiler early exit hack (pytorch/kineto#1329)
* Remove duplicate test ignore (pytorch/kineto#1328)
* Ensure that async doesn't loop while sync is active (pytorch/kineto#1327)
* Add host_name to OSS Kineto trace metadata via gethostname() (pytorch/kineto#1323)
* Revert D97166802 (pytorch/kineto#1326)
* Fix Lingering INT32 Overflow (pytorch/kineto#1324)
* Re-enabled some hardcoded tests (pytorch/kineto#1321)
* Expose occupany limiting factors (pytorch/kineto#1322)

Authored with Claude.
Pull Request resolved: pytorch#178918
Approved by: https://github.com/divyanshk
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Apr 15, 2026
Changes to EventMetadata:

- occupancy -> est_occupancy_pct
- introduces occupancy dictionary (which was added in pytorch/kineto#1330)

Moves json convertor inline so we don't have multiple helpers each doing the same thing with different output types.
Pull Request resolved: #180275
Approved by: https://github.com/scotts
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
Includes the following commits:

* Expose occupany limiting factors (pytorch/kineto#1330)
* remove the rocprofiler early exit hack (pytorch/kineto#1329)
* Remove duplicate test ignore (pytorch/kineto#1328)
* Ensure that async doesn't loop while sync is active (pytorch/kineto#1327)
* Add host_name to OSS Kineto trace metadata via gethostname() (pytorch/kineto#1323)
* Revert D97166802 (pytorch/kineto#1326)
* Fix Lingering INT32 Overflow (pytorch/kineto#1324)
* Re-enabled some hardcoded tests (pytorch/kineto#1321)
* Expose occupany limiting factors (pytorch/kineto#1322)

Authored with Claude.
Pull Request resolved: pytorch#178918
Approved by: https://github.com/divyanshk
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
Includes the following commits:

- Emit USDT logger messages on profiler start/stop (pytorch/kineto#1325) b2103f7
- Fix NCCL metadata missing on GPU kernels due to CUPTI buffer ordering (pytorch/kineto#1354) 360873c
- Modernize target_link_libraries in Cmakelists.txt (pytorch/kineto#1283) 2b26470
- Replace shared_ptr singleton with Meyers singleton in CuptiCallbackApi (pytorch/kineto#1350) f287ee7
- Fix XpuptiProfilerTest link error and double free crash (pytorch/kineto#1349) eea2334
- Fix missing wait_on_cuda_event_record_corr_id in Event Synchronize activities (pytorch/kineto#1318) f689d8a
- approximate clock fast path for arm (pytorch/kineto#1333) ec4a9b0
- Fix ABBA deadlock in bufferCompleted when verbose logging is enabled (pytorch/kineto#1347) 404f8cd
- refactor JSON chrome trace writing (pytorch/kineto#1342) c51fcfe
- Fix GPU trace collection on ROCm by ensuring early rocprofiler-sdk tool registration (pytorch/kineto#1338) 4ff89e8
- Remove tb_plugin CI workflows (pytorch/kineto#1341) e335a7d
- Remove INFO logs from kineto trace metadata to fix invalid JSON (pytorch/kineto#1336) 502c513
- Expose occupany limiting factors (pytorch/kineto#1330) 185fe9c

Authored with Claude.
Pull Request resolved: pytorch#179906
Approved by: https://github.com/ryanzhang22
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
Changes to EventMetadata:

- occupancy -> est_occupancy_pct
- introduces occupancy dictionary (which was added in pytorch/kineto#1330)

Moves json convertor inline so we don't have multiple helpers each doing the same thing with different output types.
Pull Request resolved: pytorch#180275
Approved by: https://github.com/scotts
ani300 pushed a commit to IBM/kineto-spyre that referenced this pull request Jul 28, 2026
Summary:
Pull Request resolved: pytorch/kineto#1330

What's different in this diff? Nothing. It is on top of MTIA's changes to include the right symbols
in their `cuda_occupancy.h` shim: D97952003, D98009788.
The failure in MTIA tests were because these symbols didn't exist earlier.
-----------------------------------------------------------------------------------------------------

`cudaOccResult` from `cuda_occupancy.h` has information which should help better interpret Kineto's occupany estimates.

```
struct cudaOccResult {
    int activeBlocksPerMultiprocessor; // Occupancy
    unsigned int limitingFactors;      // Factors that limited occupancy. A bit
                                       // field that counts the limiting
                                       // factors, see cudaOccLimitingFactor
    int blockLimitRegs;                // Occupancy due to register
                                       // usage, INT_MAX if the kernel does not
                                       // use any register.
    int blockLimitSharedMem;           // Occupancy due to shared memory
                                       // usage, INT_MAX if the kernel does not
                                       // use shared memory.
    int blockLimitWarps;               // Occupancy due to block size limit
    int blockLimitBlocks;              // Occupancy due to maximum number of blocks
                                       // managable per SM
    int blockLimitBarriers;            // Occupancy due to block barrier usage
    int allocatedRegistersPerBlock;    // Actual number of registers allocated per
                                       // block
    size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
                                       // per block
    cudaOccPartitionedGCConfig partitionedGCConfig;
                                       // Report if partitioned global caching
                                       // is actually enabled.
};
```

The `limitingFactors` field is a bitmask indicating which resource(s) constrained occupancy:

```
enum cudaOccLimitingFactor {
  OCC_LIMIT_WARPS    = 0x01,  // Block size (threads)
  OCC_LIMIT_REGS     = 0x02,  // Register usage
  OCC_LIMIT_SMEM     = 0x04,  // Shared memory
  OCC_LIMIT_BLOCKS   = 0x08,  // Max blocks per SM
  OCC_LIMIT_BARRIERS = 0x10   // Barrier usage
};
```

Fields like `blockLimitXXX` show the headroom in maximum number of blocks per SM if only XXX was the constraint.

`activeBlocksPerMultiprocessor` is the minimum value of the all `blockLimitXXX` values. For eg, a kernel with:
```
limitingFactors: 3 (binary 0011 = warps + registers)
blockLimitWarps: 4
blockLimitRegs: 2
activeBlocksPerMultiprocessor: 2
```
This means occupancy is register-limited (2 blocks instead of potential 4).

Note: this is not on the hot-path of profiling, but on the post-processing side. So there should be no overhead. Plus we do populate `occ_result` already, just weren't using other attributes.

Reviewed By: fenypatel99, scotts

Differential Revision: D98209055

fbshipit-source-id: 8077793d4d6080be8a4e6d9055a8ecc9f255f15e
Signed-off-by: Antoni Viros i Martin <[email protected]>
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
Includes the following commits:

* Expose occupany limiting factors (pytorch/kineto#1330)
* remove the rocprofiler early exit hack (pytorch/kineto#1329)
* Remove duplicate test ignore (pytorch/kineto#1328)
* Ensure that async doesn't loop while sync is active (pytorch/kineto#1327)
* Add host_name to OSS Kineto trace metadata via gethostname() (pytorch/kineto#1323)
* Revert D97166802 (pytorch/kineto#1326)
* Fix Lingering INT32 Overflow (pytorch/kineto#1324)
* Re-enabled some hardcoded tests (pytorch/kineto#1321)
* Expose occupany limiting factors (pytorch/kineto#1322)

Authored with Claude.
Pull Request resolved: pytorch#178918
Approved by: https://github.com/divyanshk
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
Includes the following commits:

- Emit USDT logger messages on profiler start/stop (pytorch/kineto#1325) b2103f7
- Fix NCCL metadata missing on GPU kernels due to CUPTI buffer ordering (pytorch/kineto#1354) 360873c
- Modernize target_link_libraries in Cmakelists.txt (pytorch/kineto#1283) 2b26470
- Replace shared_ptr singleton with Meyers singleton in CuptiCallbackApi (pytorch/kineto#1350) f287ee7
- Fix XpuptiProfilerTest link error and double free crash (pytorch/kineto#1349) eea2334
- Fix missing wait_on_cuda_event_record_corr_id in Event Synchronize activities (pytorch/kineto#1318) f689d8a
- approximate clock fast path for arm (pytorch/kineto#1333) ec4a9b0
- Fix ABBA deadlock in bufferCompleted when verbose logging is enabled (pytorch/kineto#1347) 404f8cd
- refactor JSON chrome trace writing (pytorch/kineto#1342) c51fcfe
- Fix GPU trace collection on ROCm by ensuring early rocprofiler-sdk tool registration (pytorch/kineto#1338) 4ff89e8
- Remove tb_plugin CI workflows (pytorch/kineto#1341) e335a7d
- Remove INFO logs from kineto trace metadata to fix invalid JSON (pytorch/kineto#1336) 502c513
- Expose occupany limiting factors (pytorch/kineto#1330) 185fe9c

Authored with Claude.
Pull Request resolved: pytorch#179906
Approved by: https://github.com/ryanzhang22
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
Changes to EventMetadata:

- occupancy -> est_occupancy_pct
- introduces occupancy dictionary (which was added in pytorch/kineto#1330)

Moves json convertor inline so we don't have multiple helpers each doing the same thing with different output types.
Pull Request resolved: pytorch#180275
Approved by: https://github.com/scotts
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant